Search code examples
rabbitmqprefetch

RabbitMQ - Will the same message be delivered to consumers on separate connections


If I have and exchange with a single queue bound to it. I have two processes each with their own connection. Each connection has its own consumer which is consuming messages from that single queue.

Is it possible that when a message is placed onto the queue, both consumers could be delivered the same message?

Pre-fetch seems to apply across consumers on a single channel, or connection if the global flag is set. What happens with consumers across multiple connections


Solution

  • No. Messages are always round-robin delivered to multiple consumers on the same queue.

    One solution is to have two queues bound to the same exchange using the same routing key if you need messages to go to both consumers.