aws-lambdamoonmail

MoonMail: Re-invoking a Lambda send function


When there is a message in a user SQS queue, an alarm is triggered and an SNS notification starts the Lambda send email process. If the Lambda function throws an exception and does not re-invoke itself again to send the rest of the batch, how do you start the process again? SNS will only send notifications as the alarm state changes but in this case the state will remain the same.


Solution

  • You could set up a Dead Letter Queue, programmatically check what have caused the error and re-invoke the lambda if you wish. Anyway, keep in mind that the function executes recursively until the queue is empty, so if something is preventing the queue from being flushed and nothing halts the function it could keep executing over and over