0

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.

Julian
  • 8,808
  • 8
  • 51
  • 90
  • What exception it's being thrown? The most common exceptions are being handled, but if an unexpected exception occurs the whole process stops to prevent the lambda from ending up in an infinite loop – davids Feb 20 '17 at 08:31
  • @davids, the exception being thrown is completely my fault. I cloned the repo, deployed, and tweaked Moonmail in order to study it and learn it better. But my question still remains. What if the exception only happened on an edge case and stopping lambda wasn't the desired behaviour? What if Lambda itself fails with something out of my control and I want to re-trigger it? My question was not geared towards "there's a bug in Moonmail" but rather towards a "what if" regarding the architectrure resilience. – Julian Feb 20 '17 at 15:03
  • In that case you could set up a [Dead Letter Queue](http://docs.aws.amazon.com/lambda/latest/dg/dlq.html), 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 – davids Feb 20 '17 at 15:44
  • @davids, that could work. By the way, I don't see a dead letter queue in Moonmail. Is that how yo do it there? In your experience has this problem ever happened? – Julian Feb 20 '17 at 16:24
  • Actually, we haven't bumped into that issue yet. I'm gonna add the previous comment as an answer – davids Feb 20 '17 at 17:24

1 Answers1

0

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

davids
  • 6,259
  • 3
  • 29
  • 50