简体   繁体   English

AWS 中将消息从 SNS 发送到 SQS FIFO 的替代方法是什么?

[英]What is an alternative in AWS for sending message from SNS to SQS FIFO?

I have this situation where I am using Amazon SNS + SQS in order to handle domain events.我有这种情况,我使用 Amazon SNS + SQS 来处理域事件。

Basically on domain event I publish a message to SNS and two SQS queues are subscribed to SNS.基本上在域事件中,我向 SNS 发布消息,并且两个 SQS 队列订阅了 SNS。 Since i noticed SQS supports FIFO, but SNS doesn't support FIFO, I am trying to find a resolution on how to simultaneously deliver message A to multiple SQS FIFO queues?由于我注意到 SQS 支持 FIFO,但 SNS 不支持 FIFO,我试图找到一个解决方案来解决如何同时将消息 A 传递到多个 SQS FIFO 队列?

What I had so far到目前为止我所拥有的

  • Publish Message A to SNS将消息 A 发布到 SNS
  • Distribute Message A to SQS 1 and SQS 2将消息 A 分发到 SQS 1 和 SQS 2

All I can think of now is我现在能想到的只有

  • Publish message A to SQS A将消息 A 发布到 SQS A
  • Use code to pull message A from SQS and publish it to SQS 1 and SQS 2使用代码从 SQS 拉取消息 A 并发布到 SQS 1 和 SQS 2

Not really an atomic process I was looking for...不是我正在寻找的原子过程......

Is there an alternative to this approach?这种方法有替代方法吗?

Today, we launched Amazon SNS FIFO topics, which can fan out messages to multiple Amazon SQS FIFO queues!今天,我们推出了 Amazon SNS FIFO 主题,它可以将消息扇出到多个 Amazon SQS FIFO 队列!

https://aws.amazon.com/about-aws/whats-new/2020/10/amazon-sns-introduces-fifo-topics-with-strict-ordering-and-deduplication-of-messages/ https://aws.amazon.com/about-aws/whats-new/2020/10/amazon-sns-introduces-fifo-topics-with-strict-ordering-and-deduplication-of-messages/

You can think about using the AWS Kinesis Data stream .您可以考虑使用AWS Kinesis Data stream One feature of it is an ordering .它的一个特点是ordering

From faq: https://aws.amazon.com/kinesis/data-streams/faqs/来自常见问题解答:https://aws.amazon.com/kinesis/data-streams/faqs/

When should I use Amazon Kinesis Data Streams, and when should I use Amazon SQS?什么时候应该使用 Amazon Kinesis Data Streams,什么时候应该使用 Amazon SQS?

Ordering of records.记录排序。 For example, you want to transfer log data from the application host to the processing/archival host while maintaining the order of log statements.例如,您希望将日志数据从应用程序主机传输到处理/归档主机,同时保持日志语句的顺序。

You can process events from Kinesis to SQSs.您可以处理从 Kinesis 到 SQS 的事件。

If your goal is to have a message be pushed to two Amazon SQS FIFO queues, I'd recommend:如果您的目标是将消息推送到两个 Amazon SQS FIFO 队列,我建议:

  • Have Amazon SNS trigger an AWS Lambda functionAmazon SNS触发 AWS Lambda function
  • The Lambda function can send the same message to both Amazon SQS queues Lambda function可以向两个Amazon SQS 队列发送相同的消息

It is effectively doing the fan-out via Lambda rather than SNS.通过 Lambda 而不是 SNS 有效地进行扇出

The Lambda function might also be able to extract a Message Group ID that it can provide with the SQS message, which will enable parallel processing of messages while maintaining FIFO within the message group. Lambda function 还可以提取它可以与 SQS 消息一起提供的消息组 ID ,这将启用消息的并行处理,同时在消息组中保持 FIFO。 For example, all messages coming from a particular source will be FIFO, but can be processed in parallel with messages from other sources.例如,来自特定来源的所有消息都是 FIFO,但可以与来自其他来源的消息并行处理。 It's a very powerful capability that would not be available just by having Amazon SNS forward the message.这是一项非常强大的功能,仅通过让 Amazon SNS 转发消息是无法实现的。

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

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