19

With the introduction of FIFO queues in SQS we are guaranteed that SQS messages will be delivered in order.

Now, could there be an out-of-order delivery when I publish messages through SNS? Here's what I'm thinking that could happen:

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

Is that scenario possible?

Hammad Akhtar
  • 177
  • 12
jlhonora
  • 10,179
  • 10
  • 46
  • 70
  • 2
    SNS doesn't even support publishing to FIFO queues. – Mark B Dec 30 '16 at 00:07
  • @MarkB I see. So only direct publishing for fifo queues? – jlhonora Dec 30 '16 at 00:09
  • 3
    Ugh. ["Amazon SNS isn't currently compatible with FIFO queues."](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-subscribe-queue-sns-topic.html) – wrschneider Sep 20 '17 at 19:05
  • Did you work on it mate ? I have tried following this link "https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-subscribe-queue-sns-topic.html" but still cannot subscribe to SQS Fifo – user2627846 Feb 02 '18 at 07:32
  • It is possible [refer](https://stackoverflow.com/a/64550495/3303074) – Prasanth Rajendran Aug 15 '21 at 17:09

4 Answers4

19

This scenario is currently impossible because SNS is not compatible with FIFO SQS in AWS. It is only supported for standard queues. This is clearly mentioned in the AWS docs in this link, under special notes.

EDIT

It's also listed in the SNS FAQs, under Are Amazon SQS FIFO queues compatible with Amazon Simple Notification Service (SNS)?

The answer's still the same as of July 26, 2020: Amazon SNS does not currently support forwarding messages to Amazon SQS FIFO queues. You can use SNS to forward messages to standard queues.

osoclever
  • 373
  • 7
  • 16
Keet Sugathadasa
  • 11,595
  • 6
  • 65
  • 80
  • 1
    where's the link – LLL May 08 '18 at 14:22
  • 2
    the link has been added. Sorry for the inconvenience – Keet Sugathadasa May 08 '18 at 18:02
  • Is there any progress? I suppose that AWS is working on it to implement this functionality? How and where can I track this? – ielkhalloufi Jan 19 '19 at 13:55
  • @G.Mast Still AWS is not supporting this. Note that FIFO queues are not currently supported. Wonder whether someone has already addressed this with them. If anyone wants, they can request for features via the Developer Forum: https://forums.aws.amazon.com/forum.jspa?forumID=4 – Keet Sugathadasa Jan 19 '19 at 18:03
  • I had the same question. And as said [Keet Sugathadasa](https://stackoverflow.com/users/4388776/keet-sugathadasa), SNS isn't compatible with SQS Fifo just because what is indicated in the question would happen. I done a test with a SNS http that invoke to endpoint then its sent to SQS. Sent five messages to a topic of SNS (1,2,3,4,5) and was delivery (5,4,31,2). – carboleda Jul 25 '19 at 02:07
  • 4
    it's possible now https://aws.amazon.com/blogs/aws/introducing-amazon-sns-fifo-first-in-first-out-pub-sub-messaging/ – Ala' Alkhaldi Oct 22 '20 at 21:35
  • It is possible [refer](https://stackoverflow.com/a/64550495/3303074) – Prasanth Rajendran Aug 15 '21 at 17:09
16

SNS FIFO just launched. SNS can now integrate with SQS FIFO https://aws.amazon.com/blogs/aws/introducing-amazon-sns-fifo-first-in-first-out-pub-sub-messaging/

Marc Yu Yang
  • 196
  • 1
  • 4
  • 6
    So the answer is still NO. You can subscribe SQS FIFO queues to an SNS FIFO topic. It's still impossible to subscribe SQS FIFO queues to an SNS topic. – villasv Mar 16 '21 at 18:24
  • @villasv why do you want to use FIFO queue (guaranteed ordered) to subscribe to SNS topic (order non guaranteed). SNS FIFO topic has different architecture, limits, and pricing, it would not make sense to fix those two. If your system has a strict ordering use case, just use FIFO topics. – Marc Yu Yang Mar 15 '22 at 06:26
  • 2
    Because SQS FIFO queues have content-based deduplication, it was chosen even though order of delivery was not important. Good decision? Maybe not, but that's a different discussion. OP is not asking if this is a good architecture, he's asking if it's possible. "Just use FIFO topics" is not a useful answer. – villasv Mar 15 '22 at 18:03
4

It is possible with the latest SNS support for FIFO,

As per the excerpt from amazon doc

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

I have listed some important links for you to refer

  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

As your SNS topic protocol endpoint is Amazon SQS which perfectly works fine.

NOTE for other protocol endpoints 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.
Prasanth Rajendran
  • 4,570
  • 2
  • 42
  • 59
0

My team was also looking for SNS integration with SQS FIFO queue but unfortunately it's not compatible till now.

  • 1
    SNS FIFO just launched. SNS can now integrate with SQS FIFO https://aws.amazon.com/blogs/aws/introducing-amazon-sns-fifo-first-in-first-out-pub-sub-messaging/ – jlhonora Oct 22 '20 at 21:56
  • It is possible, for more please refer [answer](https://stackoverflow.com/a/64550495) – Prasanth Rajendran Mar 17 '21 at 08:48