RabbitMQ
On this page 8 topics
Overview
Topics
- Exchanges
- routing
- acknowledgments
- dead-letter queues
Learn first
2.5 h of practice (estimate)
Learning outcomes
- Explain exchanges (direct, topic, fanout), bindings, and queues.
- Publish and consume with Spring AMQP using manual acknowledgments.
- Configure dead-letter exchanges and retry with delay.
- Decide between RabbitMQ and Kafka for a workload.
Lessons
Lab and exercises
Lab
MID-027-LAB1 · Notifications
Outcomes: 1–4 · Time: ~2.5 h
- Build a notification service with Spring AMQP, consuming
emailandsmsqueues bound to a topic exchange with routing keys. - Use manual acknowledgments and a prefetch limit.
- Add a TTL retry queue (3 attempts) and a final dead-letter queue.
- Send a poison message and normal messages together.
Acceptance: a poison message ends in the DLQ without blocking others.
Exercises (assessment: lab plus tool-choice scenario; five exercises)
| ID | Outcome | Task |
|---|---|---|
| MID-027-EX01 | 1 | Write the routing key patterns so one queue gets all order.* events and another only order.cancelled. |
| MID-027-EX02 | 1 | Name the exchange type for: exact routing, pattern routing, broadcast. |
| MID-027-EX03 | 2 | Convert an auto-ack listener to manual ack and explain the failure it removes. |
| MID-027-EX04 | 3 | Declare a queue with a dead-letter exchange and a 10-second delayed retry back to the main queue. |
| MID-027-EX05 | 4 | Scenario: a 20 TB event history must be replayable by new services; another need is delayed email jobs. Pick a broker for each. |
Show solutions
- EX01 Bind
order.*to the first queue andorder.cancelledto the second (exact keys also match topic patterns). - EX02 Direct, topic, fanout.
- EX03 Set manual acknowledge mode;
basicAckafter success,basicNack(tag, false, false)on failure. Removes loss of unprocessed messages on a crash. - EX04
QueueBuilder.durable("main").deadLetterExchange("dlx"); a retry queue withx-message-ttl=10000andx-dead-letter-exchangepointing to the main exchange. - EX05 Replayable history: Kafka. Delayed jobs: RabbitMQ with TTL and DLX (or plugin).
- Outcome 2 is also exercised by the lab (manual acks, prefetch).
Quiz
Outcomes: O1 exchanges and bindings · O2 Spring AMQP and acks · O3 DLX and retry · O4 RabbitMQ vs Kafka.
A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.
Practical part
Five exercises MID-027-EX01 to EX05 plus the lab. Pass: at least four exercises correct and the lab's poison message landing in the DLQ while normal messages are still processed.
Common mistakes
Auto-ack; infinite redelivery loops.
Assessment
Lab plus tool-choice scenario.
Career relevance
Enterprise integration (ARC-009).