[rabbitmq-discuss] Cathing broker shut down in a consumer

CJ rmqjava1a at yahoo.com
Fri Dec 21 18:55:10 GMT 2012


I think I have the registration issue worked out now.
 
Does anyone know how I can catch Exception on sending to queues ?
 
 
 

On Thursday, December 20, 2012 1:55:53 PM UTC-5, CJ wrote:

> I need to write an exception in the case of a broker shutdown to end my 
> programs gracefully
>
> In the Sender, I used the following code successfully:
>  
>     while ( numMsgs < maxMsgs ) {
>       try { channel.basicPublish( exchange, queueName, 
>             (persistEnabled) ? MessageProperties.PERSISTENT_TEXT_PLAIN : 
> null,
>             message.getBytes()); }
>       catch (Exception ex) {
>          System.out.println("--- Connection Broken ---");
>       }
>  
> This catches the IOException and termiates gracefully on the Sender.
> I can NOT do this on the consumer, where I get the following error once 
> the broker is shut down
> I do not seem to be able to catch the problem of the broker coming down in 
> the consumer.  I use the following code on the nextDelivery
>  
>       catch (ShutdownSignalException ex) {
>          System.out.println("--- Broker Shut Down ---");
>       }
>       catch (Exception ex) {
>          System.out.println("--- Broker Shut Down ---");
>       }
>  
> But I get the following error:
>  
> Exception in thread "main" com.rabbitmq.client.ShutdownSignalException: 
> connecti
> on error; reason: {#method<connection.close>(reply-code=320, 
> reply-text=CONNECTI
> ON_FORCED - broker forced connection closure with reason 'shutdown', 
> class-id=0,
>  method-id=0), null, ""}
>         at 
> com.rabbitmq.client.QueueingConsumer.handle(QueueingConsumer.java:198
> )
>         at 
> com.rabbitmq.client.QueueingConsumer.nextDelivery(QueueingConsumer.ja
> va:227)
>         at Recv.main(Recv.java:50)
>  
> Does Rabbit support catching broken connections in the consumer ?
>
> How can I do this ?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121221/15c3e73c/attachment.htm>


More information about the rabbitmq-discuss mailing list