What is a dead letter exchange (DLX) in RabbitMQ?
Answer
A Dead Letter Exchange (DLX) is an exchange where messages are routed when they cannot be delivered to their intended queue or consumer. Messages become "dead letters" when: they are negatively acknowledged (nack) with requeue: false, they exceed the queue's TTL (x-message-ttl), or the queue exceeds its max length. Configure DLX on a queue: {"x-dead-letter-exchange": "dlx_exchange", "x-dead-letter-routing-key": "dead"}. A second queue binds to the DLX to receive dead letters. Use cases: Error handling: inspect failed messages. Delayed retry: dead-letter to a TTL queue, then re-route back to the original queue after the TTL expires (delayed retry pattern). Monitoring: alert when messages accumulate in the DLX. Dead letter queues are essential for production RabbitMQ systems — without them, failed messages are silently discarded or cause infinite retry loops.