Blog/

Messaging Queue Vs Pub/Sub

Lesson overview

Messaging Queue Vs Pub/Sub

Both are messaging patterns for decoupled services. Queues assign work to one consumer; pub/sub broadcasts the same message to many subscribers.

Message Queue vs Pub/Sub they both are messaging patterns used in decoupled service queue = assign work pub/sub = broadcast

Example - Queue focus on assigning work

Order Service

Example - PUB/SUB but focus is broadcasting

notification

Queues: In a queue-based system, messages are sent to a queue, and one or more consumers (subscribers) process messages from the queue. Messages are typically consumed in a first-in, first-out (FIFO) order. Each message is typically processed by only one consumer

Pub/Sub System: In a Pub/Sub system, messages are published to a topic, and multiple subscribers can receive those messages. Publishers and subscribers are decoupled, and subscribers express interest in specific topics. When a message is published to a topic, all interested subscribers receive a copy of the message.

Message queue vs pub/sub

Loading Messaging Queue Vs Pub/Sub