简体   繁体   English

在SQS收到来自SNS的消息后触发AWS Lambda

[英]Trigger AWS Lambda after SQS has received message from SNS

I am facing the problem of how to trigger a Lambda function after a message has been written in a SQS queue which is a SNS subscriber. 我面临的问题是,在将消息写入SNS订阅者的SQS队列中之后如何触发Lambda函数。

I know there is this useful post but I have not really understood how to publish a second message (on topic B) after the first one has been successfully sent (on topic A). 我知道有这个有用的帖子,但我还没有真正理解如何发布第二消息(在主题B)后的第一个已经发送成功(在主题A)。 I did not know if it is the right answer. 我不知道这是否是正确的答案。

Here below there is a diagram of what I would link to implement 下面是我要实现的链接的图表

在此处输入图片说明

As you can see there is an API which publish to an SNS topic. 如您所见,有一个发布到SNS主题的API。 The subscribers of this topic should be: 该主题的订阅者应为:

  1. An SQS queue where a message is stored 存储消息的SQS队列
  2. A Lambda function which has to been triggered by SNS to consume the message written to the queue. Lambda函数,必须由SNS触发才能使用写入队列的消息。

The problem I am facing is how to be sure the lambda is executed after a message has been written in the queue and how to really implement the solution. 我面临的问题是如何确保在将消息写入队列后执行lambda,以及如何真正实现解决方案。 How to publish two topic and from one writing message in SQS and from the other one trigger the queue (how can be sure the message has been effectively written in the queue?). 如何发布两个主题,并从SQS中的一条消息中发布消息,而从另一条消息中触发发布消息队列(如何确保消息已被有效地写到队列中?)。

Thank you very much guys, hope I was clear enough. 非常感谢你们,希望我足够清楚。

Add the lambda to the topic as a subscriber. 将lambda作为订阅者添加到主题。 As soon as a message is published to the topic,lambda will be triggered. 一旦消息发布到该主题,lambda就会被触发。 If you have an SQS queue as a subscriber to the topic, then the message will be queued there too.. 如果您有SQS队列作为该主题的订阅者,则该消息也将在那里排队。

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

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