RabbitMQ connection automatic recovery

I’m a little confused about the automatic recovery of the connections in RabbitMQ java client.

Consider the following code

ConnectionFactory factory;
factory.setAutomaticRecoveryEnabled(true);
Connection connection = factory.newConnection();
Channel chan_obj = conn.createChannel();

As per RabbitMQ documentation, if connection drops, then automatically recovery will re-create the connection, re-create the channel etc. I’m really confused about what to do with the ‘chan_obj’ while RabbitMQ automatically recovers. I’m curious if the ‘channel’ created from the connection after the recovery will be usable with the object ‘chan_obj’ Another question is during the recovery process, will I get any notification that channel has closed and hopefully followed by another notification like ‘channel can be used again’.

Answer

To cite the documentation

Create a new channel, using an internally allocated
channel number. If automatic connection recovery is
enabled, the channel returned by this method will
be Recoverable.

See also AutorecoveringConnection and AutorecoveringChannel.

Leave a Reply

Your email address will not be published. Required fields are marked *