Amazon Simple Queue Service
API Reference (API Version 2012-11-05)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.

ChangeMessageVisibility

Description

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 you have a message and its default message visibility timeout is 30 minutes. You could call ChangeMessageVisiblity with a value of two hours and the effective timeout would be two hours and 30 minutes. When that time comes near you could again extend the time out by calling ChangeMessageVisiblity, but this time the maximum allowed timeout would be 9 hours and 30 minutes.

Note

There is a 120,000 limit for the number of inflight messages per queue. Messages are inflight after they have been received from the queue by a consuming component, 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.

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

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

For information about the common parameters that all actions use, see Common Parameters.

QueueUrl

The URL of the Amazon SQS queue to take action on.

Type: String

Required: Yes

ReceiptHandle

The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.

Type: String

Required: Yes

VisibilityTimeout

The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.

Type: Integer

Required: Yes

Errors

For information about the errors that are common to all actions, see Common Errors.

MessageNotInflight

The message referred to is not in flight.

HTTP Status Code: 400

ReceiptHandleIsInvalid

The receipt handle provided is not valid.

HTTP Status Code: 400

Examples

The following example Query request changes the visibility timeout for a message to 60 seconds. How you structure the AUTHPARAMS depends on how you are signing your API request. For information on AUTHPARAMS in Signature Version 4, go to Examples of Signed Signature Version 4 Requests.

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=2012-11-05
&Expires=2012-04-18T22%3A52%3A43PST
&AUTHPARAMS

      

Sample Response

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