RabbitMQ and round robin topic exchanges

rabbitmq

I'm seeking some advise as to how best configure my rabbitMQ exchanges.

I'm trying to use a topic exchange in a round robin methodology. Each consumer has its own (uniquely) named queue attached to a topic exchange. I would like the exchange to round robin messages to each consumer queue for the "same" topic – lets say *.log for example.

I have tried multiple combinations and only seem to be able to simultaneously deliver messages to the consumer queues which effectively means I'm processing the message twice, once in each consumer.

For clarity I also have a fanout exchange, which I use to "control" the consumers (start, stop etc).this should remain in place in any outcome.

Any guidance on how best to achieve the stated outcome would be great.

Best Answer

Each consumer has its own (uniquely) named queue attached to a topic exchange

The trick is to have every worker/consumer that you want to round-robin between to setup a named queue and all use the same queue instead creating their own.

So you could create a named queue called "log" for all of the "log" workers. You would create a different named queue for say "foo" for all of the "foo" workers. Requests will be delivered round-robin to all consumers looking at the same queue.