rabbitmqamqphigh-availabilityround-robinnode-amqp

Why Rabbitmq cluster delivers messages to consumers in a Round-Robin fashion


I have 2 Rabbitmq nodes connected as a cluster (no queue replication), and have 4 workers, all are bound to the same queue "myqueue", now, I manually publish messages to that queue (the publisher can be connected to any of rabbit nodes .. doesn't affect the result).

Now, this happens: Each time I publish a message to that queue, I find the messages delivered to the workers/consumers in a Round-Robin fashion, no matter what to which node the consumers or the publisher are connected, I always get the same result.

I have been told that this is the effect of Rabbitmq's "prefetch_count", but I don't understand how is that, or even i don't know if that's the right answer.


Solution

  • I think rabbitmq is behaving correctly. When workers are listening to queue, rabbitmq delivers message to consumers in round robin fashion.

    Ref: http://www.rabbitmq.com/tutorials/tutorial-two-python.html

    By default, RabbitMQ will send each message to the next consumer, in sequence. On average every consumer will get the same number of messages. This way of distributing messages is called round-robin. Try this out with three or more workers.