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