1

If Service1 wants to send a command asynchronously towards a service2, which would be ideal:

service1 -> sns -> sqs -> service2

or

service1 -> sqs -> service2

What would be the basis on deciding on this?

1

2 Answers 2

3

If you want your command to be received by only one consumer use SQS.

If you want it to be received by many consumers publish your command to SNS and subscribe with SQS. Many different subscription types are available in addition to SQS e.g. Lambda, Email, Webhook etc.

In both cases commands (or messages) will be delivered asynchronously.

If you want only a single consumer and also ordered delivery you can use FIFO SQS queues. Ordered delivery cannot be achieved with SNS + SQS.

Sign up to request clarification or add additional context in comments.

1 Comment

> If you want only a single consumer and also ordered delivery you can use FIFO SQS queues. Ordered delivery cannot be achieved with SNS + SQS. Why do you say this? Both SQS and SNS support FIFO, so if you connect a FIFO Topic to a FIFO queue it should be ordered delivery? This might be outdated part of the answer since support for this launched later in 2020 aws.amazon.com/blogs/aws/…
3

Amazon SQS will not "deliver" a message. Rather, the application needs to poll SQS to request a message.

Thus, if you wish to "push" a message to your application, then Amazon SNS is more appropriate, but it will not queue messages.

Some people prefer to implement the first option since other consumers can be added with no change to existing code or configuration. The new consumers would simply subscribe to the existing Amazon SNS topic.

However, if you know for sure that there will never be another consumer, then you could feel comfortable going direct to an Amazon SQS queue.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.