CodePark/ questions / Retries, poison messages & DLQs
START PRACTICINGPRACTICE
Backend question · Message queues & streaming › Retries, poison messages & DLQs

An SQS queue has a redrive policy with maxReceiveCount: 5 pointing at a DLQ. When does a message move to the DLQ?

After it has been received 5 times without being deleted, its next receive moves it to the DLQ

SQS counts how many times a message is received. Each time a consumer gets the message but does not delete it before the visibility timeout ends, the count goes up. The visibility timeout is the time the message stays hidden from other consumers. Once the count goes over maxReceiveCount, SQS moves the message to the DLQ.

"After 5 different consumers have read it, even if one deleted it" is wrong. A deleted message is gone for good, so it never reaches the DLQ. "After it has been in the queue for 5 minutes" is also wrong, because SQS counts receives, not time.