amazon-web-servicesaws-lambdaamazon-sqs

Behavior of AWS Lambda Event Source Mapping after Re-enabling


I have an AWS Lambda function configured with an event source mapping from an SQS queue. I recently disabled the event source mapping using the update_event_source_mapping method with the Enabled parameter set to False. During this period of disablement, new messages were added to the SQS queue.

Now, I'm planning to re-enable the event source mapping using the same method with the Enabled parameter set to True. However, I'm unsure about the behavior of the Lambda function once re-enabled:

Will the Lambda function process the messages that were already in the queue during the period when the event source mapping was disabled? Or will it only process new messages added to the queue after re-enabling the event source mapping? I've gone through the AWS documentation, but I couldn't find a clear answer to this scenario. Could someone clarify how AWS Lambda handles event source mappings in this situation?

Any insights or guidance would be greatly appreciated. Thank you!


Solution

  • The event source mapper will read any message from the standard SQS queue and trigger the lambda function. It will not distinguish between new or prior to disabling. The retention period will determine which messages are still available to be processed. The default SQS retention is 4 days, configurable between 1 minute and 14 days.

    With a SQS FIFO queue you would be able to receive the last unprocessed message.

    Just in case there might have been messages lost or not processed correctly, due to the delay in disabling the event source mapping: take a look at the dead letter queue configured (DLQ) on the SQS. As this combination is called synchronous - the DLQ on the SQS will be used, instead of the Lambda’s DLQ.

    By the way, in February 2024 the responsiveness for queue-based event source was improved for updating, disabling, or deleting ESMs take effect within 90 seconds, an improvement from the previous time frame of up to 15 minutes. AWS Lambda improves responsiveness for configuring stream and queue-based event sources