1
00:00:00,270 --> 00:00:06,870
In this video we are going to publish message to the topic on Amazon since using database libraries.

2
00:00:07,140 --> 00:00:13,650
So we will perform the second use case publishing message in Amazon SANS and we will use the publish

3
00:00:13,650 --> 00:00:19,350
message command to the Amazon since we are using the Node.js application and SDK libraries.

4
00:00:19,710 --> 00:00:26,190
So basically when publishing the message, it is send a message to Amazon sans topic or it is a text

5
00:00:26,190 --> 00:00:32,280
message directly to the phone number or a message to the mobile platform and points it is depending

6
00:00:32,280 --> 00:00:34,800
on which system are subscribing.

7
00:00:34,860 --> 00:00:40,560
If we send a message to the topic, Amazon SMS delivers the message to each end point that is subscribed

8
00:00:40,560 --> 00:00:46,950
to the topic, the format of the message depending on the notification protocol for each subscribed

9
00:00:46,950 --> 00:00:47,850
endpoints.

10
00:00:48,270 --> 00:00:50,340
So let's start the implementation.

11
00:00:50,340 --> 00:00:52,560
Before we start, we should check the documentation.

12
00:00:52,560 --> 00:00:55,560
You can come to this client and search for the.

13
00:00:56,700 --> 00:00:57,450
Publish.

14
00:00:58,920 --> 00:00:59,470
Come on.

15
00:00:59,630 --> 00:01:04,350
You can see in here if you open the publish command, you can see the documentation in here.

16
00:01:04,370 --> 00:01:09,290
Basically, we will use the publish command operation to perform these tasks.

17
00:01:09,320 --> 00:01:14,390
If you go to input statement, you can see the potential input statement.

18
00:01:14,390 --> 00:01:20,990
When we are sending any message to the topic, it requires the subject message, phone number, topic,

19
00:01:20,990 --> 00:01:22,120
agent and so on.

20
00:01:22,130 --> 00:01:26,780
But the idea is that publish command is provided to send a message to Amazon sans topic.

21
00:01:26,780 --> 00:01:34,250
And if you send the SNS topic, Amazon SNS will be redirect this message to the subscribe systems.

22
00:01:34,490 --> 00:01:42,500
Okay, before we proceed to publish command, we should create a topic on Amazon SNS environment.

23
00:01:42,500 --> 00:01:50,030
For that purpose we have already used an implement create topic so we don't have any topic now to create

24
00:01:50,030 --> 00:01:51,250
a new topic.

25
00:01:51,260 --> 00:01:57,050
So I'm going to run not command which is not create topic that just hit enter.

26
00:01:57,050 --> 00:02:00,830
This will be create a new topic on the Amazon SNS.

27
00:02:00,830 --> 00:02:07,040
So after that we will implement our actual logic, which is the published command to this new topic.

28
00:02:07,070 --> 00:02:11,660
For that purpose, I'm going to create a new file, which is the publish.

29
00:02:13,420 --> 00:02:14,140
Beaumont.

30
00:02:14,870 --> 00:02:15,800
But this topic.

31
00:02:16,960 --> 00:02:17,860
But this.

32
00:02:18,760 --> 00:02:23,280
So in this file we are going to implement our actual logic.

33
00:02:23,290 --> 00:02:24,010
To do so.

34
00:02:24,010 --> 00:02:30,090
I'm going to copy from the create topic and come here, which is pasting the whole code.

35
00:02:30,100 --> 00:02:34,420
But this time we are going to use the command of the published command, right?

36
00:02:34,420 --> 00:02:37,420
So we can see documentation in the publish command.

37
00:02:37,420 --> 00:02:43,630
We should specify some different parameters which including the our message and the topic area.

38
00:02:43,690 --> 00:02:50,710
So let me give a topic and you can remember that when we delete a topic, we pass the topic and copy

39
00:02:50,710 --> 00:02:56,500
this parameter from here and come back to our actual logic, which is the publish topic.

40
00:02:56,500 --> 00:02:58,780
So a paste the topic, a run in here.

41
00:02:58,810 --> 00:03:02,500
Also we have another parameter which is the message.

42
00:03:03,740 --> 00:03:04,700
In the message.

43
00:03:04,730 --> 00:03:07,040
We can give the some example.

44
00:03:08,580 --> 00:03:11,550
Publish a month message.

45
00:03:11,550 --> 00:03:13,350
You can give any message in here.

46
00:03:13,470 --> 00:03:14,230
Okay, very good.

47
00:03:14,250 --> 00:03:19,530
We specify the parameters for the publish command and we are going to send these publish commands with

48
00:03:19,530 --> 00:03:25,170
these parameters to the SNS client and the rest of the code is will be same.

49
00:03:25,200 --> 00:03:25,860
Okay.

50
00:03:25,860 --> 00:03:26,460
Very good.

51
00:03:26,490 --> 00:03:31,410
To test this code, we can save this file and open the terminal.

52
00:03:31,440 --> 00:03:35,430
Run the node, publish command to JS, hit enter.

53
00:03:35,460 --> 00:03:39,480
This is going to publish a message to the topic that we create.

54
00:03:39,510 --> 00:03:39,990
Okay.

55
00:03:40,050 --> 00:03:42,690
As you can see that the message ID is returned to us.

56
00:03:42,690 --> 00:03:47,730
So we will verify from the message the Amazon SNS topic.

57
00:03:47,760 --> 00:03:52,950
If you go to the our environment, go to topics.

58
00:03:53,850 --> 00:03:55,770
If you refresh this page.

59
00:03:56,790 --> 00:04:03,180
You can see the topics that we created and if you open the topic, you can see that we send the topic

60
00:04:03,180 --> 00:04:10,080
message, we got the topic message ID, but since we don't have any subscriber, we didn't see the message

61
00:04:10,080 --> 00:04:12,330
from the subscriber systems.

62
00:04:12,330 --> 00:04:18,560
So as you can see that we have successfully publish message to the topic on Amazon since using a disk

63
00:04:18,630 --> 00:04:19,380
libraries.

64
00:04:19,410 --> 00:04:23,970
In the next video we will subscribe and unsubscribe from the topic on Amazon since.
