Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Amazon Simple Notification Service overview
2.1.
SNS subscribers and publishers
3.
How does Amazon SNS work?
4.
Getting started with Amazon Simple Notification Service
5.
Creating a topic
5.1.
Creating a subscription to the topic
5.2.
Publishing a message on the topic
6.
Features of Amazon Simple Notification Service
7.
Benefits of Amazon Simple Notification Service
8.
Frequently Asked Questions
8.1.
What are the different topic types in Amazon SNS?
8.2.
Can many users publish the same topic?
8.3.
Will I receive messages in the order in which they were published?
9.
Conclusion
Last Updated: Mar 27, 2024

Amazon Simple Notification Service

Author Prerna Tiwari
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

AWS is one of the world's most popular cloud service companies. Many companies use AWS to store and manage their data in the cloud. AWS provides customers with various services that help them securely store and manage their data. One such service is Amazon simple notification service. Let us learn more about it.

AWS is intended to enable application providers, ISVs, and vendors to quickly and securely host their applications, whether they are existing or new SaaS-based applications. To access AWS's application hosting platform, you can use the AWS Management Console or well-documented web services APIs.

The Amazon Web Services portfolio includes over 100 services, including compute, databases, infrastructure management, application development, and security. These services are classified as follows:

  • Compute
  • Storage databases
  • Data management
  • Migration
  • Cloud hybrid
  • Networking
  • Tools for development
  • Management
  • Monitoring
  • Security
  • Governance
  • Big data management
  • Analytics
  • AI
  • Mobile application development
  • Notifications and messages

Amazon Simple Notification Service overview

Amazon Simple Notification Service (Amazon SNS) helps us to set up, operate, and send messages using a publish/subscribe model on the cloud. It allows users to push messages to Windows, Google, and Apple using an API or AWS management console. It is a completely managed messaging service for application-to-application (A2A) and application-to-person (A2P) communication. 

Amazon SNS adheres to the "publish-subscribe" (pub-sub) communications paradigm, with alerts given to clients using a "push" technique that eliminates the need to check or "poll" for new information and changes regularly. 

Amazon SNS provides developers with an easy way to include a robust notification system into their applications. Simple APIs require no up-front development work, maintenance or administrative costs, and pay-as-you-go pricing.

SNS subscribers and publishers

SNS publishers: The Amazon SNS (Simple Notification Service) publisher receives Amazon SNS topic notifications and publishes them to FME Server topics.

SNS subscribers: Amazon SNS (Simple Notification Service) subscribers get subject alerts and post them to Amazon SNS topics. Amazon SNS topics, like FME Server Notification Service topics, serve as entry points for subscribers to register for alerts and publishers to deliver messages.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

How does Amazon SNS work?

Amazon SNS is quite simple to use. 

  • To publish messages and allow clients to subscribe to alerts, developers must first construct a "topic," which is an "access point" defining a certain subject or event type. 
  • After creating a topic, the subject owner can define its policies, such as who can publish messages or subscribe to alerts or which notification protocols will be supported (e.g., HTTP/HTTPS, Email, SMS). 
  • Subscribers are clients who want to be notified about subjects of interest; they can subscribe to a topic or be subscribed to by the topic owner. Subscribers indicate the protocol and Endpoint (URL, email address, etc.) to which alerts should be sent. 
  • When publishers have information or changes to share with their subscribers, they can publish a message to the subject, which immediately sends it to all relevant subscribers.
    Also see, Amazon Hirepro

Getting started with Amazon Simple Notification Service

Creating a topic

  1. Log in to your Amazon SNS console.
  2. Select Topics from the left navigation window.
  3. Select Create subject from the Topics page.
  4. The console produces a FIFO topic by default. Select Standard.
  5. Enter a name for the subject in the Details area, such as MyTopic.
  6. Scroll to the bottom of the form and select Create topic.
  7. The Details page for the newly formed subject is displayed in the console.

Creating a subscription to the topic

  1. Select Subscriptions from the left navigation pane.
  2. Select Create subscription from the Subscriptions page.
  3. Choose the Topic ARN field on the Create subscription page to get a list of the subjects in your AWS account.
  4. Select the subject you established in the preceding step.
  5. Select Email as the protocol.
  6. Enter an email address that may receive alerts for Endpoint.
  7. Select Create subscription.
  8. The console displays the new subscription's Details page.
  9. Check the email inbox and click Confirm subscription in the AWS Notifications email. Typically, the sender ID is "no-reply@sns.amazonaws.com."
  10. Amazon SNS opens your browser and displays a subscription confirmation page with the subscription ID.

Publishing a message on the topic

  1. Select Topics from the left navigation window.
  2. Select the subject you established previously on the Topics page, and then select Publish message.
  3. The console displays the page Publish message to the topic.
  4. Enter a Subject in the Message Details field, such as 
     

                  Welcome to Coding Ninjas!

It is an optional step and is just done here for testing.

5. Choose the Identical payload for all delivery methods in the Message body box, and then add a message body, such as
 

                      Publishing message to SNS topic.


6. Select Publish message.

7. The message is published to the subject, and the console displays the Details page for the topic.

8. Examine your inbox to see if you received an email from Amazon SNS with the published message.

Features of Amazon Simple Notification Service

  1. Sources and destinations for events
    Event-driven computing is a computing model in which subscriber services perform work automatically in response to events triggered by publisher services. This paradigm can be used to automate workflows while decoupling the services that work together and separately to fulfill these workflows. Amazon SNS is an event-driven hub that integrates natively with a wide range of AWS event sources and destinations.
     
  2.  Message publishing and batching
    Message publishing allows you to send data in the form of messages to an Amazon SNS topic, which then delivers the messages to applications that have subscribed to the topic asynchronously. Per API request, you can publish up to ten messages. You can reduce your Amazon SNS costs by batching messages together. Each message can hold up to 256KB of information. If your use case necessitates larger data payloads, the Amazon SNS Extended Client Library can store the payload up to 2GB in the Amazon S3 bucket and publish the Amazon S3 object reference to the Amazon SNS topic. 
     
  3. Message filtration
    Message filtering allows your subscriber applications to create filter policies, allowing them to receive only the notifications that they are interested in, rather than every message published on the topic. You can simplify your architecture by offloading message filtering logic from subscriber applications and message routing logic from publisher applications.
     
  4. Message fanout and delivery
    When a message to a topic is published, Amazon SNS replicates it and distributes it to applications that have subscribed to the topic. Amazon SNS supports message delivery from application to application (A2A) and application to person (A2P). Amazon SNS also supports cross-region and cross-account message delivery, as well as Amazon CloudWatch message delivery status logging.
     
  5. Message durability
    Amazon SNS employs a number of mechanisms that work in tandem to ensure message durability. To begin, published messages are stored across multiple servers and data centers that are geographically separated. When a subscribed endpoint is unavailable, Amazon SNS implements a message delivery retry policy. You can use a dead-letter queue powered by Amazon SQS to save any messages that aren't delivered before the delivery retry policy expires. 
     
  6. Encryption of messages
    Amazon SNS offers encrypted topics to keep your messages safe from unauthorized and anonymous access. When you publish messages to encrypted topics, Amazon SNS encrypts them immediately. The encryption occurs on the server, and it employs a 256-bit AES-GCM algorithm and a Customer Master Key (CMK) issued by AWS Key Management Service (KMS). Messages are encrypted and delivered to subscribing endpoints such as Amazon SQS queues, Amazon Kinesis Data Firehose streams, AWS Lambda functions, HTTP/S endpoints, phone numbers, mobile apps, and email addresses. 
     
  7. Message confidentiality
    AWS PrivateLink allows Amazon SNS to support VPC Endpoints (VPCE). You can use VPC Endpoints to publish messages to Amazon SNS topics without leaving your Amazon Virtual Private Cloud (VPC) privately. This feature adds security, promotes data privacy, and aligns with assurance programs. AWS PrivateLink eliminates the need for an Internet Gateway (IGW), Network Address Translation (NAT), or Virtual Private Network (VPN) connection. You are also not required to use public IP addresses.
     
  8. Text messages (SMS)
    Amazon SNS allows you to send SMS text messages to 200+ countries at scale, using a highly available and durable service with redundancy across multiple SMS providers. You can control your originating identity with Amazon SNS by using a sender ID, long codes, or shortcodes. You can also use the Amazon SNS sandbox to test your SMS workloads before deploying them to production.
     
  9. Push notifications for mobile devices
    Amazon SNS mobile notifications make it easy and inexpensive to distribute mobile push notifications to iOS, Android, Fire, Windows, and Baidu devices. User-driven actions or business logic can both mobile trigger notifications. Amazon SNS sends push notifications to mobile devices via Amazon Device Messaging (ADM), Apple Push Notification Service (APNs), Baidu Cloud Push (Baidu), Firebase Cloud Messaging (FCM), Microsoft Push Notification Service for Windows Phone (MPNS), and Windows Push Notification Services (WNS).
     
  10. Notifications via Email
    Amazon SNS allows you to send notifications to email addresses that have subscribed to topics. This feature is useful in a variety of situations. You can, for example, use Amazon SNS to receive application alerts as email notifications in order to gain visibility into your DevOps workflows. As a result, you can receive immediate notification when an event occurs, such as a specific change to your Amazon EC2 Auto Scaling group, a new file uploaded to your Amazon S3 bucket, or a metric threshold breached in Amazon CloudWatch.

Benefits of Amazon Simple Notification Service

Amazon SNS provides various advantages that make it a versatile choice for developing and integrating loosely linked distributed applications:

  • Simplify and reduce costs with message filtering and batching APIs that are easy to use and integrate with apps
  • Ensure accuracy with message ordering and deduplication
  • Increase security with message encryption and privacy
  • Increase durability with message archiving, delivery retries, and DLQ
  • Capture and fan out events from AWS services
  • Send A2P notifications via SMS, mobile push, and Email.

Frequently Asked Questions

What are the different topic types in Amazon SNS?

There are two types of topics in Amazon SNS:-

  1. Standard topics
    Standard topics can be used in a variety of scenarios, as long as your application can process messages that arrive multiple times and in a random order, such as fanning out messages to media encoding, fraud detection, tax calculation, search index, and critical alerting applications.
     
  2. FIFO topics
    FIFO topics are intended to improve messaging between applications when the order of operations and events is critical, or duplicates are not tolerated, such as when fanning out messages to bank transaction logging, stock monitoring, flight tracking, inventory management, and price update applications.

Can many users publish the same topic?

A topic owner can grant explicit access to multiple users (with a valid AWS ID) to publish to a subject. Only topic owners have the ability to publish to a topic by default.

Will I receive messages in the order in which they were published?

The Amazon SNS service will try to send messages from the publisher in the order in which they were published in the subject. However, network difficulties may cause out-of-order messages at the subscriber end.

Conclusion

In this article, we have extensively discussed the concepts of Amazon Simple Notification Service. We started with getting an overview of Amazon SNS. After that, we talked about its work, and then we created and published an Amazon SNS topic. We also learned about the features of Amazon SNS and finally concluded with the benefits of Amazon SNS.

You can also refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingSystem Design, and many more! You may also check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! For placement preparations, you must look at the problemsinterview experiences, and interview bundle.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Happy Coding!

Previous article
Amazon MQ
Next article
Amazon Simple Queue Service
Live masterclass