[rabbitmq-discuss] Autorecovery Issue

Michael Klishin mklishin at gopivotal.com
Fri Jun 20 07:23:10 BST 2014



On 20 June 2014 at 10:16:14, Ranjitha Shet (ranjithavshet09 at gmail.com) wrote:
> > to receive message what I do is -->
>  
> while(true){
>  
> try{
>  
> QueueingConsumer.Delivery delivery = consumer.nextDelivery();  
> ..
> ..
> }
> catch (ShutdownSignalException sse) {
>  
> // notify client about network disconnection
> // check if connection and channel is open... if its open then  
> this current thread is delayed for some time so that exchange,  
> queue, binding and consumer are restored..
>  
> } catch (java.io.IOException ioe) {
>  
> }
>  
>  
> } // end of while

QueueingConsumers currently cannot be recovered: on shutdown,
they modify their internal state in a way that marks them as "done".
Think of them as Iterators which have a logical end.

You have two options:

 * Use a "regular" consumer (recommended)
 * Add a recovery listener and re-create the queueing consumer

Automatic connection recovery simply re-adds the consumer(s) you previously
had, without knowing anything about their implementation and if they can "self terminate"
like the QueueingConsumer does. 
--  
MK  

Software Engineer, Pivotal/RabbitMQ


More information about the rabbitmq-discuss mailing list