amazon-web-servicesaws-lambdabatch-processingamazon-sqsaws-sqs-fifo

Making SQS message visible again using partial batch response


Assuming:

When Lambda returns a partial batch response with ids of the failed messages, e.x.:

{
    "batchItemFailures": [
        {
            "itemIdentifier": "d4c7c57f-c12c-4639-abe3-3a0d37690790"
        }
    ]
}

The successfully processed messaged are deleted from the queue. However, the failed messages from the batch are still waiting for the visibility timeout instead of being made visible to the consumers immediately. Is the behaviour for failed messages correct? Or the only way to make them visible immediately is to call SQS API and change visibility timeout to 0?


Solution

  • While I cant speak for a FIFO SQS queue, I can say that I am seeing this behavior with a Standard SQS queue.

    I assumed that items returned in the batchItemFailures would immediately be set to visible, but they do indeed seem to remain in flight until their VisibilityTimeout expires.

    My solution was to manually change the message visibility timeout to 0 via the SQS API before returning the batchItemFailures.