02.02.2018 Views

sqsputapi

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<br />

Message Lifecycle<br />

Extending a Message's Visibility Timeout<br />

When you receive a message from the queue, you might find the visibility timeout for the queue is<br />

insufficient to fully process and delete that message. Amazon SQS allows you to extend the visibility<br />

timeout for that particular message. When you extend the visibility timeout, Amazon SQS overwrites the<br />

original timeout value and the new value begins at the time you changed it.<br />

For example, let's say the timeout for the queue is 30 seconds, and you receive a message. Once you're<br />

20 seconds into the timeout for that message (i.e., you have 10 seconds left), you extend it by 60 seconds<br />

by calling ChangeMessageVisibility with VisibilityTimeoutset to 60 seconds.You have then changed<br />

the remaining visibility timeout from 10 seconds to 60 seconds.<br />

The extension you request is not stored in memory for that message. If for some reason you don't delete<br />

the message and the message is received again, the visibility timeout for the message the next time it's<br />

received is the overall value for the queue and not the extended value you previously set.<br />

Terminating a Message's Visibility Timeout<br />

When you receive a message from the queue, you might find that you actually don't want to process and<br />

delete that message. Amazon SQS allows you to terminate the visibility timeout for a specific message,<br />

which immediately makes the message visible to other components in the system to process. To do this,<br />

you call ChangeMessageVisibility with VisibilityTimeout=0 seconds.<br />

API Actions Related to Visibility Timeout<br />

The following table lists the API actions to use to manipulate the visibility timeout.<br />

To do this...<br />

Set the visibility timeout for a queue<br />

Get the visibility timeout for a queue<br />

Set the visibility timeout for the received messages without<br />

affecting the queue's visibility timeout<br />

Extending or terminating a message's visibility timeout<br />

Use this action<br />

SetQueueAttributes<br />

GetQueueAttributes<br />

ReceiveMessage and set the<br />

VisibilityTimeout parameter to the<br />

value you want<br />

ChangeMessageVisibility<br />

Message Lifecycle<br />

The following diagram and process describe the lifecycle of an Amazon SQS message, called Message<br />

A, from creation to deletion. Assume that a queue already exists.<br />

API Version 2009-02-01<br />

9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!