C++ CORBA DII 问题
请所有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过将对象引用从 _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.
我对此不太确定,但在我看来,如果第一次轮询响应失败,您将退出此功能。然后,当您返回时,您将发送另一条消息(使用
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.