Back to results for “Monitoring (CloudWatch)”
AWS › Amazon SQS (Simple Queue Service)

What is a dead letter queue in SQS, and why is it useful for handling failed messages?

Intermediate

Answer

A dead letter queue is a separate SQS queue that automatically receives messages which have failed processing a specified maximum number of times, isolating problematic messages away from the main queue so they do not repeatedly block or slow down processing of healthy messages, while still preserving the failed messages for later investigation, debugging, or manual reprocessing.
aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/OrderQueue --attributes '{"RedrivePolicy":"{\"deadLetterTargetArn\":\"arn:aws:sqs:us-east-1:123456789012:OrderDLQ\",\"maxReceiveCount\":\"3\"}"}'
Real-world example An order processing system automatically routes any order message that fails processing three times into a dead letter queue, alerting the engineering team to investigate the specific malformed order rather than letting it repeatedly clog the main processing queue.

Common follow-ups: How do you monitor and alert on messages arriving in a dead letter queue?;Can messages be moved back from a dead letter queue to the main queue for reprocessing?