Amazon SQS 延迟队列
Posted cloudrivers
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Amazon SQS 延迟队列相关的知识,希望对你有一定的参考价值。
延迟队列可让您将针对队列的新消息传递操作推迟特定的秒数。如果您创建延迟队列,则发送到该队列的任何消息在延迟期间对用户都保持不可见。队列的默认(最小)延迟为 0 秒。最大延迟为 15 分钟。
延迟队列类似于可见性超时,因为这两种功能都使得使用者在特定的时间段内无法获得消息。二者之间的区别在于:对于延迟队列,消息在首次添加到队列时 是隐藏的;而对于可见性超时,消息只有在从队列使用后 才是隐藏的。下图说明了延迟队列和可见性超时之间的关系。
要为单条消息 而不是整个队列设置延迟(以秒为单位),请使用消息计时器以允许 Amazon SQS 使用消息计时器的 DelaySeconds
值,而不是使用延迟队列的 DelaySeconds
值。
Amazon SQS Delay Queues
Delay queues let you postpone the delivery of new messages to a queue for a number of seconds. If you create a delay queue, any messages that you send to the queue remain invisible to consumers for the duration of the delay period. The default (minimum) delay for a queue is 0 seconds. The maximum is 15 minutes. For information about configuring delay queues using the AWS Management Console or the AWS SDK for Java (and the SetQueueAttributes
action), see Configuring an Amazon SQS Delay Queue.
Note
For standard queues, the per-queue delay setting is not retroactive—changing the setting doesn‘t affect the delay of messages already in the queue.
For FIFO queues, the per-queue delay setting is retroactive—changing the setting affects the delay of messages already in the queue.
Delay queues are similar to visibility timeouts because both features make messages unavailable to consumers for a specific period of time. The difference between the two is that, for delay queues, a message is hidden when it is first added to queue, whereas for visibility timeouts a message is hidden only after it is consumed from the queue. The following diagram illustrates the relationship between delay queues and visibility timeouts.
To set delay seconds on individual messages, rather than on an entire queue, use message timers to allow Amazon SQS to use the message timer‘s DelaySeconds
value instead of the delay queue‘s DelaySeconds
value.
以上是关于Amazon SQS 延迟队列的主要内容,如果未能解决你的问题,请参考以下文章
Amazon-SQS + Django-Celery 创建了数千个队列(每条消息一个队列)
如何真正快速地从 Amazon SQS(简单队列服务)队列中删除事件?