|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
Delay queues allow you to postpone the delivery of new messages in a queue for a specific number of seconds. If you create a delay queue, any message that you send to that queue will be invisible to consumers for the duration of the delay period. You can use
CreateQueue to create a delay queue by setting the
DelaySeconds attribute to any value between 0 and 900 (15 minutes). You can also turn an existing queue into a delay queue by using
SetQueueAttributes to set the queue's
Delay queues are similar to visibility timeouts in that both features make messages unavailable to consumers for a specific period of time. The difference between delay queues and visibility timeouts is that for delay queues, a message is hidden when it is first added to the queue, whereas for visibility timeouts, a message is hidden only after a message is retrieved from the queue. The following figure illustrates the relationship between delay queues and visibility timeouts.
There is a 120,000 limit for the number of inflight messages per queue. Messages are inflight after they have been received by the queue, but have not yet been deleted from the queue. If you reach the 120,000 limit, you will receive an OverLimit error message from Amazon SQS. To help avoid reaching the limit, you should delete the messages from the queue after they have been processed. You can also increase the number of queues you use to process the messages.
To set delay seconds on individual messages, rather than for an entire queue, use message timers. If you send a message with a message timer, Amazon SQS uses the message timer's delay seconds value instead of the delay queue's delay seconds value. For more information, see Amazon SQS Message Timers.
All Amazon SQS queues have delay functionality enabled. You can turn any queue that you create using the 2008-01-01 or 2009-02-01 API versions into a delay queue. Message timers are available in the 2011-10-01 API version and later API versions. If you want to apply specific delay values to individual messages, you must use the 2011-10-01 API version or later API versions.
You can create a delay queue using the AWS Management Console by setting a Delivery Delay value that is greater than 0.
To create a delay queue with the AWS Management Console
Sign in to the AWS Management Console and open the Amazon SQS console at https://console.aws.amazon.com/sqs/.
Click Create New Queue.
In the Create New Queue dialog box,
enter a name for your queue (e.g.,
MyQueue) in the Queue Name
Enter a positive integer value (e.g., 30) for the Delivery Delay attribute.
You can leave the default value settings for the remaining fields or enter new values.
Click Create Queue.
You can use the AWS Management Console to change the Delivery Delay setting for an existing queue by selecting the Configure Queue action with an existing queue highlighted.
The following Query API example calls the
CreateQueue action to create a delay queue that hides each message from consumers for the first 45 seconds that the message is in the queue.
http://sqs.us-east-1.amazonaws.com/ ?Action=CreateQueue &QueueName=testQueue &Attribute.1.Name=DelaySeconds &Attribute.1.Value=45 &Version=2011-10-01 &SignatureMethod=HmacSHA256 &Expires=2011-10-20T22%3A52%3A43PST &AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE &SignatureVersion=2 &Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE
You can also change an existing queue into a delay queue by changing the DelaySeconds attribute from its default value of 0 to a positive integer value that is less than or equal to 900. The following example calls
SetQueueAttributes to set the
DelaySeconds attribute of a queue named
testQueue to 45 seconds.
http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/ ?Action=SetQueueAttributes &Attribute.Name=DelaySeconds &Attribute.Value=45 &Version=2011-10-01 &SignatureMethod=HmacSHA256 &Expires=2011-10-20T22%3A52%3A43PST &AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE &SignatureVersion=2 &Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE