AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Changes the visibility timeout of a specified message in a queue to a new value. The maximum allowed timeout value is 12 hours. Thus, 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, see Visibility Timeout in the Amazon SQS Developer Guide.

For example, you have a message and with the default visibility timeout of 5 minutes. After 3 minutes, you call ChangeMessageVisiblity with a timeout of 10 minutes. At that time, the timeout for the message is extended by 10 minutes beyond the time of the ChangeMessageVisibility action. This results in a total visibility timeout of 13 minutes. You can continue to call the ChangeMessageVisibility to extend the visibility timeout to a maximum of 12 hours. If you try to extend the visibility timeout beyond 12 hours, your request is rejected.

A message is considered to be in flight after it's received from a queue by a consumer, but not yet deleted from the queue.

For standard queues, there can be a maximum of 120,000 inflight messages per queue. If you reach this limit, Amazon SQS returns the OverLimit error message. To avoid reaching the limit, you should delete messages from the queue after they're processed. You can also increase the number of queues you use to process your messages.

For FIFO queues, there can be a maximum of 20,000 inflight messages per queue. If you reach this limit, Amazon SQS returns no error messages.

If you attempt to set the VisibilityTimeout to a value greater than the maximum time left, Amazon SQS returns an error. Amazon SQS doesn't automatically recalculate and increase the timeout to the maximum remaining time.

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

Note:

This is an asynchronous operation using the standard naming convention for .NET 4.5 or higher. For .NET 3.5 the operation is implemented as a pair of methods using the standard naming convention of BeginChangeMessageVisibility and EndChangeMessageVisibility. For Unity the operation does not take CancellationToken as a parameter, and instead takes AmazonServiceCallback<ChangeMessageVisibilityRequest, ChangeMessageVisibilityResponse> and AsyncOptions as additional parameters.

Namespace: Amazon.SQS
Assembly: AWSSDK.SQS.dll
Version: 3.x.y.z

Syntax

C#
public abstract Task<ChangeMessageVisibilityResponse> ChangeMessageVisibilityAsync(
         String queueUrl,
         String receiptHandle,
         Int32 visibilityTimeout,
         CancellationToken cancellationToken
)
Parameters
queueUrl
Type: System.String

The URL of the Amazon SQS queue whose message's visibility is changed. Queue URLs are case-sensitive.

receiptHandle
Type: System.String

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

visibilityTimeout
Type: System.Int32

The new value for the message's visibility timeout (in seconds). Values values: 0 to 43200. Maximum: 12 hours.

cancellationToken
Type: System.Threading.CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Return Value
The response from the ChangeMessageVisibility service method, as returned by SQS.

Exceptions

ExceptionCondition
MessageNotInflightException The message referred to isn't in flight.
ReceiptHandleIsInvalidException The receipt handle provided isn't valid.

Version Information

.NET Standard:
Supported in: 1.3

.NET Framework:
Supported in: 4.5

Portable Class Library:
Supported in: Windows Store Apps
Supported in: Windows Phone 8.1
Supported in: Xamarin Android
Supported in: Xamarin iOS (Unified)
Supported in: Xamarin.Forms

Unity:
Supported Versions: 4.6 and above
Supported Platforms: Android, iOS, Standalone

See Also