Skip to content

Why are my Amazon SQS messages unexpectedly sent to a DLQ?

2 minute read
0

I configured an Amazon Simple Queue Service (Amazon SQS) dead-letter queue (DLQ). My Amazon SQS messages unexpectedly moved to the DLQ, and I want to understand why.

Resolution

Your Amazon SQS messages might move to the DLQ for the following reasons.

ReceiveCount exceeds maxReceiveCount

The default maxReceiveCount value is 10. When the ReceiveCount value exceeds the maxReceiveCount value for a queue, Amazon SQS moves the message to the DLQ. To resolve this issue, it's a best practice to set the maxReceiveCount value high enough to allow for Amazon SQS retries. For example, if the maxReceiveCount value is set to 1, then one failure to receive a message causes the message to move to the DLQ.

Your Lambda function requires additional configuration

If you use an AWS Lambda function to process messages in your Amazon SQS queue, then you might need to reconfigure your function. For more information, see Why is my Lambda function retrying valid Amazon SQS messages and placing them in my dead-letter queue?

You used the AWS Management Console to view SQS messages

SQS messages that you view on the AWS Management Console might move to the DLQ because they count against the queue's redrive policy. You can increase the Maximum receives value for the DLQ redrive policy up to 1,000. For more information, see Configure a dead-letter queue using the Amazon SQS console.

You tried to delete SQS messages with an expired ReceiptHandle or after the visibility timeout period

Messages move to the DLQ after retries. The QueueDoesNotExist error can occur when you perform a DeleteMessage operation with an earlier ReceiptHandle from the main queue. You must delete messages within the configured VisibilityTimeout window. For more information, see How do I troubleshoot the QueueDoesNotExist error when I make API calls to my Amazon SQS queue?

Related information

Using dead-letter queues in Amazon SQS