Search code examples
amazon-web-servicesamazon-sqs

When a message being sent to DLQ


I'm trying to understand when and by what trigger exactly message can be thrown to DLQ.

For example, there is a schema below, where SNS produces messages into SQS and some Spring Service consumes this SQS.

Simple SQS pattern

If we attach DLQ to the Main queue, we can configure Maximum receives parameter (depicted below). I don't get it from documentation, if, for example, Maximum receives equals to 1, and Spring Service makes an attempt to consume a message from the SQS and fails for some reason after the very first attempt, that message will go into DLQ, right?

And so, if we want to give the Spring Service a few more attempts for consumption a message we need to increase Maximum receives parameter? 🤔

DLQ settings


Solution

  • And so, if we want to give the Spring Service a few more attempts for consumption a message we need to increase Maximum receives parameter?

    Yes. That's right. To minimize that, you have to ensure that your SQS visibility timeout is adequate for the processing. If the processing time is variable, you can also modify the visibility time per message, e.g. by extending it ever 30 s in your spring application.