Why did my Amazon SQS messages get sent to a dead-letter queue?
所要時間2分
0
I configured an Amazon Simple Queue Service (Amazon SQS) dead-letter queue (DLQ). Some Amazon SQS messages were sent to the DLQ that I didn’t expect and I want to understand why.
Resolution
The maxReceiveCount value is the number of times a message is delivered to the source queue before it's moved to the DLQ. When the ReceiveCount message value exceeds the maxReceiveCount value for a queue, Amazon SQS moves the message to the DLQ.
Check the maxReceiveCount value for your Amazon SQS queue. The default maxReceiveCount value is 10. If the maxReceiveCount is set to a low value such as 1, then message failures are moved to the DLQ. Make sure that the maxReceiveCount value is set high enough to allow for Amazon SQS retries.
Make sure that the DLQ retention period is longer than the retention period of the original queue. This allows for more time for Amazon SQS retries.
If you use the AWS Management Console to view SQS messages, then those messages might get moved to the DLQ. SQS message views in the AWS Management Console counts against the queues redrive policy. You can increase the Maximum receives value for the DLQ. The Maximum receives value is 1000. For more information, see Viewing messages using the console might cause messages to be moved to a dead-letter queue.
For standard SQS queues that are configured with a DLQ, messages are moved 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?