When sending a message to an SQS Queue in AWS we can set a delay for the message to be visible to consumers of the queue for processing.

This can be done by setting a Delay for the message.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3e789b4f-f111-4bbf-85d9-d517319cfcf6/Untitled.png

Why would I want to do this ?

We might want to space out the message processing. Say for example you are sendig the messages to a Thrid party service for processing and dont want to DDOS the service by sending too may messages at a point of time, but space out the messages getting sent.

Visibility Timeout for the Queue

When processing messages where we are setting a delay remember to set the Visibility timeout of the Queue to a large enough value . If the visibility timeout is very short for example say 30 seconds and you have put a delay of 1 minute for your message. The message will never be picked up by the consumer and get lost.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/fdd2937e-ead3-407a-a46b-131df057ecf7/Untitled.png