Marketplace Application
A company wants to build an online marketplace application on AWS as a set of loosely coupled microservices. For this application, when a customer submits a new order, two microservices should handle the event simultaneously. The Email microservice will send a confirmation email, and the OrderProcessing microservice will start the order delivery process. If a customer cancels an order, the OrderCancellation and Email microservices should handle the event simultaneously. A solutions architect wants to use Amazon Simple Queue Service (Amazon SQS) and Amazon Simple Notification Service (Amazon SNS) to design the messaging between the microservices. How should the solutions architect design the solution?
Create an SNS topic with SQS queues subscribed using message filtering.
Why this works best:
SNS enables simultaneous message delivery to multiple subscribers (fan-out)
SQS queues ensure reliable message processing for each microservice
Message filtering lets each queue receive only relevant events
The binding happens during queue subscription to the SNS topic. Here's how:
Using AWS Console:
Go to SQS Queue -> Subscribe to SNS topic
Add subscription filter policy in JSON format
Using AWS CLI:
Using AWS CDK:
Loose coupling maintained between services
Architecture:
SNS topic receives all order events
Three SQS queues subscribe with filters:
Email queue: receives all events
OrderProcessing: new orders only
OrderCancellation: cancellations only
Potential Improvements
There are several potential improvements:
Event Router Pattern:
Benefits: Better event filtering, reduced SNS costs
Direct Integration:
Benefits: Simpler, cost-effective for single consumers
EventBridge Pattern:
Benefits:
Better event filtering
Content-based routing
Schema validation
Dead-letter queues
Replay capabilities
EventBridge would be ideal here because:
Native CloudEvents support
Better filtering capabilities
Built-in error handling
Event archiving and replay
Direct Lambda integration
Last updated
Was this helpful?