SQS Lambda - retry logic?

后端 未结 4 1189
忘了有多久
忘了有多久 2021-02-12 22:21

When the message has been added to an SQS queue and it is configured to trigger a lambda function (nodejs).

When a lambda function is triggered - I may want to retry sa

4条回答
  •  孤街浪徒
    2021-02-12 22:38

    Fairly simple (if you execute the Lambda in a Async way) and without the need to do any coding. First of all: if you code will throw an error, AWS Lambda will retry 3 more times to execute you code. In this case if the external API was not accessible, there is a big change that by the third time AWS retries – the API will work. Plus the delay between the re-tries is random-ish meaning, there a is a delay between the re-tries.

    If the worst happens, and the external API is not yet up, you can take advantage of the dead-letter queue (DLQ) feature that each lambda have. Which will push to SQS a message saying what went wrong, so you can take additional actions. In this case, keep re-trying until you make it.

    You can read more here: https://docs.aws.amazon.com/lambda/latest/dg/dlq.html

提交回复
热议问题