2
votes

I connect to a cluster of rabbitmq nodes ( A, B and C) using spring-amqp. Let's say one of the rabbitmq nodes in the cluster shuts down (C shuts down). Also, assume there are two message receivers ( Receiver_1 and Receiver_2 ) which were using connections to node C. When C goes down, does Receiver_1 and Receiver_2 automatically switch their connections to connect to A or B ? And what happens when C comes up again ? Does some of the receiver connections get redistributed to use C ?

1

1 Answers

2
votes

Failover is not supported by RabbitMQ itself. When a node in a RabbitMQ cluster goes down, a new master will be elected and business will continue as usual for the rest of the cluster.

So in your example, Receiver_1 and Receiver_2 will need to handle the case where the C has gone down, and know to attempt to connect to either A or B instead.

You can see the official documentation for this here: http://www.rabbitmq.com/clustering.html#clients

Personally, I use haproxy (http://haproxy.1wt.eu/) to load balance the connections for all of my clients. haproxy will not only load balance, but it will automatically detect when a node has gone offline and reroute all the connections to another live node. With that said, it will not be seamless. The application will still become disconnected, so you will need to catch the exception and attempt to reconnect.