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: 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.
  • Explain: 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.
  • Explain: 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

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 \times 236B) - (1,200B + 116B) = 1,044B$ per 10 readings (44% reduction).
  • Conclusion:: The telemetry (98% of messages) uses fire-and-forget, keeping broker load minimal.
  • That overhead is waste for data that is replaced every 5 seconds.

Numbers to remember

98%Conclusion:: The telemetry (98% of messages) uses fire-and-forget
~360 KbpsUsing exactly-once for all messages would increase bandwidth to ~360 Kbps (vs.
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.

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)

Treating those as one chain keeps operators from over-trusting a single durable setting.

  • This opening does not promise exactly-once physical action.
  • AMQP Message Delivery teaches message structure, delivery modes, publisher confirms, consumer acknowledgments, prefetch, dead-letter queues, and delivery sizing.
  • Retrying from a message id makes the duplicate detectable.
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.

  • 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.
  • That requeue is why at-least-once can *duplicate*.
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.
  • 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.
  • Retryable work waits in the TTL queue and returns; excessive failures move to parking with context intact.
iotclass.org

Major section

AMQP Delivery Reliability Chain Contracts (continued)

If four consumers each use basic.qos(prefetch_count=20), as many as 80 messages can be delivered but unacknowledged at once.

  • 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.
  • Publisher confirms even close the fsync race -- the broker only confirms a persistent message routed to a durable queue after it is on disk.
  • A worker crash with 17 unacked messages does not lose those messages; they return to the queue when the channel closes.
iotclass.org

Major section

AMQP Delivery Reliability Chain Contracts (continued)

The DLX can route it to a retry queue with x-message-ttl=30000; after 30 seconds that retry queue dead-letters it back to the main exchange.

  • 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.
  • That count is what lets a retry loop give up after N attempts instead of cycling a poison message forever.
  • The next worker may see the same alarm, so the team must prevent a second incident without losing the first.
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.
  • Treating those as one chain keeps operators from over-trusting a single durable setting.
  • The consumer reads, writes the reading to the database, and only then sends basic.ack.
  • If the broker confirms and then restarts, the durable queue and persistent message are what make the alarm still appear after recovery.
iotclass.org

Retrieval practice

Recall check 1 of 3

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

Q1Place each AMQP delivery event where it lives so you can tell broker acceptance, queue routing, and consumer completion apart.

APublisher
BPublisher Confirm
CBroker Exchange + Queue
DConsumer ACK/NACK
Show answer

Answer: A Separate publish acceptance, broker routing and retention, and consumer settlement so you can prove exactly how far a message travelled.

Q2Complete 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 3

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

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

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

iotclass.org

Retrieval practice

Recall check 3 of 3

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

Q4A durable queue holds messages published with delivery-mode 1 (transient). The broker restarts. What happens, and what is the minimal fix for zero loss?

AQueue survives; transient messages are lost. Use delivery-mode 2.
BBoth the queue and its messages survive, because a durable queue implies persistent messages.
CThe queue is deleted; make the queue durable to keep the transient messages.
DNothing is lost as long as consumers use auto-ack.
Show answer

Answer: A Queue durability keeps the definition; message persistence keeps the contents.

iotclass.org

Print reference

Answers

Answer key.

  1. A · Separate publish acceptance, broker routing and retention, and consumer settlement so you can prove exactly how far a message travelled.
  2. A · Publisher confirms are enabled with confirm_delivery().
  3. A · Unacknowledged messages are still owned by the queue until acked.
  4. A · Queue durability keeps the definition; message persistence keeps the contents.
iotclass.org