Skip to content
Ameen Abozaid
MID-027

RabbitMQ

  • 6 Lessons
  • 2.5 h practice (estimate)
On this page 8 topics

Overview

Topics

  • Exchanges
  • routing
  • acknowledgments
  • dead-letter queues

Learn first

2.5 h of practice (estimate)

Learning outcomes

  1. Explain exchanges (direct, topic, fanout), bindings, and queues.
  2. Publish and consume with Spring AMQP using manual acknowledgments.
  3. Configure dead-letter exchanges and retry with delay.
  4. Decide between RabbitMQ and Kafka for a workload.

Lessons

  1. 01RabbitMQ's model
  2. 02Exchanges and routing
  3. 03Acknowledgments and prefetch
  4. 04Dead-letter queues and delayed retry
  5. 05RabbitMQ or Kafka?
  6. 06Demo: notification routing with a topic exchange

Lab and exercises

Lab

MID-027-LAB1 · Notifications

Outcomes: 1–4 · Time: ~2.5 h

  1. Build a notification service with Spring AMQP, consuming email and sms queues bound to a topic exchange with routing keys.
  2. Use manual acknowledgments and a prefetch limit.
  3. Add a TTL retry queue (3 attempts) and a final dead-letter queue.
  4. 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)

IDOutcomeTask
MID-027-EX011Write the routing key patterns so one queue gets all order.* events and another only order.cancelled.
MID-027-EX021Name the exchange type for: exact routing, pattern routing, broadcast.
MID-027-EX032Convert an auto-ack listener to manual ack and explain the failure it removes.
MID-027-EX043Declare a queue with a dead-letter exchange and a 10-second delayed retry back to the main queue.
MID-027-EX054Scenario: 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 and order.cancelled to the second (exact keys also match topic patterns).
  • EX02 Direct, topic, fanout.
  • EX03 Set manual acknowledge mode; basicAck after success, basicNack(tag, false, false) on failure. Removes loss of unprocessed messages on a crash.
  • EX04 QueueBuilder.durable("main").deadLetterExchange("dlx"); a retry queue with x-message-ttl=10000 and x-dead-letter-exchange pointing 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.

  1. 1Producers in RabbitMQ publish to:O1
  2. 2Which exchange copies a message to every bound queue?O1
  3. 3In a topic exchange * matches:O1
  4. 4With auto-ack, a consumer crash during processing:O2
  5. 5With manual acks, when should you ack?O2
  6. 6Prefetch limits:O2
  7. 7A message is dead-lettered when it:O3
  8. 8Delayed retry without a plugin is commonly built with:O3
  9. 9Infinite redelivery of a poison message is stopped by:O3
  10. 10Which need most favors Kafka over RabbitMQ?O4

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).

Type to search levels, phases, modules and lessons.