# Message Queue

> A line where messages wait for a free worker.

**Field:** Software Development  
**Category:** Architecture  
**Also known as:** Queue, Job Queue, Task Queue, Message Broker

## Think of it like

Think of it like a line at a bakery. Each order waits its turn for a free baker.

## Definition

A message queue holds messages until a worker is ready for them. They come from one part of a system and go to another. The sender, or producer, drops a message in and moves on. A worker, or consumer, takes messages out one at a time and does the work. Each message is usually handled by just one worker. If workers are busy or down, messages wait safely in the queue.

## Example

Jack's site lets people upload videos. Each upload adds a message to a queue. Four workers take messages out and convert the videos, while the site stays fast.

## Why it matters

Slow jobs move out of the web request, so users are not kept waiting. Spikes of traffic just make the line longer.

## Common mistake

Assuming each message is handled exactly once. Most queues may deliver one twice, so the work must be safe to repeat.

## Three principles

- **Producer drops it in.** And moves on.
- **One worker takes it.** When it is free.
- **Waits safely.** Through spikes and outages.

## Related terms

- [Publish-Subscribe (Pub/Sub)](https://learn.benibix.com/term/development/publish-subscribe)
- [Event-Driven Architecture](https://learn.benibix.com/term/development/event-driven-architecture)
- [Microservices](https://learn.benibix.com/term/development/microservices)
- [Event Bus](https://learn.benibix.com/term/development/event-bus)
- [Dead Letter Queue (DLQ)](https://learn.benibix.com/term/development/dead-letter-queue)
- [Background Job](https://learn.benibix.com/term/development/background-job)

## Told apart from

- [Message Queue vs Pub/Sub](https://learn.benibix.com/compare/message-queue-vs-pub-sub): A message queue and pub/sub both pass messages between parts of a system, but they hand them out in two different ways. In a queue, each message goes to just one worker. So a job is done once. In pub/sub, every subscriber gets its own copy. So one event can start many jobs. Use a queue for work and pub/sub for news.
- [Event Streaming vs Message Queue](https://learn.benibix.com/compare/event-streaming-vs-message-queue): People think event streaming is just a message queue. A queue hands each message to one reader and then removes it. A stream keeps every event for a set time. Many readers can each read all of it, at their own pace, and read it again later.

---

Source: https://learn.benibix.com/term/development/message-queue
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
