简体   繁体   English

在 AWS 中订阅 SNS 到 SQS?

[英]Subscribing SNS to SQS in AWS?

Looking at this image :看着这张图片:

在此处输入图片说明

The messages are really imporant hence I use a queue in the middle.这些消息非常重要,因此我在中间使用了一个队列。 But now - On the right side SNS , I need to have multiple subscribers ( Lambdas).但是现在 - 在右侧 SNS 上,我需要有多个订阅者(Lambdas)。

But now, How can I subscribe the right side SNS to the SQS on the center ?但是现在,如何将右侧的 SNS 订阅到中心的 SQS?

Question:题:

Is it possible to subscribe SNS to SQS ?是否可以将 SNS 订阅到 SQS? ( meaning - passing the messages from SQS to an SNS) (意思是 - 将消息从 SQS 传递到 SNS)

SNS is a topic, it does not subscribe to anything. SNS 是一个主题,它不订阅任何内容。 It cannot receive data, it needs to be published to.它无法接收数据,需要发布到。

However, you can publish to it from an application code.但是,您可以从应用程序代码发布到它。 For this, you can attach a consumer to your SQS in the middle.为此,您可以在中间将消费者附加到您的 SQS。 This could be a Java application or a simple lambda code.这可以是 Java 应用程序或简单的 lambda 代码。

Here are a few references for doing it in various languages.以下是一些用各种语言进行操作的参考资料。

  1. Java and .NET Java 和 .NET
  2. Python Python
  3. Node JS 节点JS

First of all create a new Lambda function to send message to a SNS topic .首先创建一个新的 Lambda 函数来向 SNS 主题发送消息。 Refer this - https://github.com/aws-samples/serverless-app-examples/tree/master/python/step-functions-send-to-sns参考这个 - https://github.com/aws-samples/serverless-app-examples/tree/master/python/step-functions-send-to-sns

And then you can configure your queue to trigger that Lambda function on receiving of payload.然后您可以配置您的队列以在接收有效负载时触发该 Lambda 函数。

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

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