AWS SQS delay on retry

0

Hello,

There is a question: can we set up AWS SQS delay for the next retry attempt?

The main goal:

  • I put in SQS the messages which are planned so be sent as email
  • Imagine the 1st attempt of sending mail failed (e.g: server down)
  • The retry will happen
  • So I want to postpone the next retry attempt to provide some time for a server to restore.

Appreciate any help. Thanks!

asked 7 months ago2465 views
2 Answers
0
Accepted Answer

You can't control the retry schedule from SQS, but you have a couple of options:

  1. Remove the message from the queue and put it back in, with a delay (note that you can set the delay for each message individually, no need to define a delay queue).
  2. Set the visibility timeout to some larger value and do not delete the message.
profile pictureAWS
EXPERT
Uri
answered 7 months ago
0

Hello.

Configure the Delay Attribute: By default, SQS queues have a delay of 0 seconds, meaning messages are available for processing as soon as they are sent to the queue. To introduce a delay, you'll need to set the DelaySeconds attribute when sending messages to the queue.

Using the AWS Management Console: When you send a message through the console, you can specify the delay in seconds as shown in the console UI.

Using the AWS CLI: You can use the --delay-seconds parameter when using the aws sqs send-message command. For example: aws sqs send-message --queue-url <queue-url> --message-body "Your message" --delay-seconds 300

Using an SDK: When using an SDK, you can set the DelaySeconds attribute in the message attributes or properties before sending the message.

But be careful that messages that have a delay set will not be visible to consumers until the specified delay period has passed. After the delay period, the messages become available for retrieval by consumers.

Best regards, Andrii

profile picture
EXPERT
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions