# RabbitMQ

> Route messages between services with exchanges, queues and acknowledgements in the classic message broker. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/backend/rabbitmq
Last updated: 2026-11-28

Route messages between services with exchanges, queues and acknowledgements in the classic message broker.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [Messaging Patterns and Delivery Guarantees](https://www.internhack.in/roadmaps/tracks/backend/messaging-fundamentals)

**RabbitMQ** is a mature, general-purpose message broker implementing AMQP 0-9-1. It shines at task distribution and flexible routing between services, and it is easy to run locally.

### The routing model

Producers never publish directly to queues. They publish to an **exchange**, which routes messages to **queues** based on **bindings**:

- **Direct** exchanges route by exact routing key (`email.send`).
- **Topic** exchanges route by pattern (`order.*.created`, `order.#`).
- **Fanout** exchanges copy every message to all bound queues (pub/sub).
- **Headers** exchanges route by message headers (rare).

Consumers subscribe to queues. Several consumers on one queue share the work.

### Reliability settings

- **Durable queues** and **persistent messages** survive broker restarts.
- **Manual acknowledgements**: the consumer acks only after finishing; unacked messages are redelivered if it dies.
- **Prefetch (QoS)** limits how many unacked messages each consumer holds, balancing load fairly.
- **Publisher confirms** tell the producer the broker safely stored the message.
- **Dead-letter exchanges** catch rejected or expired messages.
- **Quorum queues** replicate data across a cluster for high availability and are the modern default over classic mirrored queues.

### When to pick RabbitMQ

Work queues, request/reply, complex routing and moderate throughput where each message is consumed and removed. For replayable, very high-volume event streams, Kafka fits better. RabbitMQ also offers **Streams** for log-style use cases.

### Pitfalls

- Auto-ack mode silently losing messages when a consumer crashes.
- Unbounded queues growing because consumers are down, until memory alarms block publishers.

You are ready to move on when you can set up a topic exchange feeding two queues, process messages with manual acks and prefetch, and route failures to a dead-letter queue.

## Key concepts

- **Exchanges, queues and bindings**
- **Direct, topic and fanout exchanges**
- **Manual acks and prefetch**
- **Durability and publisher confirms**
- **Dead-letter exchanges**
- **Quorum queues**
- **Management UI and monitoring**

## Mini project

Run RabbitMQ in Docker and build an order pipeline: the API publishes order events to a topic exchange, separate email and inventory consumers process them with manual acks, and failures land in a dead-letter queue.

## Check yourself

What is the difference between a fanout and a topic exchange, and when would you use each?

## Free resources

- [RabbitMQ tutorials](https://www.rabbitmq.com/tutorials) (RabbitMQ)
- [RabbitMQ documentation](https://www.rabbitmq.com/docs) (RabbitMQ)

Previous: [Messaging Patterns and Delivery Guarantees](https://www.internhack.in/roadmaps/tracks/backend/messaging-fundamentals) · Next: [Event Streaming with Apache Kafka](https://www.internhack.in/roadmaps/tracks/backend/kafka)

## More in Background Jobs and Message Brokers

- [Background Jobs and Task Queues](https://www.internhack.in/roadmaps/tracks/backend/background-jobs)
- [Messaging Patterns and Delivery Guarantees](https://www.internhack.in/roadmaps/tracks/backend/messaging-fundamentals)
- [RabbitMQ](https://www.internhack.in/roadmaps/tracks/backend/rabbitmq)
- [Event Streaming with Apache Kafka](https://www.internhack.in/roadmaps/tracks/backend/kafka)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Backend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/backend)
