AMQP · Study deck

AMQP Delivery: Sizing and Reliability Contracts

An AMQP message is a parcel with a label, a body, and a delivery receipt path.

Broker Bex is your guide for this deck.

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

After studying this chapter

Learning objectives

You will be able to:

  • Explain: Adding the assumed 200-byte transaction cost to every message would raise this model's bandwidth from ~197 to ~360 Kbps (about 1.8×); transactions alone would not provide exactly-once business processing.
  • Explain: Batching 10 readings into one 1,200-byte message improves efficiency from 51% to 91%, saving (10×236B)−(1,200B+116B)=1,044B(10 \times 236B) - (1,200B + 116B) = 1,044B(10×236B)−(1,200B+116B)=1,044B per 10 readings (44% reduction).
  • Explain: The two disk settings only work together: a persistent message in a transient queue is not saved, and a transient message in a durable queue is not saved either.
iotclass.org

Major section

Putting Numbers to It

For telemetry with 120-byte payloads, nearly half the bandwidth is protocol overhead.

  • Batching 10 readings into one 1,200-byte message improves efficiency from 51% to 91%, saving (10×236B)−(1,200B+116B)=1,044B(10 \times 236B) - (1,200B + 116B) = 1,044B(10×236B)−(1,200B+116B)=1,044B per 10 readings (44% reduction).
  • Conclusion: The telemetry (about 98% of messages) uses fire-and-forget, keeping broker load minimal.
  • Adding the assumed 200-byte transaction cost to every message would raise this model's bandwidth from ~197 to ~360 Kbps (about 1.8×); transactions alone would not provide exactly-once business processing.
iotclass.org

Major section

AMQP Delivery Reliability Chain Contracts

The message reaches a queue, the worker writes the incident, and then the worker crashes before it says the job is done.

  • One durable setting cannot protect a different gap in the chain.
  • The chain can notify and retain evidence, but it must not be the sole route to stop immediate harm.
  • The next worker may see the same alarm, so the team must prevent a second incident without losing the first.
  • This opening does not promise exactly-once physical action.

Why it matters

The next worker may see the same alarm, so the team must prevent a second incident without losing the first.

A dead-letter exchange is a controlled branch: retryable failures loop through a TTL queue, while messages over the retry limit move to a parking queue with their evidence intact.
A dead-letter exchange is a controlled branch: retryable failures loop through a TTL queue, while messages over the retry limit move to a parking queue with their evidence intact.
iotclass.org

Major section

AMQP Delivery Reliability Chain Contracts (continued)

AMQP Message Delivery teaches message structure, delivery modes, publisher confirms, consumer acknowledgments, prefetch, dead-letter queues, and delivery sizing.

  • This page tightens the contract that connects those pieces: no single flag makes delivery reliable, and each acknowledgment only means something inside its scope.
  • Concrete chain example: a gateway sends a valve-state alarm and keeps its local copy until the broker sends a publisher confirm.
  • Retrying from a message id makes the duplicate detectable.
iotclass.org

Major section

AMQP Delivery Reliability Chain Contracts (continued)

If the broker confirms and then restarts, the durable queue and persistent message are what make the alarm still appear after recovery.

  • If the consumer receives the alarm, writes it to an incident table, and crashes before basic.ack, the broker requeues the unacknowledged delivery on channel close.
  • Treating those as one chain keeps operators from over-trusting a single durable setting.
  • That requeue is why at-least-once can *duplicate*.
iotclass.org

Major section

AMQP Delivery Reliability Chain Contracts (continued)

The consumer reads, writes the reading to the database, and only then sends basic.ack.

  • The practical audit question is therefore always, "where can the message be acknowledged but not yet recoverable?" Publisher confirms answer the producer side, persistence answers the broker restart side, and manual acknowledgements answer the consumer side.
  • The two disk settings only work together: a persistent message in a transient queue is not saved, and a transient message in a durable queue is not saved either.
  • If four consumers each use basic.qos(prefetch_count=20), as many as 80 messages can be delivered but unacknowledged at once.
iotclass.org

Major section

AMQP Delivery Reliability Chain Contracts (continued)

Publisher confirms even close the fsync race -- the broker only confirms a persistent message routed to a durable queue after it is on disk.

  • Worked example -- a meter reading that must not be lost: The producer opens confirm mode, publishes with delivery-mode=2 to a durable queue, and waits for the broker's confirm before deleting its local copy.
  • A worker crash with 17 unacked messages does not lose those messages; they return to the queue when the channel closes.
  • That count is what lets a retry loop give up after N attempts instead of cycling a poison message forever.
iotclass.org

Deck summary

Key takeaways

For telemetry with 120-byte payloads, nearly half the bandwidth is protocol overhead.

  • The message reaches a queue, the worker writes the incident, and then the worker crashes before it says the job is done.
  • AMQP Message Delivery teaches message structure, delivery modes, publisher confirms, consumer acknowledgments, prefetch, dead-letter queues, and delivery sizing.
  • If the broker confirms and then restarts, the durable queue and persistent message are what make the alarm still appear after recovery.
  • The consumer reads, writes the reading to the database, and only then sends basic.ack.
iotclass.org

Retrieval practice

Recall check 1 of 4

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

Q1A plant has 500 machines. Each sends one reading every 5 seconds. What is the average reading rate?

A2500 readings per second
B10 readings per second
C500 readings per second
D100 readings per second
Show answer

Answer: D Divide the machine count by the time between readings.

Q2Who creates an AMQP message and sends it to an exchange?

APublisher Confirm
BBroker Exchange + Queue
CConsumer ACK/NACK
DPublisher
Show answer

Answer: D The publisher creates the message and sends it to an exchange.

Q3Complete the AMQP publisher with persistent delivery mode and publisher confirms:

Achannel.confirm_delivery()
Bchannel.enable_confirms()
Cchannel.set_confirm_mode()
Dchannel.start_confirms()
Show answer

Answer: A Publisher confirms are enabled with confirm_delivery().

iotclass.org

Retrieval practice

Recall check 2 of 4

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

Q4Per this chapter's sizing worked example (four consumers, each with prefetch_count=20), why does a worker crash while holding 17 unacknowledged messages not lose those 17 messages?

AThe prefetch limit keeps a separate recovery queue of pending work, from which another consumer receives the 17 messages
BThe persistent delivery mode recovers the 17 messages from disk when the replacement worker connects to the broker
CThe publisher confirm remains pending until the consumer finishes, prompting the producer to resend the 17 messages
DThe broker sees the channel drop and requeues the unacknowledged messages, so another consumer reprocesses them
Show answer

Answer: D Unacknowledged messages are still owned by the queue until acked.

iotclass.org

Retrieval practice

Recall check 3 of 4

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

Q5A durable queue holds delivery-mode 1 (transient) messages. After a broker restart, what persistence guarantee is missing, and which message property addresses that gap?

ADurable queue makes delivery-mode 1 messages persistent after broker restart.
BDurable queue survives; transient messages need mode 2 for restart.
CThe queue vanishes; redeclaring durable preserves the transient messages.
DAuto-ack makes both queue and transient messages survive restart.
Show answer

Answer: B A durable queue definition can survive restart while delivery-mode 1 messages have no persistence guarantee.

iotclass.org

Retrieval practice

Recall check 4 of 4

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

Q6A poison message keeps failing after bounded retries. Where should it go for investigation?

AParking queue with body, failure reason and source context.
BRequeue to the main queue forever, even after bounded attempts.
CAcknowledge an empty result and discard the failure context.
DSend it into a producer connection with no review record.
Show answer

Answer: A Parking stops the retry loop and keeps the evidence needed for repair.

iotclass.org

Print reference

Answers

Answer key.

  1. D · Divide the machine count by the time between readings.
  2. D · The publisher creates the message and sends it to an exchange.
  3. A · Publisher confirms are enabled with confirm_delivery().
  4. D · Unacknowledged messages are still owned by the queue until acked.
  5. B · A durable queue definition can survive restart while delivery-mode 1 messages have no persistence guarantee.
  6. A · Parking stops the retry loop and keeps the evidence needed for repair.
iotclass.org