是否可以集成 AWS SNS 和 AWS SQS FIFO 队列

Is it possible to integrate AWS SNS and AWS SQS FIFO queue

有了 introduction of FIFO queues in SQS,我们保证 SQS 消息将按顺序传递。

请问在SNS上发布消息会不会出现乱序的情况?以下是我认为可能发生的情况:

 _____                       _____                       __________
| App |-- Publish msg 1 --> | SNS | --> Queue msg 2 --> | FIFO SQS | --> Consume 2
|     |-- Publish msg 2 --> |     | --> Queue msg 1 --> |          | --> Consume 1
 -----                       -----                       ----------

这种情况可能吗?

这种情况目前是不可能的,因为 SNS 与 AWS 中的 FIFO SQS 不兼容。它仅支持标准队列。 this link 中的 AWS 文档在特别说明下明确提到了这一点。

编辑

它也列在 SNS FAQs 中,在 Are Amazon SQS FIFO queues compatible with Amazon Simple Notification Service (SNS)?

答案与 2020 年 7 月 26 日相同:Amazon SNS does not currently support forwarding messages to Amazon SQS FIFO queues. You can use SNS to forward messages to standard queues.

我的团队也在寻找 SNS 与 SQS FIFO 队列的集成,但不幸的是,它直到现在才兼容。

SNS FIFO 刚刚推出。 SNS 现在可以与 SQS FIFO 集成 https://aws.amazon.com/blogs/aws/introducing-amazon-sns-fifo-first-in-first-out-pub-sub-messaging/

最新的 SNS 对 FIFO 的支持是可能的,

根据亚马逊文档的摘录

FIFO topics support fanning out messages to multiple subscriptions with high durability, filtering, encryption, and privacy, while FIFO topics provide the added benefit of ordering and deduplication of message

我列出了一些重要的链接供您参考

  1. Amazon SNS introduces First-in-First-out (FIFO) topics with strict ordering and deduplication of messages
  2. Introducing Amazon SNS FIFO – First-In-First-Out Pub/Sub Messaging
  3. Building event-driven architectures with Amazon SNS FIFO

因为您的 SNS 主题协议端点是 Amazon SQS,它工作得很好。

其他协议端点的注意事项 Ref

  • Currently, the endpoint protocol must be Amazon SQS, with an Amazon SQS FIFO queue's Amazon Resource Name (ARN) as the endpoint.
  • SNS FIFO topics can't deliver messages to customer managed endpoints, such as email addresses, mobile apps, phone numbers for text messaging (SMS), or HTTP(S) endpoints. These endpoint types aren't guaranteed to preserve strict message ordering. Attempts to subscribe customer managed endpoints to SNS FIFO topics result in errors.