Understanding Amazon SNS (Simple Notification Service) Architecture: For .NET Developers
Amazon SNS for .NET Developers.
Messaging and Notifications are pretty crucial in Distributed Systems. Here is how Notifications work in AWS World using Amazon SNS (Simple Notification Service)
👉 Amazon SNS Topics are logical access points, to which systems can push messages or subscribe.
👉 The Publisher, which can be a part of a distributed system, microservices, or another AWS Service first sends a notification to the Amazon SNS Topic. For example, in a Product Management Microservice Application, when there is a new Product Created, the product microservice will send a new notification with the subject "ProductCreatedNotification" and Message Payload as the product metadata to SNS Topic.
👉 Amazon SNS, which is a fully managed AWS PubSub Service, sends the message to all the clients that have subscribed to this particular SNS Topic.
👉 Amazon SNS supports Subscription protocols like AWS Lambda, Amazon SQS, Kinesis Firehose, Email, and HTTP(s) endpoints. This means that whenever there is a new notification, the message will be sent to the configured set of subscribers.
👉By default, when there is a new message, all the subscribers can receive it. To filter out certain messages, AWS supports the SNS filter policy at the Subscriber level, where the Subscriber can choose what message to receive based on attributes.
👉 This is a FanOut process, meaning all the subscribers will get the messages from the SNS Topic.
👉 In cases where Amazon SNS is not able to push a message to a Subscriber, it retries for the defined amount of time, after which the message is completely discarded.
👉 To preserve the failed message, you can connect a Dead Letter Queue to the SNS Subscription. So, whenever there is a failure, and the retry count is exhausted, the message is pushed to a SQS Queue where it can be analyzed and reprocessed.
I have written an entire article about SNS for .NET Developers. Here is the link to my blog post: https://codewithmukesh.com/blog/scalable-notifications-with-amazon-sns-and-aspnet-core/
Here is what you will learn from my article:
👉What is Amazon SNS, or Simple Notification Service?
👉Amazon SNS vs SQS
👉PubSub Architecture with Amazon SNS
👉Creating an Amazon SNS Topic via .NET
👉Publishing the Message to the SNS Topic via .NET
👉Email Subscription
👉Lambda Subscription
👉Amazon SNS Filter Policy
👉Retries & Dead Letter Queues
You can analyze the article, and decide where Amazon SNS can be a perfect fit for your distributed .NET application.
Image Credits: AWS