将消息从 AWS SNS 发布到 SQS

Publishing messages from AWS SNS to SQS

由于 SQS 支持多个消费者并行处理消息存在限制。 IE。 m1 到 m10 由进程 1 选择,m11 到 m20 由进程 2 选择,依此类推。重复。由于 SQS 不支持,我正在考虑使用 SNS + SQS(订阅的队列列表),其中每个进程侦听其特定队列并处理记录。

是否可以在 SNS 和 SQS 之间设置类似循环的选项,以便 SNS 以循环方式将消息分发到 SQS,以便每个队列都有唯一的消息,而不会跨队列重复?

提前致谢!

此致, 库马尔

如果您不希望您的 SNS 发布到所有订阅者(队列),请查看 SNS Message Filtering。消息过滤允许您定义控制哪些订阅者接收给定消息的逻辑。

By default, a subscriber of an Amazon SNS topic receives every message published to the topic. 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. 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. If there is a match between the attributes, Amazon SNS sends the message to the subscriber. Otherwise, Amazon SNS skips the subscriber without sending the message to it. If a subscription lacks a filter policy, the subscription receives every message published to its topic.

除非您使用的是 SQS FIFO 队列,否则您关于 SQS 不支持多个并行消费者的限制的假设是不正确的

标准 SQS 确实支持多个并行使用者。

关于 SQS FIFO 队列,它们不会一次将来自同一消息组的消息提供给多个消费者。但是,如果您的 FIFO 队列有多个消息组,您可以利用并行使用者,允许 Amazon SQS 将来自不同消息组的消息提供给不同的使用者。