- Newest
- Most votes
- Most comments
The visibility timeout is the period of time during which a message is invisible to other consumers after it has been read from the queue. Setting the visibility timeout to 0 means the message is immediately visible to other consumers again.
When a Lambda function is triggered by an SQS queue, it reads messages and attempts to process them. If the visibility timeout is set to 0, the message becomes available for other consumers (or the same consumer) immediately after it is read, leading to potential reprocessing of the same message before the deletion request is processed.
There might be a slight delay between when the Lambda function deletes the message and when the deletion is acknowledged by SQS. During this period, the message can be reprocessed by the Lambda function because it is still visible.
Setting the visibility timeout to 0 causes messages to be immediately visible to other consumers, leading to repeated processing. Increase the visibility timeout to a value greater than 0 to ensure messages are not reprocessed before they are deleted. Ensure proper deletion logic in your Lambda function to handle messages efficiently.
To sum up, setting the visibility timeout to 0 is generally not recommended as it can lead to repeated message processing. A higher visibility timeout value helps ensure that messages are processed and deleted properly, avoiding unnecessary reprocessing.
The problem is that there is not "a slight delay". The message keeps being received for the whole lifetime of the message, i.e. 1 minute in my case, despite being deleted. So that is not a feature, that is a bug in my opinion.
Relevant content
- asked a year ago
please accept the answer if it was useful