- Building Serverless Web Applications
- Diego Zanon
- 267字
- 2021-07-15 17:31:30
Amazon SNS
Amazon Simple Notification Service (SNS) implements the publish-subscribe messaging pattern. When you create an SNS topic, it becomes available for other services to subscribe to it. If someone publishes a message in this topic, all subscribed services will be alerted.
It's a very simple and powerful service. You can use it to dynamically attach different services that are able to handle a specific kind of notification. For example, an application can send a notification to an SNS topic to alert that you have received a new file to process. You can subscribe to this topic using an HTTP endpoint and SNS will send a message to your web service with the file location that needs processing. Later, you can add another endpoint, using a Lambda function programmed to do another kind of processing.
Let's perform the following steps to create a simple demo using the CLI as an example:
- Create an SNS topic using the following command line:
aws sns create-topic --name email-alerts
- The result is an Amazon Resource Name (ARN) that you need to save. The ARN will be created with a format of this example: arn:aws:sns:us-east-1:1234567890:email-alerts
- Subscribe to a topic using the e-mail protocol, so you will receive an e-mail every time that an application publishes to this topic:
aws sns subscribe --topic-arn the_previous_arn --protocol email \
--notification-endpoint myemail@example.com
- Open your e-mail account and confirm that you want to subscribe to events.
- Publish a test message and see it working by using the following command line:
aws sns publish --topic-arn the_previous_arn --message "test"
- Android Jetpack開發:原理解析與應用實戰
- Angular UI Development with PrimeNG
- Computer Vision for the Web
- Visual Studio 2012 Cookbook
- PostgreSQL for Data Architects
- 小創客玩轉圖形化編程
- Java加密與解密的藝術(第2版)
- Implementing Cisco Networking Solutions
- 零基礎學Java(第4版)
- Bootstrap Essentials
- Mastering Predictive Analytics with Python
- Yocto for Raspberry Pi
- Hands-On Natural Language Processing with Python
- Python算法從菜鳥到達人
- Learning Salesforce Einstein