gpt4 book ai didi

amazon-web-services - SQS Lambda 集成 - 抛出异常时会发生什么

转载 作者:行者123 更新时间:2023-12-05 02:14:11 28 4
gpt4 key购买 nike

The document states that

A Lambda function can fail for any of the following reasons:

The function times out while trying to reach an endpoint.

The function fails to successfully parse input data.

The function experiences resource constraints, such as out-of-memory errors or other timeouts.

就我而言,我使用的是 C# Lambda 与 SQS 集成

If the invocation fails or times out, every message in the batch will be returned to the queue, and each will be available for processing once the Visibility Timeout period expires

我的问题:如果我使用 SQS Lambda 集成 (.NET) 会怎样

  • 我的函数抛出异常
  • 我的 SQS 可见性计时器设置为 15 分钟,最大接收计数为 1,DLQ 设置

函数会重试吗?是否会在所有重试后抛出异常时放入DLQ?

最佳答案

当您的代码抛出未处理/未捕获的异常时,Lambda 失败。如果您将最大接收计数设置为 1,消息将在第一次失败后发送到 DLQ,不会重试。例如,如果您的最大接收计数设置为 5,那么在 Lambda 函数失败的那一刻,消息将在可见性超时到期后返回到队列。

此行为的原因是您授予 Lambda 代表您轮询队列的权限。如果它收到一条消息,它会调用一个函数并为您提供一次处理该消息的机会。如果您失败,消息返回到队列并且 Lambda 继续代表您轮询队列,它不关心下一条消息是与失败的消息相同还是全新的消息。

这是一个很棒的博客 post这帮助我了解了这些触发器的工作原理。

关于amazon-web-services - SQS Lambda 集成 - 抛出异常时会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53922247/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com