sqs-dg-2009-02-01
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Amazon Simple Queue Service Developer Guide
Message Lifecycle
Extending a Message's Visibility Timeout
When you receive a message from the queue, you might find the visibility timeout for the queue is
insufficient to fully process and delete that message. Amazon SQS allows you to extend the visibility
timeout for that particular message. When you extend the visibility timeout, Amazon SQS overwrites the
original timeout value and the new value begins at the time you changed it.
For example, let's say the timeout for the queue is 30 seconds, and you receive a message. Once you're
20 seconds into the timeout for that message (i.e., you have 10 seconds left), you extend it by 60 seconds
by calling ChangeMessageVisibility with VisibilityTimeoutset to 60 seconds.You have then changed
the remaining visibility timeout from 10 seconds to 60 seconds.
The extension you request is not stored in memory for that message. If for some reason you don't delete
the message and the message is received again, the visibility timeout for the message the next time it's
received is the overall value for the queue and not the extended value you previously set.
Terminating a Message's Visibility Timeout
When you receive a message from the queue, you might find that you actually don't want to process and
delete that message. Amazon SQS allows you to terminate the visibility timeout for a specific message,
which immediately makes the message visible to other components in the system to process. To do this,
you call ChangeMessageVisibility with VisibilityTimeout=0 seconds.
API Actions Related to Visibility Timeout
The following table lists the API actions to use to manipulate the visibility timeout.
To do this...
Set the visibility timeout for a queue
Get the visibility timeout for a queue
Set the visibility timeout for the received messages without
affecting the queue's visibility timeout
Extending or terminating a message's visibility timeout
Use this action
SetQueueAttributes
GetQueueAttributes
ReceiveMessage and set the
VisibilityTimeout parameter to the
value you want
ChangeMessageVisibility
Message Lifecycle
The following diagram and process describe the lifecycle of an Amazon SQS message, called Message
A, from creation to deletion. Assume that a queue already exists.
API Version 2009-02-01
9