Video in progress
What is the logical difference between sending to a topic and to a queue in STOMP?
By convention, /topic is broadcast: one message goes to all subscribers. /queue is point-to-point: the message is for a single recipient, usually sent to a specific user as /user/queue/....
📖 Answer
Example: an online auction.
- Everyone must see the new price of a lot →
/topic/auction/15. - "Your bid was rejected, insufficient balance" goes to one person only →
/user/queue/errors.
For Spring's simple broker these names are just prefixes. It treats both the same way and sends to everyone subscribed. The real difference shows up with an external broker: in RabbitMQ's STOMP plugin, /topic/... is distributed to every subscriber through an exchange, while /queue/... is a queue, and if there are several consumers each message reaches only one of them.
So it's better to get the naming right from the start. Then when you move from the simple broker to RabbitMQ later, the behavior doesn't change unexpectedly.
Sign up to mark studied questions and save your progress.