[rabbitmq-discuss] Advice on where to reset connection and channel

Michael Klishin mklishin at gopivotal.com
Sun Feb 16 06:44:43 GMT 2014


On 16 Feb 2014, at 09:09, cw storm <cwstorm at gmail.com> wrote:

> I don't think I would want to include the function to re-establish the connection/channel in both of the handlers.  So, where would I perform the re-connect logic.  Maybe I should just pick one.

JVM language clients that support reconnection, including RabbitMQ Java client itself on branch bug14587, have a wrapper connection that
delegates everything to the underlying connection (so, implements com.rabbitmq.client.Connection) and adds a shutdown listener
that performs recovery:

 * Reconnects (creates a new delegate connection)
 * Reopens all channels (there is a wrapper Channel as well), including various listeners
 * Recovers queues, exchange, bindings, and consumers (in this order)

> Also, another consumer callback name "handleCancel".  This will only be invoke when an unexpected cancellation by the broker.  That would also mean I would have to reconsume from the other node by creating another connection/channel.  I assume this does not get invoke during a restart of the broker or a force close connection.  That would only apply to the two that I mentioned, right?

Not “unexpected cancellation” but when the queue is deleted.

MK

Software Engineer, Pivotal/RabbitMQ




More information about the rabbitmq-discuss mailing list