← Back to the chapter · Next detail →
Technical detail · AMQP Delivery: Guarantees and Acknowledgements
Delivery fields across AMQP versions
| Field | Description | Common Values |
|---|---|---|
| Durable | Message survives broker restart | True (persistent), False (transient) |
| Priority | Message priority level | 0-9 (0 lowest, 9 highest) |
| TTL | Time-To-Live before expiration | Milliseconds (e.g., 60000 for 1 minute) |
| First-Acquirer | First consumer to receive | Boolean |
| Delivery-Count | Number of delivery attempts | Integer |
The durable, first-acquirer and delivery-count names in this table belong to AMQP 1.0. For AMQP 0-9-1, the following Pika fragment requests persistence, priority 8 and a 60-second expiration. It publishes order 12345 through orders with routing key order.priority. Queue declaration, binding and confirmation are separate setup.
import pika
properties = pika.BasicProperties(
delivery_mode=2, # Persistent (survives restart)
priority=8, # High priority (0-9 scale)
expiration='60000' # TTL: 60 seconds
)
channel.basic_publish(
exchange='orders',
routing_key='order.priority',
body='{"order_id": 12345}',
properties=properties
)