C++ CORBA DII 问题

发布于 2024-09-25 12:07:06 字数 1231 浏览 2 评论 0原文

请所有 CORBA 专家帮我解决这个问题吗?

我有一个多线程应用程序,其中包含一些代码,这些代码将消息发送到服务器并等待返回响应。我可以看到服务器正在发送回响应,但应用程序似乎没有收到它。

这是我的代码的一部分。

  // Create a request object for the given message
  msg.request = serverRef->_request("receiveCoreMessageVia");
  msg.request->set_return_type (CORBA::_tc_short);

  msg.request->add_in_arg() <<= msg.sourceGateway;
  msg.request->add_in_arg() <<= msg.octetSeq;

  msg.request->send_deferred();

  ...
  // The following code is in a while loop in a different function. It uses the request reference to check the response.
  // Check if the request has completed
  if (!msg->request->poll_response())
  {
    clssendlog << debug << "Polling..." << endl;

    return false; // No response yet
  }

  // Get the returned result
  clssendlog << debug << "Get response..." << endl;
  msg->request->get_response();

  clssendlog << debug << "Reading the returned response value" << endl;
  CORBA::Short tmp = 0;
  msg->request->return_value () >>= tmp;

结果是,即使服务器响应,它仍然显示“轮询”。 这是一个基本的 DII 调用,我实际上是在 ACE/TAO 5.7.9 上测试代码。这段代码在omniORB 4.1.4 上完美运行。然而,我真的希望这能在 ACE/TAO 上运行。

Could all those CORBA experts out there please help me with this one.

I have a multithreaded application with some code that sends a message to a server and waits for a response back. I can see that the server is sending the response back however the application doesnt seem to receive it.

Heres part of my code.

  // Create a request object for the given message
  msg.request = serverRef->_request("receiveCoreMessageVia");
  msg.request->set_return_type (CORBA::_tc_short);

  msg.request->add_in_arg() <<= msg.sourceGateway;
  msg.request->add_in_arg() <<= msg.octetSeq;

  msg.request->send_deferred();

  ...
  // The following code is in a while loop in a different function. It uses the request reference to check the response.
  // Check if the request has completed
  if (!msg->request->poll_response())
  {
    clssendlog << debug << "Polling..." << endl;

    return false; // No response yet
  }

  // Get the returned result
  clssendlog << debug << "Get response..." << endl;
  msg->request->get_response();

  clssendlog << debug << "Reading the returned response value" << endl;
  CORBA::Short tmp = 0;
  msg->request->return_value () >>= tmp;

The result is that it keeps saying Polling even if the server responds.
This is a basic DII invocation and I am actually testing the code on ACE/TAO 5.7.9. This exact code works perfectly on omniORB 4.1.4. However, I really want this to work on ACE/TAO.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人的夜不怕黑 2024-10-02 12:07:06

通过将对象引用从 _ptr 更改为 _var 设法修复。我编写了一个小型测试应用程序来验证这一点。更改指针类型后,其行为按预期提供响应。所以问题是获取对接口的初始引用。

Managed to fix by changing object reference from _ptr to _var. I wrote a small test application to verify this. After changing the pointer type its behaving as expected serving the responses. So the problem was getting the initial reference to the interface.

水溶 2024-10-02 12:07:06

我对此不太确定,但在我看来,如果第一次轮询响应失败,您将退出此功能。然后,当您返回时,您将发送另一条消息(使用 send_deferred() 调用),独立于第一条消息。

这意味着,除非您运气好并且在调用 poll_response() 之前出现响应,否则您将始终收到轮询消息。

I'm not too sure about this but it appears to me that you will exit this function if the first poll response fails. Then, when you come back in, you'll send another message (with the send_deferred() call), independent from the first.

That means that, unless you strike it lucky and a response appears before you call poll_response(), you'll always get a polling message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文