Lesson 3 of 3 Serverless and API Architecture

Choosing Event-Driven Integration Services

This lesson explains how to choose between similar-looking messaging services for event-driven integration, from routing needs, ordering, throughput, replay and the number of consumers each message needs.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between SQS, SNS, EventBridge and Kinesis.
  • Explain how messages are fanned out and filtered.
  • Explain how FIFO services preserve order and remove duplicates.
  • Describe EventBridge archive and replay and other features.

Choosing a messaging service

Each messaging service follows a different model. Amazon SQS is a queue in which each message is processed by one consumer, which suits buffering work, smoothing load and retrying with a DLQ. Amazon SNS pushes each message to many subscribers, queues, Lambda, HTTP, email and SMS, with simple filtering on attributes. Amazon EventBridge is an event bus whose rules match any field of the event content. It receives events from SaaS applications and AWS services, supports buses in other accounts, and can archive and replay events.

Kinesis Data Streams provides ordered, replayable streams per shard, for high throughput with several consumers reading the same data, kept for up to 365 days. Amazon MSK runs Apache Kafka for existing Kafka applications. Amazon MQ runs ActiveMQ or RabbitMQ, so applications using JMS, AMQP or MQTT migrate without code changes. The following table summarises the services.

ServiceModelChoose it when
Amazon SQSQueue: each message processed by one consumerBuffering work, smoothing load, retries with a DLQ
Amazon SNSPub/sub push to many subscribersFan-out to queues, Lambda, HTTP, email and SMS; simple attribute filtering
Amazon EventBridgeEvent bus with content-based rulesRouting on any event field, SaaS and AWS service events, cross-account buses, archive and replay
Kinesis Data StreamsOrdered, replayable stream per shardHigh-throughput streams, multiple consumers reading the same data, replay up to 365 days
Amazon MSKManaged Apache KafkaExisting Kafka applications and ecosystems
Amazon MQManaged ActiveMQ or RabbitMQMigrating applications that use JMS, AMQP or MQTT without code changes

Fan-out and filtering

The classic fan-out is SNS to several SQS queues, giving each consumer its own buffer and retry. Subscription filter policies deliver only matching messages to each queue. EventBridge achieves the same with one rule per consumer, matching on any field in the event body, and can transform the event for each target. Choose EventBridge when routing logic is rich or events come from AWS services and SaaS partners; choose SNS for very high fan-out throughput and push to mobile, SMS or email.

Ordering and exactly-once processing

Only a few services guarantee order. SQS FIFO queues and SNS FIFO topics preserve order within a message group and remove duplicates sent within a five-minute window, and Kinesis preserves order within a shard, determined by the partition key. Choosing the group ID or partition key as the entity whose events must stay in sequence, such as an order ID, keeps that order while still processing different entities in parallel.

Everything else delivers at least once and without guaranteed order, so consumers must be idempotent: processing a message twice must have the same effect as processing it once. A consumer records the IDs of events it has processed, for example with a DynamoDB conditional write that fails if the ID already exists, or uses the idempotency utility of Powertools for AWS Lambda.

Useful EventBridge features

Several EventBridge features recur in architecture scenarios. Archive and replay keeps events and sends them again later, which rebuilds state after a consumer bug or tests a new consumer with real events. Cross-account and cross-Region buses send events to a central bus in another account or Region, controlled by the receiving bus's resource policy, which is how organisations build central operations and security buses.

EventBridge Pipes connect a polled source, such as SQS, Kinesis, DynamoDB Streams or MSK, through optional filtering and enrichment to a target, replacing Lambda functions whose only job is to move data. EventBridge Scheduler runs millions of one-time or recurring schedules with time zones, retries and dead-letter queues, replacing cron on servers. The schema registry discovers the structure of events on a bus and generates code bindings, which helps teams that consume events they did not produce.

Worked example

When an order is placed, a company must update inventory, send a confirmation email and start fraud checks for orders above $1,000. New consumers will be added often by other teams in other accounts. Events must be replayable if a consumer has a bug.

Content-based routing (orders above $1,000), consumers in other accounts and replay all point to EventBridge: publish OrderPlaced to a bus, give each team a rule (with a numeric filter for fraud), allow their accounts in the bus policy, and enable an archive. SNS could fan out but lacks archive and replay; Kinesis offers replay but no content routing and more operational work.

Check yourself

How can SNS deliver messages in order and without duplicates?

Show answer

With an SNS FIFO topic delivering to SQS FIFO queues, using message group IDs for ordering and deduplication IDs to remove duplicates.

Exam Tips

Remember for the exam

  • SQS buffers work for one consumer; SNS and EventBridge fan out to many.
  • EventBridge: content-based rules, AWS and SaaS sources, cross-account buses, archive and replay.
  • Kinesis: ordered per shard, multiple consumers, replay; MSK for existing Kafka.
  • Amazon MQ migrates JMS, AMQP or MQTT applications without code changes.
  • Only FIFO queues and topics deduplicate; elsewhere make consumers idempotent.
  • EventBridge Pipes replaces glue Lambda functions between sources and targets.