[rabbitmq-discuss] Cathing broker shut down in a consumer
CJ
rmqjava1a at yahoo.com
Thu Dec 20 18:55:53 GMT 2012
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/20121220/55954bea/attachment.htm>
More information about the rabbitmq-discuss
mailing list