Amazon SNS (Amazon Simple Notification Service), a managed service, delivers messages from publishers to subscribers (also known by producers and consumers). Publishers communicate with subscribers asynchronously through sending messages to a topic. This topic serves as a logical entry point and communication channel for subscribers. Subscribers can subscribe to the SNS topic to receive published messages via any supported endpoint including Amazon Kinesis Data Firehose and Amazon SQS.
What is Amazon SNS?
The Simple Notification Service (Amazon SNS), is used to send push notifications to subscribers or other programs. It is a fully messaging service that allows communication between people and applications (A2A). It allows you to create a Topic. This serves as a logical connection point and communication channel. Each subject is given a unique name which identifies the SNS endpoint from where publishers can post messages. Subscribers can subscribe to receive notifications.
AmazonSimple Notification Service Feature
Automatic Scaling: It scales automatically as the number of messages increases. Message Encryption – This protects your messages against unwelcome and unknown access by using encrypted topics. They are encrypted as messages are sent to subscribing endspoints.
Message Filtering allows subscribers to modify their filter policies so that they only receive alerts that are relevant to them.
When a message has been sent to a topic it is replicated and push to multiple endpoints. This is known as message fanout. Fanout provides asynchronous event alerts, which allow for parallel processing.
Mobile Notification: It can trigger from user-initiated actions in an app or cloud-based business logic. Mobile push notifications for iOS, Android Fire OS Windows, and Baidu-based phones are easy to distribute.
SNS & E-mail Messages: Amazon SNS allows you to send text messages and emails (SMTP).
Types of SNS Topics
There are two types of SNS Topics.
How does AWS SNS function?
AWS SNS uses the Publisher-Subscriber paradigm to send messages to its endpoints. You can filter messages to a larger number of subscribers or endpoints via mobile communications, SMS and email using Amazon SNS.
Publishers, also known by the term producer, create and send messages through the AWS SNS service.
Subscribers receive the published messages from the SNS service using supported network protocols like Amazon SQS, AWS Lambda or HTTP/ HTTPS.
These are the exact steps that AWS SNS uses:
The publisher first sends the notices to subscribers.
The messages are sent to the SNS service. It consists of the following components. SNS Topic – This is used for filtering messages that must be distributed among subscribers. You must first create an SNS topic for your subscriber access point as an AWS developer. Subscribers can use the topic to receive message notifications about their chosen topic.
Subscribers receive the message via subscribing queues and microservices. Subscribers must provide valuable information, such as a URL address or email address. Here are some of the most popular forms of SNS messages. Application and system alerts are automatic user notifications that trigger by predefined thresholds and are sent to specific users via SMS or email.
Push email and text messaging are two ways to communicate with people or groups (example: news article notifications sent out to newspaper subscribers).
Mobile push notifications are messages sent directly from mobile apps to notify them about app updates.
How does Amazon SNS message filtering function?
Let’s take a look at how Amazon SNS uses message filtering to only deliver a subset SNS topic messages to subscribing endspoints. Let’s take, for instance, a company website which sends user questions to many backend server.
This server network consists of:
First, 1 server will handle “type 1” user requests
Second, 1 server will handle requests of type 2 from users
1 server for data analysis that handles both type 1 and type 2 user requests
These are the six steps to implement message filtering with Amazon SNS.
Create an Amazon SNS Topic
First, create an Amazon SNS topic. This topic will send messages to users whenever they make a request on the site.
Register with your username, password, and login to the AWS Management Console.
Use the “AWS Services Search Box” to locate the Amazon SNS service console.
Click “Start With an Overview” on the SNS console’s landingpage, then “Topics” from the left side menu.
Next, click “Create topic” in the dialogue box. Type the topic name (“Topic 1”) into the “Topic name” field (shown below).
Click “Create topic” to add a topic to the “Topics” details page.
Create the Amazon SQS Queues
Next, create the Amazon SQS queues which will be subscribed for the SNS topic. The website backend servers collect user requests from the corresponding SQS message queue. This is an example: Queue_1 handles requests from users of “type 1”.
Queue_2 responds to user requests for “type 2”.
Queue_3 can handle user requests of “type 1” or “type 2”.
Register with your username & password to log in to the AWS SQLS Console
Next, enter “Queue 1” in the “Queue Name” box on the “Create New Queue” page. Click “Quick-Create Queue”, with the “Standard” option selected. Next, type “Queue 1” in the “Queue Name” box. Repeat step b to create two new queues. After they have been created, all three SQS queues will be listed in the SQS console.
Subscribe to the Queues for the Topic
This step is required in order to subscribe to the Amazon SNS topic’s freshl