死信队列 (DLQ) 是消息在无法处理或满足特定条件时被发送的地方(被拒绝、过期、队列已满)。DLQs 防止有问题的消息丢失或阻塞处理,可以在之后进行检查和处理。
什么是死信队列
text
DEAD LETTER QUEUE → a queue that receives messages that couldn't be delivered/processed
normally:
→ messages are "dead-lettered" (routed to the DLQ) when they:
- are REJECTED/nacked (consumer can't process them) without requeue
- EXPIRE (message TTL exceeded)
- exceed the queue's MAX LENGTH (overflow)
→ the DLQ collects these for inspection/handling instead of losing them
→ a "holding area" for problematic messages
死信队列为什么重要
text
✓ Don't LOSE failed messages → they go to the DLQ (not discarded) → inspect/reprocess later
✓ Don't BLOCK processing → a "poison" message that always fails is moved aside (not retried
forever blocking the queue)
✓ VISIBILITY → DLQ messages reveal problems (bad data, bugs, downstream failures)
✓ Handle failures gracefully → retry logic, manual intervention, alerting on DLQ
