Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SQS message retention period

Tags:

According to documentation the maximum SQS message retention period(MessageRetentionPeriod) is 14 days. After that time message will be deleted from the queue.

Is any way with SQS to not lose these messages after their retention period expired? For example, it is not clear or is it possible to use Dead Letter Queue for this purpose?

like image 623
alexanoid Avatar asked Aug 02 '16 16:08

alexanoid


People also ask

Are SQS messages automatically deleted?

Amazon SQS doesn't automatically delete a message after retrieving it for you, in case you don't successfully receive the message (for example, if the consumers fail or you lose connectivity).

What is message retention period?

The message retention period is the length of time that messages are kept in the message store in a final state (successful, canceled) before they are archived.

What happens if SQS message is not deleted?

Messages in Amazon SQS have a limited amount of time to be received and processed before they are automatically deleted by SQS. If a message is not processed before the message retention period has passed, it will be permanently deleted.

Is SQS persistent?

SQS : Messages are persisted for some duration is no consumer available. The retention period value is from 1 minute to 14 days. The default is 4 days. SNS : No persistence.


1 Answers

Well 14 days is the max limit you can keep the message. After 14 days you can move that message to S3 Bucket for backup. Also there is a hack you can do with DLQ.

Here is a quick hack where you send that message back to the main queue. This is definitely not the best or recommended option.

  1. Set the main SQS queue as the DLQ for the actual DLQ with Maximum Receives as 1.
  2. View the content in DLQ (This will move the messages to the main queue as this is the DLQ for the actual DLQ)
  3. Remove the setting so that the main queue is no more the DLQ of the actual DLQ
like image 52
error2007s Avatar answered Sep 21 '22 13:09

error2007s