SQS - 交货延迟 30 分钟 [英] SQS - Delivery Delay of 30 minutes
问题描述
从 SQS 的文档中,我们可以配置一条消息向其消费者隐藏的最大时间延迟是 15 分钟 - http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-delay-queues.html
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/latest/SQSDeveloperGuide/sqs-delay-queues.html
假设如果我需要将消息隐藏一天,模式是什么?例如.我想模仿一个每天的 cron 来做一些动作.
Suppose if I need to hide the messages for a day, what is the pattern? For eg. I want to mimic a daily cron for doing some action.
谢谢
推荐答案
最简单的方法如下:
SQS.push_to_queue({perform_message_at : "Thursday November 2022"},delay: 15 mins)
在你的工人内部
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.
这篇关于SQS - 交货延迟 30 分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!