Free sample lesson · Message Queue vs Event Bus vs Message Broker

Message Queue — One Producer, One Consumer

Lesson 1 of the Wondering course Message Queue vs Event Bus vs Message Broker

What a Message Queue Does

A message queue is a mailbox between two programs.

One side, the producer, drops a message in. The other side, the consumer, picks it up later. Neither has to be online at the same moment.

A producer placing a message into a queue that one consumer pulls from

Notice the message travels one way only: in from the producer on the left, out to a single consumer on the right.

This is point-to-point async communication: one sender, one receiver, no waiting around.

The Delivery Handshake

Delivery is not just a hand-off. It follows a strict order.

The producer sends. Exactly one consumer receives. That consumer acknowledges. Only then does the queue remove the message.

How one message moves through the queue
  • Send: The producer sends a message into the queue.
  • Receive: Exactly one consumer receives that message.
  • Acknowledge: The consumer acknowledges that it handled the message.
  • Remove: The queue removes the message once acknowledged.

The acknowledgement matters. Without it, the queue assumes the work never finished.

Exactly One Consumer

This is the rule people most often get wrong.

A message in a queue goes to exactly one consumer. It is not copied out to everyone listening.

What the queue does and does not do
  • Point-to-point
  • Common misread

So if three services all need the same event, a single point-to-point queue is the wrong tool.

Competing Consumers

Now add more workers.

In the competing consumers pattern, several workers pull from the same queue. They race for whatever is waiting.

Three workers pulling from a single shared queue

Each waiting message is claimed by only one worker, so adding workers speeds the queue up without repeating any job.

Each message still gets processed only once. More workers means faster throughput, never duplicated work.

Where Queues Earn Their Keep

Three jobs come up again and again.

Background jobs move slow work out of the request path. Task distribution spreads items across a pool of workers.

Three common uses
  • Background jobs
  • Task distribution
  • Load leveling

Load leveling absorbs a traffic spike so consumers drain it at their own pace.

Why the Acknowledgement Matters

Removal is tied to the acknowledgement, not to delivery.

That single design choice is what makes a queue trustworthy when a worker crashes mid-task.

What if the acknowledgement never arrives?

Pulling It Together

A queue is a one-way, one-recipient channel.

The producer sends, exactly one consumer receives and acknowledges, and the message is removed. Add workers and they compete for the same queue without repeating work.

Queue essentials

Reach for it when work should happen later, spread out, or at a steadier pace.

Check yourself

A producer and consumer must be online at the same moment for a message queue to work.

  • True
  • False

Answer: False

False. A queue stores the producer's message so the consumer can retrieve it later; this is asynchronous communication.

Message delivery follows this sequence: the producer _____, the consumer _____, the consumer _____, and the queue _____ the message.

Answer: Message delivery follows this sequence: the producer sends, the consumer receives, the consumer acknowledges, and the queue removes the message.

The queue removes the message only after the consumer acknowledges it. This order links successful completion to removal.

Three workers pull messages from the same queue using the competing consumers pattern. What happens to a single waiting message?

  • All three workers process it independently
  • Exactly one worker processes it
  • The queue sends it to every available service
  • The message remains until all workers acknowledge it

Answer: Exactly one worker processes it

Exactly one worker processes the message. Competing consumers improve throughput by sharing the queue, but they do not duplicate each message.

Keep going

This is lesson 1 of 8 in Message Queue vs Event Bus vs Message Broker. Next up:

  1. Event Bus — One Publisher, Many Subscribers
  2. What a Broker Actually Is
  3. RabbitMQ — Flexible Routing with Exchanges
  4. Kafka as a Distributed Log, Not Just a Broker
  5. When Kafka's Log Semantics Change Everything

Start this course free

Wondering turns any topic into short lessons you can read, watch, or listen to, with practice questions and an AI tutor.