带有SQS触发器的AWS Lambda,SQS Lambda目标,永不添加到目标队列 [英] AWS Lambda w/ SQS trigger, SQS Lambda Destinations, never adds to destination queue

查看:357
本文介绍了带有SQS触发器的AWS Lambda,SQS Lambda目标,永不添加到目标队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的lambda函数,该函数是从SQS队列触发的,并且正在使用新的 Lambda Destinations 功能.

I have a simple lambda function that is triggered from a SQS queue and I'm using the new Lambda Destinations functionality.

已设置为从QUEUE_A触发,对有效载荷主体进行一些修改,然后在成功上将其发送到QUEUE_B,或在失败上将其发送到QUEUE_ERRORS强>.

It is set up to trigger from QUEUE_A, do some modification of the payload body, then send it to QUEUE_B on success, or QUEUE_ERRORS on failure.

QUEUE_BQUEUE_ERRORS在lambda函数上设置为目的地.

QUEUE_B and QUEUE_ERRORS are set up as Destinations on the lambda function.

当我从CLI触发lambda时,我在QUEUE_B上获得了一条记录良好的记录,而在QUEUE_ERRORS上获得了一条不良记录的记录.因此,它似乎正在工作.

When I trigger the lambda from the CLI, I get a record on QUEUE_B with a good record, and on QUEUE_ERRORS on a bad record. So, it seems to be working.

但是,当从SQS触发lambda时,我从不QUEUE_BQUEUE_ERRORS上获得记录.好的记录会运行lambda,而坏的记录会转到QUEUE_A_DEADLETTER,我不希望这样做.

But, when the lambda is triggered from SQS, I never get a record on QUEUE_B or QUEUE_ERRORS. A good record runs the lambda, and on a bad record it goes to QUEUE_A_DEADLETTER, which I do not want.

我尝试将QUEUE_A配置为不重试/删除邮件-如果这样做,则在不良记录上,它将永远重试(无论我将可见性/重试设置为多么低).

I have tried configuring QUEUE_A to have no retry/deadletter - if I do that, on a bad record it will just retry forever (no matter how low I set the visibility/retries).

接下来我可以尝试什么?

What can I try next?

编辑:
CloudWatch确实向我展示了我期望看到的内容-我在好"记录上看到了良好的日志,在坏"记录上看到了堆栈跟踪/异常,因此在函数本身AFAIK中这不是问题.

EDIT:
CloudWatch shows me exactly what I expect to see - I see good logs on a "good" record, and stack traces/exceptions on "bad" records, so it is not a problem within the function itself AFAIK.

编辑: 正在使用SNS触发器和目标替换SQS触发器和目标.那么,我认为这与SQS同步和SNS异步相关?有人知道吗?

EDIT: Replacing the SQS triggers and destinations with SNS triggers and destinations are working. So, I think this is related to SQS being sync and SNS being async? Does anybody know?

推荐答案

如果您同步调用Lambda函数,则不会触发目的地.您可以阅读这篇文章以获得更好的主意.

Destinations will not be triggered if you invoke the Lambda function synchronously. You can read this article to get a better idea.

Destinations的主要用例是了解Lambda函数的异步执行结果,主要是为了更深入地了解执行细节,例如请求和响应上下文,有效负载,异常堆栈跟踪等.因此,如果Lambda是同步调用的(例如,使用cli或通过SQS触发器),则不会将任何邮件传递到Destinations端点.

The primary use case of Destinations is to know about the async execution results of Lambda functions, primarily to get more visibility into the execution details like request and response contexts, payloads, exception stack traces etc. So if a Lambda was invoked synchronously (say, using cli or via an SQS trigger), no messages will be delivered to the Destinations endpoints.

使用CLI时,您将使用aws lambda invoke-async.相反,如果您使用aws lambda invoke(它同步执行Lambda),您将看到相同的问题,目标端点将不会收到此消息.

When you used the CLI you would have used aws lambda invoke-async. Instead if you use aws lambda invoke (which executes Lambda synchronously), you will see the same problems, your destination endpoints will not receive the message.

您可以将Destinations端点保持为SQS(您将在上面的文章中看到一个有效的示例),但是Lambda触发器将不得不更改为异步触发器.

You can keep your Destinations endpoints still as SQS (you will see a working example in the article above), but your Lambda trigger will have to change to an asynchronous one.

这篇关于带有SQS触发器的AWS Lambda,SQS Lambda目标,永不添加到目标队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆