简体   繁体   中英

Reprocess AWS SQS Dead Letter Queue messages

I'm sending messages that failed in my lambda to a dead letter queue using aws sdk. I want to wait for few hours before sending the message back to the main queue for reprocessing. I have a lambda attached to my dead letter queue. I can use delay for sending messages to the dead letter queue. But the maximum delay is 15 minutes. But I want to wait for more time. Has anyone done this before?

Amazon SQS is not intended to be used in this manner . Its primary purpose is to store messages and then provide them back when requested.

Some other options:

  • Store the message in a database and have the application search for relevant messages based on a timestamp field, or
  • Do some tricky stuff with delays on AWS Step Functions (which has a delay feature)

As shown in this answer you can extend the delay, by giving each message a timestamp and processing only those that are in queue for a while now.

message = SQS.poll_messages
if message.perform_message_at > Time.now
   SQS.push_to_queue({perform_message_at : "Thursday November 
   2022"},delay:15 mins)
else
   process_message(message)
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM