RabbitMQ Cluster does not elect new master
I have set up a RabbitMQ cluster with 3 nodes: rabbit1, rabbit2 and rabbit3, each of these is running in a docker container.
All queues are mirrored among the three nodes and rabbit1 is the master. When I stop the container for rabbit2 or rabbit3 the two remaining nodes work fine. If I have, say, 3 messages in a queue these still exist on rabbit1 and the other node that is still up.
However, if I stop rabbit1, the queues of rabbit2 and rabbit3 are emptied until i start rabbit1 again. If I send a message to rabbit2 or rabbit3, the message is received but not saved into the queue; whereas when rabbit1 is up and I send something to rabbit2 / rabbit3, the message gets saved and is synchronized correctly.
Is there any way or any configuration that I need to consider so that the message aren’t emptied from the slaves when the master is shut down, but the slaves elect a new master instead or at least keep the messages saved?
Thank you very much in advance.
2 Solutions collect form web for “RabbitMQ Cluster does not elect new master”
Setting up the cluster is one thing, but you also need to configure queue mirroring. By default, queues are not replicated on other nodes: you need to explicitly indicate which queue(s) must be replicated and how, using policies.
The RabbitMQ documentation linked above as examples for several use cases.
So I’ve found the problem:
I declare the queue within my code, and even though rabbitmq does “count” these queues they do not appear under the management and for example can neither be viewed with “rabbitmqctl list_queues”.
If I declare the queue via the UI or via rabbitmqadmin and let the service connect to the already existing queue it works fine.
I wonder though, why the queues to not appear in the management tool, even though they obviously exist somewhere (since I can read / push).