Lambda 将 ErrorMessage 添加到 SQS 消息
Lambda adding ErrorMessage to SQS message
我有一个基本的 SQS 队列触发 Lambda,它有一个重新驱动策略,在 5 次重试后将失败的消息发送到 DLQ。 I read that Lambda should add message attributes about the error to the message
一切都按预期工作,除了当我查看 DLQ 中的消息时,我没有看到来自 Lambda 的任何 ErrorCode、ErrorMessage 属性。有人让这个工作吗?
您混淆了两个不同功能的行为。
一个SQS队列可以有一个死信队列。
When the ReceiveCount
for a message exceeds the maxReceiveCount
for a queue, Amazon SQS moves the message to a dead-letter queue (with its original message ID).
Lambda 函数也可以有死信队列。
Any Lambda function invoked asynchronously is retried twice before the event is discarded. If the retries fail and you're unsure why, use Dead Letter Queues (DLQ) to direct unprocessed events to an Amazon SQS queue or an Amazon SNS topic to analyze the failure.
...
The payload written to the DLQ target ARN is the original event payload with no modifications to the message body. The attributes of the message contain information to help you understand why the event wasn’t processed
您拥有的是前者——带有 DLQ 的 SQS 队列,而不是后者——带有 DLQ 的 Lambda 函数。
在您的配置中,根据重新驱动策略,消息将按照描述直接移动到 DLQ,无需修改。
无法在侦听 SQS 队列的 Lambda 函数的 DLQ 中收到您正在寻找的消息,因为 SQS/Lambda 集成不使用异步函数调用。
Lambda polls the queue and invokes your function synchronously with an event that contains queue messages.
无法以其他方式配置 SQS/Lambda 集成,使用 DLQ(而不是 SQS 队列)配置 Lambda 函数本身将无效。
解决方法是使用 CloudWatch logs for your Lambda function 查找有问题的消息。在代码中记录 SQS MessageId,以便稍后在日志中找到它。
我有一个基本的 SQS 队列触发 Lambda,它有一个重新驱动策略,在 5 次重试后将失败的消息发送到 DLQ。 I read that Lambda should add message attributes about the error to the message
一切都按预期工作,除了当我查看 DLQ 中的消息时,我没有看到来自 Lambda 的任何 ErrorCode、ErrorMessage 属性。有人让这个工作吗?
您混淆了两个不同功能的行为。
一个SQS队列可以有一个死信队列。
When the
ReceiveCount
for a message exceeds themaxReceiveCount
for a queue, Amazon SQS moves the message to a dead-letter queue (with its original message ID).
Lambda 函数也可以有死信队列。
Any Lambda function invoked asynchronously is retried twice before the event is discarded. If the retries fail and you're unsure why, use Dead Letter Queues (DLQ) to direct unprocessed events to an Amazon SQS queue or an Amazon SNS topic to analyze the failure.
...
The payload written to the DLQ target ARN is the original event payload with no modifications to the message body. The attributes of the message contain information to help you understand why the event wasn’t processed
您拥有的是前者——带有 DLQ 的 SQS 队列,而不是后者——带有 DLQ 的 Lambda 函数。
在您的配置中,根据重新驱动策略,消息将按照描述直接移动到 DLQ,无需修改。
无法在侦听 SQS 队列的 Lambda 函数的 DLQ 中收到您正在寻找的消息,因为 SQS/Lambda 集成不使用异步函数调用。
Lambda polls the queue and invokes your function synchronously with an event that contains queue messages.
无法以其他方式配置 SQS/Lambda 集成,使用 DLQ(而不是 SQS 队列)配置 Lambda 函数本身将无效。
解决方法是使用 CloudWatch logs for your Lambda function 查找有问题的消息。在代码中记录 SQS MessageId,以便稍后在日志中找到它。