SQS

Queues

Queues are places where you send and from where applications are consuming messages. A message can stay in the queue until it is consumed or a timeout occurs. Timeout periods are configurable.

Messages

Messages are the content or the payload of the data that is send to the queue which needs to be processed by other services or applications. Usually the format of a message is in JSON format.

Polling

Polling is the mechanism by which the consumer of the queue is processing the messages from it.

When to use it

SQS can be used when the consumer is only one because the message will be removed from the queue once polled. (verify this claim) When we need the messages to persist in the queue until a consumer polls the queue to process the message Async communication between application services Temporary message holding 1:1 reliable communication rate limit the consumption of messages Ordered message processing SNS (Simple Notification Service)

Topics

Topics are similar to queues, the place where the messages are published. The difference is that they don’t have state. They don’t keep messages. A copy of a message in a topic is broadcasted to all recipients subscribed to the topic.

Messages

messages are JSON objects that contain the payload data. During publishing identical message is published to each subscriber for consumption.

Publish/Subscribe (Pub/Sub)

The application or person who is owning the data is the topic owner or the publisher. On the other hand the application or person who consumes the data is the consumer or the subscriber.

When to use it

Use it when we need multiple recipients for our messages. Can configure different services as subscribers. Very common practice is to use SNS + SQS for delivering messages to application or service. 1 to many Fanout distribution

Eventbridge

Newer service compared to SQS and SNS.

Message Bus - similar to SNS topics in way that they receive events that need to be broadcasted to consumers.

Events - similar to messages. They contain information that describes the source and the payload data. Events can also be scheduled to run at periodic intervals using cron expressions.

Targets - recipients of the events that are published to the message bus.

Rules - rules define certain conditions which if are met within the event data will broadcast the message to the configured targets. This is done by defining the Event Pattern.

When to use it

Use when we want to execute functionality at a periodic interval If we have third party integrations Stripe Shopify We need Schema Registry/Discovery developers need to know what to expect and how to parse the message.

References

https://www.beabetterdev.com/2021/09/10/aws-sqs-vs-sns-vs-eventbridge/