SetVisibilityTimeout (SOAP)

Sets the VisibilityTimeout, which controls how long a message is hidden from a ReceiveMessage request. Once a message is returned to an initial ReceiveMessage request, it will not be returned on subsequent ReceiveMessage requests for the duration of the VisibilityTimeout period. Once that duration has passed, the message will again be returned to a ReceiveMessage request unless it is deleted from the queue.

Messages that are meant to be received only once should be deleted using DeleteMessage within the duration of the VisibilityTimeout.

The VisibilityTimeout value is set for all messages in the queue. It cannot be set for a specific message.

Visibility Timeout

For example, message A is in a queue and has a visibility timeout set at 30 seconds. A ReceiveMessage request is made on that queue, and message A is returned. A subsequent ReceiveMessage request is made in 10 seconds (within the span of the VisibilityTimeout of 30 seconds), and so message A is not returned to that request. Another request is made 20 seconds after the first request. Message A is again not returned. After the visibility timeout expires (after 30 seconds), and until message A is deleted from the queue, message A will be available to be returned by any ReceiveMessage request.

The following criteria are validated in a SetVisibilityTimeout request.

Returns Success if successful or an error code if unsuccessful.

NameDescriptionTypeValue
VisibilityTimeout Required. The duration, in seconds, that messages are hidden from subsequent read requests after they've been retrieved by a ReceiveMessage request.Integer0 to 86400 seconds (maximum 24 hours)

The following example sets the visibility timeout to 35 seconds for all messages in the specified queue.

ErrorDescription
InvalidParameterValue VisibilityTimeout was not an integer between 0 and 86400.
InvalidURIThe URL for the queue is not valid or was not a URL returned by a CreateQueue or ListQueues request.