Now that we have seen how to establish high availability at the level of the broker along with some mechanisms to improve reliability when publishing/consuming messages, we have to explore what mechanisms we have to ensure client reliability in the event of broker failures.
Later versions of the RabbitMQ Java client provide a mechanism for handling automatic recovery in the event of connection failures with the broker. In earlier versions of the client this has to be done manually or with the help of a wrapper library that provides recovery on top of an existing RabbitMQ client (there are various implementations in the public space). Recovery via the Java client API is enabled with a single line of code:
The preceding method invoked on a RabbitMQ connection factory does a number of things in the context of a publisher/consumer connection, such as reopening channels, recovering consumers, restoring connection...