In the publish-subscribe messaging system, each message has multiple consumers. Topics are based on a publish subscribe messaging model where each message is broadcast to multiple subscribers who are listening to the topic.
Key feature of Publish Subscribe messaging model
- Publisher
- The publisher is the entity that sends the message to the topic.
- Subscriber
- These are the entities that receive messages from the topic.
- Topic
- It is the destination that is used to broadcast the message to all the subscribers who subscribed to it.
When to use publisher subscribe messaging model
The publish-subscribe messaging model should be used when we want our message to be broadcast to multiple subscribers simultaneously. Example: Stock price updates to multiple trading applications in real-time.