← Back to the chapter · Previous detail · Next detail →

Technical detail · AMQP Operations: Deployment and Broker Health

Declare the dead-letter destination

# Declare dead letter exchange and queue
channel.exchange_declare(exchange='dlx', exchange_type='direct', durable=True)
channel.queue_declare(queue='dead-letters', durable=True)
channel.queue_bind(exchange='dlx', queue='dead-letters', routing_key='orders.failed')

# Main queue with DLX configuration
channel.queue_declare(
    queue='orders',
    durable=True,
    arguments={
        'x-dead-letter-exchange': 'dlx',
        'x-dead-letter-routing-key': 'orders.failed',
        'x-message-ttl': 86400000,  # 24 hour TTL
        'x-max-length': 100000       # Max 100K messages
    }
)

← Back to the chapter · Previous detail · Next detail →