[omniORB] DII question: How do I interpret the result of ORB::get_next_response()

Alex Tingle alex.tingle at bronermetals.com
Mon Nov 24 12:04:53 GMT 2003


Hello,

Does anyone know whether I can use _is_equivalent() to reliably compare the 'target' from ORB::get_next_response() with the object ref used to send the invokation?

In more depth:

Here's my interface:

  interface PushConsumer{
    void push(Any any);
  };

I don't want to keep Request objects hanging around in my application, so I want to use the Dynamic Invokation Interface's ORB::send_multiple_requests_deferred() method to send out lots of method invokations, and then collect the responses in another thread. But how do I work out which response goes with which request?

I send requests like this:

  vector<Object_ptr> targets =...;
  CORBA::ORB::RequestSeq reqs;
  reqs.length(targets.length());
  for(long i=0; i<targets.length(); ++i)
  {
    reqs[i]=targets[i]->_request("push");
  }
  orb->send_multiple_requests_deferred(reqs);

I collect the responses like this:

  CORBA::Request_var req;
  while(true)
  {
    omni_thread::sleep(1);
    while(orb->poll_next_response())
    {
      orb->get_next_response(req.out());
      Object_var target=req->target();
      CORBA::String_var op=req->operation();
      cout<<"Got reply for operation: "<<op.in()<<"()"<<endl;
    }
  }

This code fragment shows a call to Request::operation(), which successfully 
tells me to which operation the response corresponds. I also get an object ref 'target'.

Here's the question again: Can I use _is_equivalent() to reliably compare 'target' with the object refs used to send the invokation? Like this:

  Object_var target=req->target();
  for(long i=0; i<targets.length(); ++i)
  {
    if(targets[i]->_is_equivalent(target))
      cout<<"Response is from object "<<i<<endl;
  }

_is_equivalent() is defined to be an uncertain operation. But surely a method response must contain enough information to match it up with its invokation. Indeed, if I were not being so difficult, I could have called req->send_deferred(), and the response would definitely come back to the object from which I called it.

Is there a more efficient way for me to match response to request? Calling _is_equivalent() on thousands of object references for each of thousands of response could easily get very expensive.

Finally, before you ask. No, I can't change the interface to provide an id in the response... I'm calling CosEventComm::PushConsumer::push(Any) which has been defined for me by the OMG.

tia,

-Alex



More information about the omniORB-list mailing list