Publish/subscribe
The previous pattern has workers that handle specific topics of messages, and the messages consumed by a worker are completely gone from the queue. We even added code to acknowledge that the message was consumed.
When you want a message to be published to several workers, the Publish/Subscribe (pubsub) pattern needs to be used.
This pattern is the basis for building a general event system and is implemented exactly like the previous one where there is one exchange and several queues. The difference is that the exchange part has a fanout ;type.
In that setup, every queue that you bind to a fanout exchange will receive the same message.
With a pubsub in place, you can broadcast messages to all your microservices if you need ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access