[rabbitmq-discuss] Reconnect to RabbitMQ broker

Matthew Ward matt.c.ward at gmail.com
Thu Mar 15 02:46:14 GMT 2012

I am running some tests for an async process that consumes messages from 
rabbitmq. We are trying to figure out how to gracefully handle rabbitmq 
going away and coming back. The goal is to have the async process reconnect 
and resume operations. To simulate the situation I start my consumer, then 
I turn rabbitmq off, wait then turn it back on.

As expected, Connection Refused exceptions are thrown (and caught) while 
rabbitmq is off. As soon as I bring the server back online, it throws 

com.rabbitmq.client.ShutdownSignalException: connection error; reason: 
{#method<connection.close>(reply-code=320, reply-text=CONNECTION_FORCED - 
broker forced connection closure with reason 'shutdown', class-id=0, 
method-id=0), null, "[B at 275e538e"}
at com.rabbitmq.client.QueueingConsumer.handle(QueueingConsumer.java:198)
at com.rabbitmq.client.QueueingConsumer.nextDelivery(

How do I gracefully handle the shutdown so that I can get back to 
consuming? I attempted shutting the channel / connection and creating a new 
connection from the factory but the shutdown signal exception is still 
thrown after 'reconnect'. What's going on under the hood that keeps me from 
successfully consuming again? Is there some sort of message I need to tell 
RabbitMQ "yes I know I shut you down, but its you're back up so 
stop crying..."


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

More information about the rabbitmq-discuss mailing list