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.
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.
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.
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.ChangeMessageVisibility
action.Namespace: Amazon.SQS.Model
Assembly: AWSSDK.dll
Version: (assembly version)
public class ChangeMessageVisibilityRequest : AmazonSQSRequest IRequestEvents
The ChangeMessageVisibilityRequest type exposes the following members
Name | Description | |
---|---|---|
![]() |
ChangeMessageVisibilityRequest() | Empty constructor used to set properties independently even when a simple constructor is available |
![]() |
ChangeMessageVisibilityRequest(string, string, int) | Instantiates ChangeMessageVisibilityRequest with the parameterized properties |
Name | Type | Description | |
---|---|---|---|
![]() |
QueueUrl | System.String |
Gets and sets the property QueueUrl.
The URL of the Amazon SQS queue to take action on. |
![]() |
ReceiptHandle | System.String |
Gets and sets the property ReceiptHandle.
The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action. |
![]() |
VisibilityTimeout | System.Int32 |
Gets and sets the property VisibilityTimeout.
The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout. |
This example shows how to change message visibility.
var client = new AmazonSQSClient(); var url = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue"; // Receive messages. var rcvRequest = new ReceiveMessageRequest { AttributeNames = new List<string>() { "All" }, QueueUrl = url }; var rcvResponse = client.ReceiveMessage(rcvRequest); // Change visibility timeout for each message. if (rcvResponse.Messages.Count > 0) { foreach (var message in rcvResponse.Messages) { var visRequest = new ChangeMessageVisibilityRequest { QueueUrl = url, ReceiptHandle = message.ReceiptHandle, VisibilityTimeout = (int)TimeSpan.FromMinutes(10).TotalSeconds }; client.ChangeMessageVisibility(visRequest); } } else { Console.WriteLine("No messages to change visibility for."); }
.NET Framework:
Supported in: 4.5, 4.0, 3.5
.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8
.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8