Hi!

I'm sort of new to QPid, and I'm trying to set up a broker link based on the qpid::messaging API, with connections, sessions, receivers etc. Actually, I've had a setup that works quite all right in the normal case for a while, but I'm a bit confused about how errors are supposed to be handled, or to be more precise, what happens to the session when an operation fails. Specifically, if I have message handling code equivalent to:

std::string broker="myBrokerHost";
qpid::messaging::Connection connection(broker);
qpid::messaging::Session session;
qpid::messaging::Receiver receiver;

while(1) {
 try {
   if(!connection.isOpen())
     connection.open();
if(session.isNull())
     session=authConnection.createSession();
   if(receiver.isNull())
receiver=session.createReceiver("my-exchange/my-topic"); // .... Check for message on receiver, and handle as appropriate

 } catch(const qpid::types::Exception &error) {
   fprintf(stderr, "Error - \"%s\" when opening link to %s\n",
            error.what(), broker.c_str());
 }
}

Which, like I said, works if everything is OK. If the broker connection works, but the receiver address ("my-exchange/my-topic") initially doesn't exist on the broker I have a problem, on the other hand. In this case, I get an error message like

Error - "Queue my-exchange does not exist" when opening power link to myBrokerHost

on every iteration of the loop. This is what I expect when the address doesn't exist, of course, but - and here is the real problem - even if I create the appropriate exchange/topic/queue, the error will keep appearing. In fact, it may seem like Session::createReceiver(), once it has failed, will just keep re-throwing the exception associated with the first failure (on subsequent calls), rather than trying the actual broker connection again.

So, what's the expected behaviour related to this? Is simply the session invalid once there has been a failure, so that I have to create a new one? Or is there some way to reset? Or is a re-issued createReceiver() (or createSender()) actually supposed to try contacting the broker again? And what if I have multiple senders and receivers associated with a session, and some addresses exist, but others don't?

I've tried all this with AMQP 0.7 and 0.8 under Linux...

- Toralf


This e-mail, including any attachments and response string, may contain 
proprietary information which is confidential and may be legally privileged. It 
is for the intended recipient only. If you are not the intended recipient or 
transmission error has misdirected this e-mail, please notify the author by 
return e-mail and delete this message and any attachment immediately. If you 
are not the intended recipient you must not use, disclose, distribute, forward, 
copy, print or rely on this e-mail in any way except as permitted by the author.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to