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.

  • Pass docker-compose environment to symfony configuration
  • using docker stack deploy on oracle linux 6
  • Use Docker Compose to create multiple containers
  • MongoDB & Docker: connections from Dockerized Mongo client to external server refused
  • Cannot connect docker swarm agent from outside internet
  • How to run bundle install with a Dockerfile file
  • 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.

  • Unable to read file from mounted directory in docker
  • access docker container in kubernetes
  • Get Environment Variable from Docker Container
  • Docker-compose: deploying service in multiple hosts
  • how to clear cache memory inside docker container
  • Cannot connect via PHP to docker mysql
  • 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).

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.