Consider first a couple of points.
First, remember that in RabbitMQ you always consume from queues. Exchange is just your portals, and you cannot directly consume them.
Secondly, Volume Sharing allows you to bind queues using routing โpatternsโ. Therefore, the term topic is valid in the context of Tag Exchange.
Now this is what I understand from your question:
Multiple consumers / one routing key : Here you want all consumers to consume all messages with the same routing key (or the same routing key patterns in case of tag exchange). It really is doable. Just do the following:
- Declaring Your Exchange Theme
- Declare a queue with a name
- Bind this queue to your topic using the desired routing key template.
- Create multiple users and ask them to listen to the same queue.
What will happen is that RabbitMQ will load balance to your consumers in a circle. This means that all consumers will consume from the same queue. But remember that in this scenario it is possible that one message is transmitted more than once in theory.
What you did was create multiple queues and have one user in the queue. This means that each message arriving at the exchange will be duplicated in all queues. The end result will be that the message is processed several times.
Amin j
source share