If you don't set an ExceptionListener on the connection to the broker from within your consumer you won't get any notification if the connection to the broker has been lost, instead MessageConsumer.receive() will only return null or block indefinitely depending on if you use the timeout parameter or not. The JMS specification clearly states (section 4.3.8):
To reproduce this use my modified ConsumerTool.java, copy it into examples/src. Run the broker, then run the consumer like:
Then run the producer like:
You'll see the consumer will get the 5 messages. Now Ctrl-C the broker and restart it. The consumer will still be running. If you run the producer again the consumer won't get the messages even though it's still blocked on MessageConsumer.receive().
Also note that if I do use the ExceptionListener on the connection object but take out the timeout parameter on line 182 in ConsumerTool.java if an exception is handled by the ExceptionListener the call to receive() is still blocked which means the example consumer won't exit when you bounce the broker.