Dead Letter Queues
What You'll Learn
You'll learn how Dead Letter Queues (DLQs) capture failed messages so they don't get lost or block your system.
What is a Dead Letter Queue?
A Dead Letter Queue is a special holding area for messages that cannot be successfully processed after multiple delivery attempts. Think of it like a hospital's "undeliverable mail" bin—when a message can't reach its destination or causes errors repeatedly, it's moved to the DLQ instead of being discarded or blocking the main queue.
Why DLQs Matter
Without a DLQ, failed messages might:
- Disappear silently, causing data loss
- Keep retrying forever, wasting resources
- Block other valid messages from processing
A DLQ lets you:
- Preserve failed messages for later investigation
- Keep your main queue flowing smoothly
- Debug issues without losing critical data
How DLQs Work
When a message fails processing:
- The queue system retries delivery (based on your retry policy)
- After max retries are exhausted, the message moves to the configured DLQ
- The original queue continues processing other messages
- You can inspect DLQ messages, fix issues, and optionally reprocess them
Common Use Cases
- Malformed messages: Invalid JSON or missing required fields
- External service failures: A downstream API is temporarily unavailable
- Business logic errors: Data that violates validation rules
- Processing timeouts: Messages that consistently take too long
Key Takeaway: Dead Letter Queues are safety nets that capture messages that fail after multiple retry attempts, preventing data loss and keeping your message processing pipeline healthy and debuggable.