SQS Lambda 集成 - 抛出异常时会发生什么
SQS Lambda Integration - what happens when an Exception is thrown
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?
您的代码抛出 unhandled/uncaught 异常的那一刻 Lambda 失败。如果您将最大接收计数设置为 1,消息将在第一次失败后发送到 DLQ,不会重试。例如,如果您的最大接收计数设置为 5,那么在 Lambda 函数失败的那一刻,消息将在可见性超时到期后返回到队列。
此行为的原因是您授予 Lambda 代表您轮询队列的权限。如果它收到一条消息,它会调用一个函数并为您提供一次处理该消息的机会。如果您将消息 returns 发送到队列失败并且 Lambda 继续代表您轮询队列,则它不关心下一条消息是与失败消息相同还是全新的消息。
这是一篇很棒的博客 post,它帮助我了解了这些触发器的工作原理。
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?
您的代码抛出 unhandled/uncaught 异常的那一刻 Lambda 失败。如果您将最大接收计数设置为 1,消息将在第一次失败后发送到 DLQ,不会重试。例如,如果您的最大接收计数设置为 5,那么在 Lambda 函数失败的那一刻,消息将在可见性超时到期后返回到队列。
此行为的原因是您授予 Lambda 代表您轮询队列的权限。如果它收到一条消息,它会调用一个函数并为您提供一次处理该消息的机会。如果您将消息 returns 发送到队列失败并且 Lambda 继续代表您轮询队列,则它不关心下一条消息是与失败消息相同还是全新的消息。
这是一篇很棒的博客 post,它帮助我了解了这些触发器的工作原理。