SQS - Delivery Delay of 30 minutes

前端 未结 4 1327
梦如初夏
梦如初夏 2021-01-04 21:33

From the documentation of SQS, Max time delay we can configure for a message to hide from its consumers is 15 minutes - http://docs.aws.amazon.com/AWSSimpleQueueService/late

相关标签:
4条回答
  • 2021-01-04 21:39

    Visibility timeout can do up to 12 hours. I think you can hack something together where you process a message but don't delete it and next time it is processed its been 12 hours. So a queue with one message and visibility timeout of 12 hours. That gets you a 12 hour cron.

    0 讨论(0)
  • 2021-01-04 21:42

    Two thoughts.

    1. Untested. Perhaps publish to and SNS topic that has no SQS queues. When delivery needs to happen, subscribe the queue to the topic. (I've not done this, I'm not sure if this would work as expected)
    2. Push messages as files to a central store (like S3). Create a worker that looks at the time created timestamp and decides whether to publish them to a queue or not. If created >= 1d ago, publish.
    0 讨论(0)
  • 2021-01-04 21:48

    The simplest way to do this is as follows:

    SQS.push_to_queue({perform_message_at : "Thursday November 2022"},delay: 15 mins)
    

    Inside your worker

    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
    

    Basically push the message back to the queue with the maximum delay and only process it when its processing time is less than the current time.

    HTH.

    0 讨论(0)
  • 2021-01-04 22:02

    Cloudwatch is likely a better way to do it. You can use a createEvent API with the timer, and have it trigger either a lambda function or an API call to whatever comes next.

    Another way to do is to use the "wait" utility in an AWS step function.

    https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-wait-state.html

    In any case, unless you are extremely sure you will never need anything more than 15 minutes, the SQS backdoor to add the delay seems hacky.

    0 讨论(0)
提交回复
热议问题