AMQP · Study deck

AMQP Core: Routing and Message Lifecycle

AMQP adds a smart sorting desk between senders and receivers.

Broker Bex is your guide for this deck.

fundcoreconcepts
Amqp Routing Lifecycle cover: Broker Bex guiding messages through exchange, queue, acknowledgement, and retry lifecycle objects.
iotclass.org

After studying this chapter

Learning objectives

Follow matching, storage, delivery, and completion as separate responsibilities.

  • Exchanges route messages, queues buffer them, and consumers perform the work.The warehouse alert passes through a routing decision and a waiting line before a worker handles the task.
  • Each exchange type uses different routing evidence.A direct exchange uses an exact key, topic uses wildcard patterns, fanout broadcasts, and headers checks message attributes.
  • Broker acceptance and completed work require separate evidence.A safely queued warehouse alert still needs a record showing whether the worker finished the requested task.
  • Failure consequences are part of the messaging decision.The chapter’s light readings every 5 minutes can tolerate possible loss, while a fire alarm needs a different delivery choice.

I am following a warehouse alert from its sender to the worker who handles the task. I want evidence at each handoff, including a record that the real work finished.

iotclass.org

Major section

In 60 Seconds

A warehouse alert travels through a routing decision before a worker handles the task.

  • The publisher names the event before the broker selects destinations.A warehouse sender describes an alert for the cold-store or loading team without naming every receiving worker.
  • Exchange bindings select the queues that receive an alert.An exact match, a broad pattern, a broadcast, or message details can produce different waiting lines.
  • A queue holds the alert until a consumer handles the work.The waiting line separates message storage from the moment a warehouse worker becomes ready to take the task.
  • Completion evidence records the result after delivery.The warehouse needs proof that the task finished, because a receipt alone only establishes an earlier step.

I have a warehouse alert that belongs with either the cold-store team or the loading team. I follow the sorting decision, the waiting line, and the worker’s result as three different parts of the journey.

iotclass.org

Major section

Routing tests and completion evidence

Test the routing rule and the resulting work independently.

  • Routing rules can produce different destination sets.An exact binding selects a matching key, while a fanout exchange copies the alert to every bound queue.
  • Message attributes can select relevant queues.Priority can select an alert path, format a parser, and region a processing boundary without relying on routing-key words.
  • Restarts and repeated alerts test the delivery design.Sending the same warehouse alert twice or failing a worker reveals whether the path handles uncertain outcomes.
  • Stored messages do not prove completed warehouse tasks.A restart test needs separate records for receipt and the real work, so the review can locate a failure.

I send the warehouse alert again and make one worker fail. I then compare the receipt record with the task result, because the routing test and the completion test answer different questions.

iotclass.org

Activity 1 · Draw it

✎ Trace the warehouse alert

I want you to separate the message path from the proof that work finished.

On paper, draw publisher, exchange, queue, and consumer in order. Label the routing decision and waiting place. Add the evidence needed after the worker handles the alert.

3 minutes · Pen and paper · Answer: Activity 1

Your answer
iotclass.org

Major section

Alternative View: Exchange Types Comparison

This comparison shows routing rules; start with direct matching, then compare topic, fanout, and headers.

  • The direct column matches an exact routing key.An error event reaches the Error Log Queue, while the info binding receives no copy because its key differs.
  • The topic column matches patterns across routing-key words.The sensor.temp.line1 event matches both sensor.temp.# and sensor.#, creating copies for the temperature dashboard and data lake.
  • The fanout column copies messages to every bound queue.A firmware announcement reaches gateway, audit, and cache queues independently, adding storage and delivery work for each binding.
  • The headers column selects destinations using message attributes.The chapter pairs high priority with the Alert Queue, JSON format with the Parser Queue, and EU region with EU processing.
AMQP exchange type comparison showing direct exact routing, fanout broadcast, topic wildcard routing, and headers attribute matching with a comparison table.
AMQP exchange type comparison showing direct exact routing, fanout broadcast, topic wildcard routing, and headers attribute matching with a comparison table.
iotclass.org

Major section

The Three Delivery Promises

Delivery promises trade possible loss, repeated delivery, and coordination overhead.

  • The no-acknowledgement path can lose messages.At-most-once suits the chapter’s routine light readings every 5 minutes because the example accepts possible loss to reduce overhead.
  • Acknowledged retries can deliver another copy.At-least-once keeps trying when receipt is uncertain, so a worker may encounter the same alert again.
  • Coordinated processing adds exchanges and state.The chapter’s bank-transfer analogy uses extra receipts and transactions to explain why controlling repeated effects costs more effort.
  • The event determines the acceptable delivery tradeoff.The fire-alarm example chooses at-least-once, while routine light readings accept a lighter path with possible loss.

I am weighing a light reading every 5 minutes against a fire alarm. I use the chapter’s battery discussion to connect possible loss, repeated delivery, and extra confirmations to the choice of delivery promise.

iotclass.org

Major section

Energy, retries, and failed deliveries

Match the delivery promise to the event and its failure cost.

  • Light readings and fire alarms need different delivery choices.The chapter contrasts routine readings every 5 minutes with an alarm whose loss has a different consequence.
  • Extra confirmations can consume energy and broker resources.The battery character shows how stronger delivery promises need additional back-and-forth messages, confirmations, and transactions.
  • Retries require a plan for repeated alerts.When receipt remains uncertain, another delivery can reach the worker, so handling must account for a repeated task.
  • Dead-letter handling requires explicit configuration.Queue limits and dead-letter exchanges belong in the failure design rather than a blanket promise that every message survives.

I am reviewing the fire-alarm path with the worker who receives alerts. I need the retry and dead-letter rules to be explicit before a failed delivery turns into an unexplained gap.

iotclass.org

Major section

The Four Exchange Types

This direct-exchange diagram follows an error event; compare its key with both queue bindings.

  • The publisher supplies the error routing key.The log event enters the direct exchange with a key that can be compared against both visible queue bindings.
  • The exchange compares the key with error and info bindings.Exact matching determines the destination; the event does not become an information message merely because another queue exists.
  • The matching error binding delivers to the Error Log Queue.The error key equals that binding, so the diagram’s matching path carries a copy toward the error destination.
  • The Info Log Queue receives no copy.Its info binding differs from the published error key, making the absent delivery part of the routing evidence.
Direct exchange routing for an AMQP log event with routing key error.
Direct exchange routing for an AMQP log event with routing key error.
iotclass.org

Major section

Topic patterns, broadcasts, and attributes

Evaluate each binding independently before counting the queue copies.

  • One temperature event matches two topic patterns.The sensor.temp.line1 key matches sensor.temp.# for Temp Dashboard and sensor.# for Data Lake, producing two queue copies.
  • The vibration binding rejects that temperature event.The sensor.vibration.# pattern does not match sensor.temp.line1, so the Vibration Queue receives no copy from that binding.
  • Fanout gives every bound queue an independent copy.A firmware update reaches gateway, audit, and cache queues without consulting the routing key, multiplying storage and delivery work.
  • Headers exchanges use attributes instead of routing-key words.High priority selects the Alert Queue, JSON format selects the Parser Queue, and EU region selects the EU Processing Queue.

I publish sensor.temp.line1 and follow each binding separately. I expect the temperature dashboard and data lake to receive copies, while the vibration queue gives me a useful non-match to check.

iotclass.org

Deck summary

Key takeaways

Reliable routing connects destination rules with evidence of completed work.

  • Exchanges select destinations while queues hold work for consumers.The warehouse alert needs both matching and buffering before a worker can complete the requested task.
  • Matching bindings can create several queue copies.The sensor.temp.line1 example reaches the temperature dashboard and data lake but does not match the vibration binding.
  • Acknowledgement and retry require care with repeated messages.An uncertain receipt can trigger another delivery, so the warehouse worker’s handling must account for the repeated alert.
  • Application completion needs evidence beyond broker acceptance.The warehouse test separately checks which record proves receipt and which record proves that the real task finished.

I return to the warehouse alert with the routing records and the worker’s result. I can explain which queue received the message and whether the requested task actually finished.

iotclass.org

Retrieval practice

Recall check

Broker Bex says: answer from memory, then check your reasoning.

Q1A smart-city platform needs to send a firmware update notification to every device in the fleet simultaneously, regardless of device type or location. Which AMQP exchange type should the platform use?

ADirect exchange with a routing key per device type
BFanout exchange that delivers to all bound queues
CTopic exchange with a catch-all pattern #
DHeaders exchange filtering on a firmware-update header
Show answer

Answer: B Fanout exchange broadcasts every incoming message to all bound queues, ignoring the routing key entirely.

iotclass.org

Print reference

Answers

Answer key.

  1. B · Fanout exchange broadcasts every incoming message to all bound queues, ignoring the routing key entirely.
iotclass.org

Print reference

Activity 1 answer

Model answer.

Draw it: The publisher sends to an exchange, bindings select a queue, and a consumer takes the queued message. The exchange owns matching and the queue owns buffering. Consumer completion evidence must establish the task result separately from message storage.

iotclass.org