简体   繁体   English

将消息从AWS SNS发布到SQS

[英]Publishing messages from AWS SNS to SQS

As there is a limitation on SQS to support multiple consumers to process messages in parallel. 由于SQS受到限制,无法支持多个使用者并行处理消息。 ie. 即。 m1 to m10 picked by process 1 and m11 to m20 picked by process 2 and so on.. with duplication. 由过程1选择的m1至m10和由过程2选择的m11至m20,依此类推。 Since this is not supported by SQS, I am thinking of using SNS + SQS (list of queues subscribed), where each process listens to its specific queue and processes records. 由于SQS不支持此功能,因此我考虑使用SNS + SQS(已订阅队列列表),其中每个进程都侦听其特定的队列并处理记录。

Is there an option to set between SNS and SQS like round-robin so that SNS distributes messages to SQS in a round robin fashion, So that each queue would have unique messages without duplication across queues? 是否可以在SNS和SQS之间设置诸如循环的选项,以便SNS以循环方式将消息分发到SQS,以便每个队列将具有唯一的消息而不会在队列之间重复?

Thanks in advance! 提前致谢!

Regards, Kumar 问候,库玛

If you don't want your SNS publish to go to all subscribers (queues), look in to SNS Message Filtering . 如果您不希望SNS发布到所有订阅者(队列),请查看SNS消息过滤 Message filtering allows you to define logic controlling which subscribers receive a given message. 消息过滤使您可以定义控制哪些订户接收给定消息的逻辑。

By default, a subscriber of an Amazon SNS topic receives every message published to the topic. 默认情况下,Amazon SNS主题的订阅者会收到发布到该主题的每条消息。 To receive only a subset of the messages, a subscriber assigns a filter policy to the topic subscription. 为了只接收消息的子集,订阅者将过滤策略分配给主题订阅。

A filter policy is a simple JSON object. 过滤策略是一个简单的JSON对象。 The policy contains attributes that define which messages the subscriber receives. 该策略包含定义订户接收哪些消息的属性。 When you publish a message to a topic, Amazon SNS compares the message attributes to the attributes in the filter policy for each of the topic's subscriptions. 当您将消息发布到主题时,Amazon SNS会将消息属性与每个主题的订阅的过滤器策略中的属性进行比较。 If there is a match between the attributes, Amazon SNS sends the message to the subscriber. 如果属性之间匹配,则Amazon SNS会将消息发送给订阅者。 Otherwise, Amazon SNS skips the subscriber without sending the message to it. 否则,Amazon SNS会跳过订户而不向其发送消息。 If a subscription lacks a filter policy, the subscription receives every message published to its topic. 如果订阅缺少过滤策略,则订阅将接收发布到其主题的每条消息。

Unless you are using SQS FIFO queues, your assumption about the limitation of SQS not supporting multiple parallel consumers is not correct 除非您使用SQS FIFO队列,否则关于SQS的局限性不支持多个并行使用者的假设是不正确的

Standard SQS do support multiple parallel consumers. 标准SQS确实支持多个并行使用者。

Regarding the SQS FIFO queues they don't serve messages from the same message group to more than one consumer at a time. 关于SQS FIFO队列,它们一次不将来自同一消息组的消息提供给一个以上的使用者。 However, if your FIFO queue has multiple message groups, you can take advantage of parallel consumers, allowing Amazon SQS to serve messages from different message groups to different consumers. 但是,如果您的FIFO队列具有多个消息组,则可以利用并行使用者,从而允许Amazon SQS将来自不同消息组的消息提供给不同的使用者。

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

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