<div>I think I have the registration issue worked out now.</div><div>&nbsp;</div><div>Does anyone know how I can catch Exception on sending to queues ?</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div><br>On Thursday, December 20, 2012 1:55:53 PM UTC-5, CJ wrote:</div><blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="gmail_quote"><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>&nbsp;<br>&nbsp;&nbsp;&nbsp; while ( numMsgs &lt; maxMsgs ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try { channel.basicPublish( exchange, queueName, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (persistEnabled) ? MessageProperties.PERSISTENT_<wbr>TEXT_PLAIN : null,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; message.getBytes()); }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("--- Connection Broken ---");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<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.&nbsp; I use the following code on the nextDelivery<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (ShutdownSignalException ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("--- Broker Shut Down ---");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch (Exception ex) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("--- Broker Shut Down ---");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>But I get the following error:<br>&nbsp;<br>Exception in thread "main" com.rabbitmq.client.<wbr>ShutdownSignalException: connecti<br>on error; reason: {#method&lt;connection.close&gt;(<wbr>reply-code=320, reply-text=CONNECTI<br>ON_FORCED - broker forced connection closure with reason 'shutdown', class-id=0,<br>&nbsp;method-id=0), null, ""}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.<wbr>QueueingConsumer.handle(<wbr>QueueingConsumer.java:198<br>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at com.rabbitmq.client.<wbr>QueueingConsumer.nextDelivery(<wbr>QueueingConsumer.ja<br>va:227)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at Recv.main(Recv.java:50)<br>&nbsp;<br>Does Rabbit support catching broken connections in the consumer ?</p><p>How can I do this ?</p></blockquote>