rabbitmq / rabbitmq-stomp

RabbitMQ STOMP plugin
https://www.rabbitmq.com/stomp.html
Other
49 stars 28 forks source link

Only one subscriber receives message from destination starting '/topic/' #108

Closed zxkane closed 7 years ago

zxkane commented 7 years ago

According to the doc of stomp, the message with destination from /topic/ will be delivered to all active subscribers.

Topic Destinations

For simple topic destinations which deliver a copy of each message to all active subscribers, destinations of the form /topic/ can be used. Topic destinations support all the routing patterns of AMQP topic exchanges.

Messages sent to a topic destination that has no active subscribers are simply discarded.

But the behavior in my application is NOT consistent with above declaration.

I have an app that uses spring-websocket over stomp protocol, and uses RabbitMQ(3.6.6) with stomp as full feature broker.

Once the app receives a message from user, it will send the message to destination /topic/<route-key>. In my test scenario I opened two browers to open the same page. There are two clients to subscribe the same /topic/<route-key>. After the server side app sends the message to destination /topic/<route-key>, only one client receives the message. If more messages are sent by my app, the two clients will rotate to receive messages.

If using SimpleBroker of spring-websocket which is a memory broker implementation instead of RabbitMQ, both of two clients can receive the same message.

Is there any misunderstanding of stomp specification? If not, how I can debug this problem in RabbitMQ? If you need more information please let me know.

acogoluegnes commented 7 years ago

Please post questions to rabbitmq-users or Stack Overflow. RabbitMQ uses GitHub issues for specific actionable items engineers can work on, not questions. Thank you.

acogoluegnes commented 7 years ago

Your understanding is correct. With the 2 clients listening on the same topic, you should see 2 queues in the management UI, bound with the routing key to the amq.topic exchange. Each queues should receive a copy of the message. Please post your question on rabbitmq-users with versions and code samples, it'll help digging further.

michaelklishin commented 7 years ago

We will update the language on that page but it's not really a good idea to describe topic routing (in STOMP or any other protocol) as "delivers a copy of each message to all active subscribers". That's a pretty precise definition of fanouting, not topic-based routing.