Services do not call each other directly: the sender puts a message on the broker and immediately carries on, while the receiver picks it up whenever it is ready. The broker decouples the parts of the system in time and speed — one service failing does not stop the others, and a traffic spike is absorbed by the queue.
What the broker does
- Accepts messages from producers and stores them until they are delivered.
- Routes them: by queue name, topic or routing rules.
- Hands messages to consumers — each takes one when ready.
- Waits for an acknowledgement (ack) and redelivers if none arrives.
- Moves “poison” messages to a separate dead-letter queue.
Queue and log
Two approaches to storing messages. A classic queue: a message goes to the first free worker and is deleted once acknowledged — that is how RabbitMQ works. A log: messages are appended to the end, read by offset and kept until the retention period expires — that is how Kafka and Redis streams (Stream) work. You can re-read a log, several times over and from any position, and a group of workers splits the log’s partitions between them.
| Property | Queue | Log |
|---|---|---|
| Where it lands | into a named queue | into a topic partition, appended to the end |
| After delivery | deleted once acknowledged | kept until the retention period ends |
| Who receives it | each message goes to one worker | a group shares partitions, subscribers read everything |
| Re-read | no | yes, from any offset |
Types of brokers
- RabbitMQ — AMQP 0-9-1 exchanges and bindings: direct, fanout, topic, headers.
- Kafka — a distributed log with partitions and replication, streaming of large flows.
- NATS — a lightweight broker with
pub/sub,request/replyand JetStream streams. - Cloud services: Amazon SQS, Google Cloud Pub/Sub, Azure Service Bus.
Example
After an order, an online shop publishes order.created. Three workers read it independently: one reserves stock, another takes the payment, the third sends an email. If payment fails, the broker returns the message and retries a minute later; if the mail server is down, the emails go out once it is back up. A Black Friday spike piles up in the queue, and the workers clear it at their own pace.
Sources
the term is written from these pages- OASIS — AMQP 1.0, Part 0: Overviewdocs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html(opens in a new tab)
- RabbitMQ — AMQP 0-9-1 model: брокеры, обменники, очереди и подтвержденияrabbitmq.com/tutorials/amqp-concepts(opens in a new tab)
- Apache Kafka — Introductionkafka.apache.org/intro(opens in a new tab)
Verified 8 Nov