[rabbitmq-discuss] Recovery after heartbeat error

Ioannis Foukarakis ioannis.foukarakis at gmail.com
Thu Mar 7 13:28:26 GMT 2013


I am trying to setup a simple application using Java client (v3.0.2), where
a single consumer receives messages from a queue and recovers on failure. I
added a heartbeat to my connection, as the network between the client and
RabbitMQ is not very reliable. I also implemented ShutdownListener and
attached the listener to my connection and channel. When I receive a
shutdown signal, I close the connection and the channel, and then attempt
to create a new connection and channel. If I fail, I retry after a few
seconds. I tested this logic by starting the client and shutting down
RabbitMQ, and this works perfectly. However, if I disconnect from the
network, channel.close() blocks. I've tried the following two cases:

   - Attempt calling channel.close() before the shutdown signal is passed
   to shutdownCompleted(...).
   - Attempt calling channel.close() after the shutdown signal is passed to

In both cases channel.close() blocks. In the second one, I can add a flag
and avoid calling channel.close(), but in the first case I'm not able to
detect if there's a network problem or not.

Should I avoid trying to close channels? Is there a better solution for
handling network errors?

Thank you in advance for your time!

Kind regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130307/de438838/attachment.htm>

More information about the rabbitmq-discuss mailing list