简体   繁体   English

调用后AWS Lambda到SNS的响应

[英]AWS Lambda to SNS response after invocation

Lambda L1 is subscribed to SNS S1. Lambda L1已订阅SNS S1。

L1 returns the status code and a message every time it is invoked L1每次被调用时都会返回状态码和一条消息

I can check L1 response every time it is invoked independently but when I invoke L1 by publishing a message to S1, how can I verify the message returned from L1? 我可以在每次独立调用L1响应时对其进行检查,但是当我通过向S1发布消息来调用L1时,如何验证从L1返回的消息?

I need to do this programmatically in java.. Any pointers are appreciated 我需要在Java中以编程方式执行此操作。

Amazon SNS publishes messages to subscribers. Amazon SNS将消息发布给订阅者。 Once a message is successfully sent to a subscriber (eg to AWS Lambda to trigger a Lambda function), it does not wait for a response. 一旦消息成功发送给订阅者(例如,发送给AWS Lambda以触发Lambda函数),它就不会等待响应。

Therefore, it is not possible to view the response code of a Lambda function triggered by SNS. 因此,不可能查看由SNS触发的Lambda函数的响应代码。

You could look in the CloudWatch Log that is generated by the Lambda function, but you might need to insert code to push the response to the log (eg via a Print statement). 您可以查看由Lambda函数生成的CloudWatch Log,但是您可能需要插入代码以将响应推送到日志(例如,通过Print语句)。

In SNS trigger or any other asynchronous trigger, there isn't any 'server' that receives the return value of the Lambda. 在SNS触发器或任何其他异步触发器中,没有任何“服务器”接收Lambda的返回值。

For that reason, the Dead Letter Queue is a feature that makes it possible to handle errors in such a case, and it might be what you are looking for. 因此, “死信队列”是一项可以在这种情况下处理错误的功能,这可能正是您要寻找的。

If you wish to verify every message returned (and not only failures of the Lambda), you may have it configured to send the return message to another queue (SNS/SQS) and use another Lambda to make the verification. 如果您希望验证返回的每个消息(不仅是Lambda的失败),则可以将其配置为将返回消息发送到另一个队列(SNS / SQS),并使用另一个Lambda进行验证。

If you just look for monitoring your application (so you don't have any immediate action to take place in a verification failure), you may look for a monitoring solution - whether configuring CloudWatch metrics, Sentry or another. 如果您只是希望监视您的应用程序(因此在验证失败时没有任何立即采取的措施),则可能会寻找监视解决方案-无论是配置CloudWatch指标, Sentry还是其他。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM