Amazon SNS

How to Implement the Pub/Sub Pattern with .NET, Amazon SNS and CloudEvents

There is no shortage of technologies that allow for building pub-sub messaging systems. Off the cuff, I can think of NServiceBus, Azure Service Bus, RabbitMQ, MassTransit, etc. However, Amazon Simple Notification Service or SNS, may be the easiest to implement as well as the most flexible solution.  

What Exactly is the Pub-Sub Pattern?

In essence, the pub-sub pattern or publish-subscribe pattern, is a messaging pattern in software architecture where a publisher creates a message and sends it to a predetermined location for one or more subscribers to consume. The predetermined location has different names and has differing structures in different systems. However, in this tutorial we will refer to that predetermined location as a “topic”. To look at it from the consumer’s perspective, a consumer would subscribe to a topic of interest and when the publisher publishes a message to the topic, the consumer and any other subscribed consumers would receive the message.

Create an SQS Queue and an SNS Topic and Subscription using the AWS CLI

AWS gives engineers many ways to accomplish many tasks. Here we will look at creating both a Simple Notification Service topic as well as a Simple Queue Service queue and then creating an SNS subscription “linking” the two. All the while, we will exclusively use the AWS CLI to accomplish the task. This exercise could also be carried out in  the AWS console as well as one of the AWS SDKs and if you are proficient in an AWS SDK or the console, feel free to use one of those tools to view the changes being made while we move through this solution.

3 Things: Developing with Amazon SNS

Amazon Simple Notification Service, AKA SNS, is a versatile pub/sub AWS service that supports several different endpoints including, SMS, email and HTTP/HTTPS. Amazon SNS also supports AWS services as endpoints, like Amazon SQS, AWS Lambda and AWS Kenesis Data Firehouse. Amazon Simple Notification Service, which is often leveraged to do the heavy lifting in a fan-out pattern, provides a simplified path for creating pub/sub based applications without having to set up tons of infrastructure. Even with this simplified path, there are a few things that every developer should know before they start their Amazon SNS journey.