且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有 SQS 触发器的 AWS Lambda,SQS Lambda 目的地,从不添加到目的地队列

更新时间:2022-11-05 15:40:55

如果您同步调用 Lambda 函数,将不会触发目标.

Destinations will not be triggered if you invoke the Lambda function synchronously.

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

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.

您可以将目的地端点保持为 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.