Lambda不会在dlq中放入消息 [英] Lambda does not put message in dlq
问题描述
我只是想测试Lambda的DLQ,我并没有说明为什么消息没有出现在其中.我的代码只做1件事throw new Exception("Test");
.
I just trying to test my DLQ for Lambda and I do not undesrtand why messages does not put on it. My code just doing 1 thing throw new Exception("Test");
.
第一个错误是可以理解的,我试图使用按钮Test
同步执行此操作.之后,我设置了Kinesis
并开始在其上发送消息,但是没有任何变化.在CloudWatch metrics
的监视页面上,我看到Errors, Availability
中有一些错误,但是DeadLetterErrors
中没有任何错误.
The first mistake was understandable, I was trying to do this synchronously using button Test
. After that I setup Kinesis
and started sending message on it but nothing changed.On monitoring page on CloudWatch metrics
I saw that there were several errors in Errors, Availability
but there were no errors in DeadLetterErrors
.
对于创建的DLQ,这只是简单的标准队列,而无需更改配置.
As for DLQ which was created this is just simple standard queue with no changes in configuration.
预先感谢您的帮助
推荐答案
- 使用Kinesis流触发lambda意味着您正在使用同步调用.但是,DLQ仅可用于用于Kinesis和DynamoDB事件源的新错误处理机制.
- Using Kinesis streams to trigger lambda means that you are using synchronous invocation. However, DLQ is only available for asynchronous invocations.
- The good news is that in November 2019, AWS published new error handling mechanisms for Kinesis and DynamoDB event source.
- 转到lambda函数
- 点击
Add Destination
按钮 - 选择流调用
- 根据故障条件选择
- 选择SQS队列作为目标,并将其指向要使用的SQS,例如DLQ.
- Go to the lambda function
- Click on the
Add Destination
button - Select Stream invocation
- Select on failure condition
- Select SQS queue as the destination and point it to the SQS that you want to use like a DLQ.
使用此功能,您可以配置发生故障时的目标.此目标可以是SNS主题,SQS队列,另一个lambda函数或EventBridge事件总线.
With this feature, you can configure a destination on failure. This destination can be an SNS topic, SQS queue, another lambda function, or an EventBridge event bus.
要通过控制台界面添加此内容,
For adding this through the console UI,
For adding it through cloudformation, follow this documentation.
I'll provide a basic example for the trigger that you need to attach to your lambda function:
LambdaTrigger:
Type: AWS::Lambda::EventSourceMapping
Properties:
FunctionName: !GetAtt Lambda.Arn
EventSourceArn: !GetAtt Kinesis.Arn
DestinationConfig:
OnFailure:
Destination: !GetAtt DLQ.Arn
这篇关于Lambda不会在dlq中放入消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!