Amazon Simple Queue Service
API Reference (API Version 2011-10-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

ChangeMessageVisibility

Description

The ChangeMessageVisibility action changes the visibility timeout of a specified message in a queue to a new value. The maximum allowed timeout value you can set the value to is 12 hours. This means you can't extend the timeout of a message in an existing queue to more than a total visibility timeout of 12 hours. (For more information visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide.)

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.

[Important]Important

If you attempt to set the VisibilityTimeout to an amount more than the maximum time left, Amazon SQS returns an error. It will not automatically recalculate and increase the timeout to the maximum time remaining.

[Important]Important

Unlike with a queue, when you change the visibility timeout for a specific message, that timeout value is applied immediately but is not saved in memory for that message. If you don’t delete a message after it is received, the visibility timeout for the message the next time it is received reverts to the original timeout value, not the value you set with the ChangeMessageVisibility action.

Request Parameters

The following table lists the special request parameters the action uses (in addition to the common request parameters listed in Common Query Parameters).

NameDescriptionRequired

ReceiptHandle

The receipt handle associated with the message whose visibility timeout you want to change. This parameter is returned by the ReceiveMessage action.

Type: String

Default: None

Yes

VisibilityTimeout

The new value for the message's visibility timeout (in seconds).

Type: Integer from 0 to 43200 (maximum 12 hours)

Constraints: This value is limited to 43200 seconds (12 hours)

Default: None

Yes

Response Elements

The response contains no special elements besides the common elements listed in the Responses section in the Amazon SQS Developer Guide.

Special Errors

The action returns no errors besides the common errors listed in Common Errors.

Examples

The following example Query request changes the visibility timeout for a message to 60 seconds.

Sample Request

http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=ChangeMessageVisibility
&VisibilityTimeout=60
&ReceiptHandle=MbZj6wDWli%2BJvwwJaBV%2B3dcjk2YW2vA3%2BSTFFljT
M8tJJg6HRG6PYSasuWXPJB%2BCwLj1FjgXUv1uSj1gUPAWV66FU/WeR4mq2OKpEGY
WbnLmpRCJVAyeMjeU5ZBdtcQ%2BQEauMZc8ZRv37sIW2iJKq3M9MFx1YvV11A2x/K
SbkJ0=
&Version=2009-02-01
&SignatureMethod=HmacSHA256
&Expires=2009-04-18T22%3A52%3A43PST
&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

<ChangeMessageVisibilityResponse>
    <ResponseMetadata>
        <RequestId>
            6a7a282a-d013-4a59-aba9-335b0fa48bed
        </RequestId>
    </ResponseMetadata>
</ChangeMessageVisibilityResponse>