所有那些 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;
结果就是一直说Polling即使服务器有响应。 这是一个基本的 DII 调用,我实际上是在 ACE/TAO 5.7.9 上测试代码。这个确切的代码在 omniORB 4.1.4 上完美运行。但是,我真的希望它适用于 ACE/TAO。
最佳答案
通过将对象引用从 _ptr 更改为 _var 设法修复。我写了一个小的测试应用程序来验证这一点。更改指针类型后,其行为将按预期服务于响应。所以问题是获取对接口(interface)的初始引用。
关于C++ CORBA DII 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3809937/