- 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"
- Visual C++程序設(shè)計(jì)學(xué)習(xí)筆記
- Getting started with Google Guava
- Cassandra Design Patterns(Second Edition)
- TypeScript實(shí)戰(zhàn)指南
- HTML5與CSS3基礎(chǔ)教程(第8版)
- SSM開(kāi)發(fā)實(shí)戰(zhàn)教程(Spring+Spring MVC+MyBatis)
- 移動(dòng)互聯(lián)網(wǎng)軟件開(kāi)發(fā)實(shí)驗(yàn)指導(dǎo)
- Spring技術(shù)內(nèi)幕:深入解析Spring架構(gòu)與設(shè)計(jì)原理(第2版)
- Isomorphic JavaScript Web Development
- 區(qū)塊鏈原理、架構(gòu)與應(yīng)用(第2版)
- MongoDB進(jìn)階與實(shí)戰(zhàn):微服務(wù)整合、性能優(yōu)化、架構(gòu)管理
- JavaScript實(shí)戰(zhàn)-JavaScript、jQuery、HTML5、Node.js實(shí)例大全(第2版)
- 軟件測(cè)試實(shí)用教程
- Python學(xué)習(xí)手冊(cè)(原書(shū)第4版)
- 架構(gòu)寶典