visibilityTimeout
The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage
request. If not specified, the default visibility timeout for the queue is used, which is 30 seconds.
Understanding VisibilityTimeout
:
When a message is received from a queue, it becomes temporarily invisible to other consumers for the duration of the visibility timeout. This prevents multiple consumers from processing the same message simultaneously. If the message is not deleted or its visibility timeout is not extended before the timeout expires, it becomes visible again and can be retrieved by other consumers.
Setting an appropriate visibility timeout is crucial. If it's too short, the message might become visible again before processing is complete, leading to duplicate processing. If it's too long, it delays the reprocessing of messages if the initial processing fails.
You can adjust the visibility timeout using the
--visibility-timeout
parameter in thereceive-message
command to match the processing time required by your application.A message that isn't deleted or a message whose visibility isn't extended before the visibility timeout expires counts as a failed receive. Depending on the configuration of the queue, the message might be sent to the dead-letter queue.
For more information, see Visibility Timeout in the Amazon SQS Developer Guide.