Why did my Amazon SQS messages get sent to a dead-letter queue?

2 minute read
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.

Note: Amazon SQS doesn't automatically create the DLQ. To create a DLQ, see Configuring a dead-letter queue (console). To configure a DLQ redrive, see Configuring a dead-letter queue redrive.

  • 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 an AWS Lambda function to process messages in your Amazon SQS queue, then additional configuration might be required. For more information, see Why is my Lambda function retrying valid Amazon SQS messages and placing them in my dead-letter queue?
  • 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?

Related information

How do dead-letter queues work?

AWS OFFICIAL
AWS OFFICIALUpdated 7 months ago