AMQP · Study deck

AMQP Reliability: Persistence and Routing Patterns

The dangerous AMQP mistakes are often quiet.

Broker Bex is your guide for this deck.

implmisconceptions
Broker Bex, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Diagnose Common AMQP Pitfalls: Analyze the top 5 implementation mistakes that cause data loss and system failures, and explain why each leads to production incidents
  • Configure Message Persistence Correctly: Justify why both durable queues AND persistent messages (delivery_mode=2) are required for reliability, and implement both settings together
  • Apply Wildcard Patterns Accurately: Distinguish between * (exactly one word) and # (zero or more words) in topic exchanges, and select the correct wildcard for variable-depth routing hierarchies
  • Select AMQP vs MQTT Appropriately: Compare protocol overhead metrics (bandwidth, RTT, memory, battery) and justify protocol selection decisions based on quantified device constraints
iotclass.org

Major section

In 60 Seconds

A protocol is an agreed set of exchange rules.

  • Advanced message queuing protocol (AMQP) is used to exchange messages through named services and rules.
  • A broker is a service that accepts messages and routes or stores them for receivers.
  • The sender may have retried after a lost reply.
  • The service may have redelivered after a worker stopped.

Key terms

Each misconception
Each misconception is documented with quantified impact from real deployments.
iotclass.org

Major section

In 60 Seconds (continued)

Neither event proves that the system is broken; the unsafe part is acting twice without a clear rule.

  • One passed path cannot prove exactly-once business action or endless storage.
  • It proves the stated exchange under stated limits.
  • The deeper sections examine the common myths and show which mechanism, record, and application rule can support a narrower claim.
iotclass.org

Major section

The "It Should Work" Trap

"I set my queue to durable, so my messages will survive a server restart, right?" Sammy the Sensor said confidently.

  • My light readings vanished when the server rebooted." Max nodded. "Another common one: people think more consumers always means faster processing.
iotclass.org

Major section

The Pitfall

For constrained devices (battery, bandwidth), MQTT is often superior.

  • In this 10,000-message example, the protocol-overhead row uses 2 bytes for MQTT and 8–20 bytes for AMQP, so MQTT carries less framing.
  • The resulting totals are 2.02 MB and 2.18 MB respectively, again favoring MQTT for this payload mix.

Numbers to remember

2 bytesthe protocol-overhead row uses 2 bytes for MQTT
8–20 bytes8–20 bytes for AMQP, so MQTT carries less framing.

Why it matters

What developers believe: AMQP should be used for all IoT deployments because "enterprise-grade" means "always better.".

iotclass.org

Major section

Try It: Duplicate Message Simulator

Adjust the number of commands, glitch probability, and see how idempotency keys prevent dangerous duplicate executions in a chemical tank filling scenario.

  • Simulate what happens when network glitches cause message redelivery.
iotclass.org

Deck summary

Key takeaways

A protocol is an agreed set of exchange rules.

  • Neither event proves that the system is broken; the unsafe part is acting twice without a clear rule.
  • "I set my queue to durable, so my messages will survive a server restart, right?" Sammy the Sensor said confidently.
  • For constrained devices (battery, bandwidth), MQTT is often superior.
  • Adjust the number of commands, glitch probability, and see how idempotency keys prevent dangerous duplicate executions in a chemical tank filling scenario.
iotclass.org

Retrieval practice

Recall check 1 of 4

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

Q1Per this chapter's persistence truth table, what happens to a queue declared with durable=True but messages published with delivery_mode=1 (transient), after a broker restart?

AThe queue definition survives and exists, but it is empty -- the messages themselves are gone
BBoth the queue and its messages are completely gone
CThe queue is gone, but the messages persist independently and can be recovered
DBoth the queue and its messages survive intact, identical to durable=True + delivery_mode=2
Show answer

Answer: A see answers page

iotclass.org

Retrieval practice

Recall check 2 of 4

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

Q2Per this chapter's Misconception 2 impact data, what happened to a smart building system that used sensor.temperature.* instead of sensor.temperature.#?

AIt missed all multi-zone sensor data across more than 5,000 sensors for 3 months
BIt received duplicate readings from every zone-level sensor for 3 months
CIt crashed the broker due to a routing key length overflow
DIt correctly matched all sensors, but with a 3-month reporting delay
Show answer

Answer: A

iotclass.org

Retrieval practice

Recall check 3 of 4

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

Q3A payment processing consumer uses auto_ack=True and processes each message in 20ms on average. The consumer crashes while processing message #50 out of 200 total messages. How many messages are permanently lost?

A0 messages - the broker redelivers all unprocessed messages after the consumer reconnects
B1 message - message #50 was ACK'd before processing completed
C150 messages - all messages from #50 to #200 are lost
D50 messages - all messages that were processed are lost on crash
Show answer

Answer: B With auto_ack, the broker removes a message from the queue the instant it delivers it - before the consumer processes it.

iotclass.org

Retrieval practice

Recall check 4 of 4

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

Q4Per this chapter's chemical-tank duplicate scenario, why does the command execute twice (tank fills by 200ml instead of the intended 100ml) even though the first execution succeeded?

AThe ACK for the first execution is lost to a network glitch, so the broker times out and redelivers the command as if it had never been processed
BThe command itself was corrupted in transit, so the broker automatically resends a fresh copy
CThe consumer explicitly requests a retry because the tank level sensor reported an error
DAMQP always executes every command exactly twice by default as a safety margin
Show answer

Answer: A This is the chapter's concrete illustration of at-least-once delivery's redelivery mechanism: the broker only knows a message is 'done' when it receives an ACK.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. A · The chapter's four-row truth table shows durable=True, delivery_mode=1 as the 'TRAP' configuration (per the Try It tool's label): the queue definition exists after restart, but every transient message it held is gone, so the queue simply comes back empty.
  2. A
  3. B · With auto_ack, the broker removes a message from the queue the instant it delivers it - before the consumer processes it.
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. A · This is the chapter's concrete illustration of at-least-once delivery's redelivery mechanism: the broker only knows a message is 'done' when it receives an ACK.
iotclass.org