Closed laurentluce closed 7 years ago
According to what you posted, both messages have the same destination and two consumers use a single queue.
When two consumers share a queue, a case known as competing consumers, messages are distributed in the round robin manner. See tutorial two.
If you want both subscription to receive a copy, use a topic destination so that each has its own queue.
In other words, message replication happens during the routing stage, not delivery. If you want N consumers to receive something, they must each have their own queue.
@michaelklishin I don't want each subscription to receive a copy. Each subscription above uses a different pattern: topic.a.*
and topic.b.*
I do use the same queue name when i send the STOMP subscribe commands. I was expecting messages to be received based on the subscriptions topic pattern. The message with destination /exchange/app/topic.a.1
should not be received by the subscription with pattern topic.b.*
unless I am missing something.
@laurentluce see above. The feature you are asking for is known as consumer selectors. It is not available in RabbitMQ. Message distribution happens at the routing stage. I don't have anything to add to the comments above.
To be more precise, consumer selectors are implemented in the jms-topic-exchange plugin but it is JMS-specific and doesn't fit the semantics of STOMP.
@michaelklishin Thanks for clarifying. I understand now that I need to use two queues.
Messages don't seem to end up on the right subscription when I have two subscriptions using a single durable queue.
Here is my routing configuration:
rabbitmqctl list_bindings:
rabbitmqctl list_consumers:
rabbitmqctl list_queues:
Message 1 with destination topic.a.1 sent. Message received on the right subscription:
Message 2 with destination topic.a.1 sent. Message received on the wrong subscription:
Both messages should have been received on the subscription: ApMOzTQPNUlvwhmj since both messages destination match topic.a. and not topic.b.