Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically reconnect RabbitMQ channels

Tags:

java

rabbitmq

I found this gem:

In the event of a connection failure, the client will need to establish a new connection to the broker. Any channels opened on the previous connection will have been automatically closed and these will need re-opening too.

So that's not good. I'm about to go write a big layer of handling automatic reconnects and recreating the channels then encapsulate this happening from all of my code. Problem is, this should be done already. Is this possible in the Java RMQ libraries?

like image 365
djechlin Avatar asked Mar 09 '13 21:03

djechlin


2 Answers

Perhaps this is a new feature of the RabbitMQ client, but I found this in their docs:

To enable automatic connection recovery, use factory.setAutomaticRecoveryEnabled(true):

https://www.rabbitmq.com/api-guide.html

Looks like it should solve the problem.

like image 66
falconizer Avatar answered Sep 28 '22 10:09

falconizer


Check out Lyra: A high availability RabbitMQ client that automatically recovers resources (connections/channels/consumers) when they're closed unexpectedly.

like image 43
Jonathan Avatar answered Sep 28 '22 10:09

Jonathan