1
00:00:00,120 --> 00:00:05,160
In this video, we are going to develop the target systems, which is the ordering microservices and

2
00:00:05,160 --> 00:00:06,990
also notification microservices.

3
00:00:07,230 --> 00:00:11,790
So as you know that we have created the DB table for the order operations.

4
00:00:11,790 --> 00:00:14,990
So that's why I would like to start with the order microservices.

5
00:00:15,000 --> 00:00:22,020
See that there is a dynamo DB on our environment and the name of the diamond v table is ordered and

6
00:00:22,020 --> 00:00:23,700
the partition key is the ID.

7
00:00:24,000 --> 00:00:28,320
So basically we will start with the implementing and developing order.

8
00:00:28,320 --> 00:00:30,810
Microservices, please open the visitor code.

9
00:00:30,840 --> 00:00:36,810
I have created separate lecture folder and if you follow the command text we will see the dynamo DB

10
00:00:36,810 --> 00:00:43,380
table and see that these Dynamo DB table will be used from the order microservices and Order Microservices

11
00:00:43,380 --> 00:00:50,670
is triggered from the API Gateway Basket event, which is an order you can follow from the our main

12
00:00:50,670 --> 00:00:51,330
architecture.

13
00:00:51,330 --> 00:00:58,230
The user sent HTTP post request to API gateway and this will be goes to basket microservices and basket

14
00:00:58,230 --> 00:01:00,930
microservices publish checkout event to Amazon event page.

15
00:01:00,930 --> 00:01:03,220
And this is the target to the Amazon case.

16
00:01:03,270 --> 00:01:08,310
Amazon is pulling from the ordering microservices, so now we are starting to developing and interact

17
00:01:08,310 --> 00:01:10,380
with Dynamo DB for that purpose.

18
00:01:10,380 --> 00:01:17,310
If you open the OR we just do a code, if you come to order event JSON, you can see the incoming event,

19
00:01:17,310 --> 00:01:23,310
the trigger to order microservices here you can see the records array and in the resource array we have

20
00:01:23,310 --> 00:01:29,460
a board section and in the board section we are receiving an event coming from the UN page and we will

21
00:01:29,460 --> 00:01:37,530
get the detail of this attribute into the our architecture to get the actual payload from our application.

22
00:01:37,530 --> 00:01:38,880
Here you can see the detail.

23
00:01:39,210 --> 00:01:47,460
Okay, so after examine the incoming logs and see the Dynamo DB table, I'm going to start with implementing

24
00:01:47,460 --> 00:01:52,140
make this folder as a Node.js module for the ordering microservices.

25
00:01:52,140 --> 00:01:57,960
To do that, please run the API in command, but before that, open the terminal and locate the correct

26
00:01:57,960 --> 00:01:58,620
folder.

27
00:01:59,380 --> 00:02:07,870
And in here I'm going to use order microservices and run the API init command in order to create a package

28
00:02:07,870 --> 00:02:08,710
json file.

29
00:02:08,740 --> 00:02:12,450
And the first thing I am doing as a type is module.

30
00:02:12,460 --> 00:02:18,580
And after that, if you follow the commands, basically we will install the required package which is

31
00:02:18,580 --> 00:02:23,470
the client dynamo and util dynamo because we would like to insert a new item into dynamo.

32
00:02:23,470 --> 00:02:28,150
DB table from the incoming event comes from the basket microservices.

33
00:02:28,150 --> 00:02:31,930
For that purpose please run NPM commands for Dynamo DB.

34
00:02:32,140 --> 00:02:35,890
So I'm going to copy paste for the client Dynamo DB operation.

35
00:02:36,130 --> 00:02:43,570
And also I would like to run Util Dynamo DB to make it simpler when we are using to put item command

36
00:02:43,570 --> 00:02:48,370
in Dynamo db OC, this will be installed required package for Dynamo DB.

37
00:02:48,400 --> 00:02:54,850
We have the same operation and several times during our hands on labs, so that's why I'm not going

38
00:02:54,850 --> 00:02:56,440
to go to documentation.

39
00:02:56,560 --> 00:02:56,920
Okay.

40
00:02:56,920 --> 00:03:00,430
Now our NPM commands and installations are ready.

41
00:03:00,430 --> 00:03:03,280
You can confirm from the package and dependencies.

42
00:03:03,280 --> 00:03:05,320
Now we can start with development.

43
00:03:05,320 --> 00:03:10,870
For that purpose I have create the index case which is the basic implementation of lambda handed method

44
00:03:10,870 --> 00:03:16,030
and put the log method for the incoming evaluation and core we to try case block.

45
00:03:16,060 --> 00:03:22,630
Since these lambda function is pulling from the ESCs, this will be trigger synchronous but not required

46
00:03:22,630 --> 00:03:28,420
any response for that purpose we will develop according to incoming event JSON from the Amazon space.

47
00:03:28,420 --> 00:03:32,020
So I'm going to handle incoming event from the order.

48
00:03:32,050 --> 00:03:38,770
Amazon is in the order function code and let's make a plan with writing code for that purpose.

49
00:03:38,770 --> 00:03:41,230
We will start with the making.

50
00:03:41,830 --> 00:03:47,590
For example, in the first step we would like to iterate the ASCS records because the records array

51
00:03:47,590 --> 00:03:53,470
comes from the case and after that get requests by the payload of event bridge.

52
00:03:53,470 --> 00:03:59,470
When we get the case record body, this will be get payload from the Amazon event bridge and after that

53
00:03:59,470 --> 00:04:06,070
we will get the actual payload which comes from the deposit request and we will get the actual payload

54
00:04:06,070 --> 00:04:08,260
from event detail object.

55
00:04:08,620 --> 00:04:15,940
You can see the order event JSON file from the previous lecture and see that we got the records and

56
00:04:15,940 --> 00:04:23,320
body in the body we go to the detail object to get the actual logic actual payload from the deposit

57
00:04:23,380 --> 00:04:26,290
operation after getting the actual payload.

58
00:04:26,290 --> 00:04:35,320
The thing we should do that save order item into our order dynamo DB table using Dynamo DB SDK package.

59
00:04:35,350 --> 00:04:37,030
This is the our business logic.

60
00:04:37,030 --> 00:04:42,670
So these are the our main four step that we are going to implement and develop in the 100 method of

61
00:04:42,670 --> 00:04:44,020
to order microservices.

62
00:04:44,020 --> 00:04:50,110
And if you go back to common text, you can see the expected payload comes from the H2 Post request

63
00:04:50,110 --> 00:04:53,320
and we are trying to reach these expected payload.

64
00:04:53,320 --> 00:04:59,290
And after that we will we will insert these payload into the order table of Dynamo DB.

65
00:04:59,560 --> 00:05:03,430
Please go back to index and start implementation before we start.

66
00:05:03,430 --> 00:05:09,700
The first thing we should do that create the DB client JS is remember that we have created a separate

67
00:05:09,700 --> 00:05:14,440
node module in order to expose dynamo DB client object and interact with the Dynamo DB.

68
00:05:14,530 --> 00:05:18,370
Please create this file and after that we will import the card statement.

69
00:05:18,370 --> 00:05:21,400
Basically, we will perform the put item command.

70
00:05:21,400 --> 00:05:27,820
So that's why I have import to put item command flow from the client dynamo db at the util dynamo we

71
00:05:27,820 --> 00:05:32,530
use Marshall and this is the Dynamo db db client for interacting dynamo db.

72
00:05:32,680 --> 00:05:35,170
So now we can start with the implementation.

73
00:05:35,170 --> 00:05:41,530
We will start with the four statements, as you remember, that we will four for each and iterate the

74
00:05:41,680 --> 00:05:42,670
case records.

75
00:05:42,670 --> 00:05:46,450
You can come here, let me copy paste first and I will explain after that.

76
00:05:46,450 --> 00:05:50,740
So basically we have a for loop and in this loop we will.

77
00:05:52,210 --> 00:05:55,830
Iterate the event records, which is the incoming event records.

78
00:05:55,840 --> 00:05:58,190
You can come here and see the order event.

79
00:05:58,300 --> 00:06:03,900
We are got the order records and that means the first item we are reaching.

80
00:06:03,910 --> 00:06:09,700
And after that, if you go back to our first statement, we log the record statement and after that

81
00:06:09,700 --> 00:06:13,650
in the second step we get request but the information from the event payload.

82
00:06:13,660 --> 00:06:18,970
So in the record we have a body section and we get the body section which is the event piece, published

83
00:06:18,970 --> 00:06:19,600
message.

84
00:06:19,600 --> 00:06:26,500
So after that we will also reach the event page message to the detail in order to get actual order data,

85
00:06:26,500 --> 00:06:31,480
which is the basket data, which is the actual payload from the HTTP post operation.

86
00:06:31,540 --> 00:06:36,190
And after that we will perform the business logic, which is a save order item in the MDB.

87
00:06:36,220 --> 00:06:39,580
For that purpose, I have set the ID information as a hardcoded.

88
00:06:39,610 --> 00:06:45,190
If you come here you can see the partition key is the ID and you can generate this ID from the UUID.

89
00:06:45,220 --> 00:06:46,540
But make it simple.

90
00:06:46,540 --> 00:06:52,300
I set the ID information as a one and after that we will prepare the parameters of the item command

91
00:06:52,300 --> 00:06:58,210
in the parameters we pass the table name and we paste the item order the data with Marshall Operation

92
00:06:58,210 --> 00:07:04,120
and all the data include the payload, also ID information in order to save order item into the Dynamo

93
00:07:04,120 --> 00:07:10,690
DB and we will use port item command and Dynamo DB client send operation in order to interact and save

94
00:07:10,720 --> 00:07:13,390
put item in Dynamo DB okay, very good.

95
00:07:13,390 --> 00:07:19,210
We have finished the ordering microservices and now it is time to deploy our code.

96
00:07:19,240 --> 00:07:26,590
If you come to lecture folder right click reveal in Explorer Select all remove commands right click

97
00:07:26,980 --> 00:07:29,260
send to zip file.

98
00:07:30,720 --> 00:07:32,910
And this will be the order MBS.

99
00:07:34,880 --> 00:07:36,260
Order microservices.

100
00:07:36,350 --> 00:07:38,180
Now if you go to the our.

101
00:07:39,020 --> 00:07:45,110
A management console, go to order Microsoft's function and click the upload from zip file, select

102
00:07:45,110 --> 00:07:50,480
the upload and go to correct folder and select the order MBS and click the say button.

103
00:07:51,290 --> 00:07:58,670
So this will be upload or order mix source code into lambda function environment and you will check

104
00:07:58,670 --> 00:08:00,660
the codes reading on the code window.

105
00:08:00,680 --> 00:08:01,430
Yes.

106
00:08:01,640 --> 00:08:03,710
If you come here and see that.

107
00:08:04,560 --> 00:08:10,390
Review the indexes and we don't have any exception and we have developed our order microservices.

108
00:08:10,410 --> 00:08:13,360
Now it is time to develop our notification microservices.

109
00:08:13,380 --> 00:08:19,500
We open the Visual Studio code and go to our previous lecture and open the notification event.

110
00:08:19,500 --> 00:08:20,190
JSON.

111
00:08:20,190 --> 00:08:26,370
This JSON object is triggered to our notification microservices when it comes to a target from the Amazon

112
00:08:26,370 --> 00:08:27,080
event page.

113
00:08:27,210 --> 00:08:31,600
So this is the incoming event that we develop our notification microservice.

114
00:08:31,620 --> 00:08:37,690
According to this event, for that purpose, I have created in our lecture notification messages.

115
00:08:37,710 --> 00:08:43,830
If you open this file, this is the basic handle operation for the notification microservices.

116
00:08:43,860 --> 00:08:47,640
We basically log the incoming event and after that we will check the event.

117
00:08:47,640 --> 00:08:53,700
Detail type is not null and after that we will basically parse the incoming detail object or the data

118
00:08:53,700 --> 00:08:55,170
and log the order data.

119
00:08:55,200 --> 00:09:00,000
This is very basic operation that we handle in the notification microservices.

120
00:09:00,030 --> 00:09:05,040
We basically logging the incoming order data so we get the event at the tail.

121
00:09:05,070 --> 00:09:09,300
If you go back to notification event, you can see that in the detail object.

122
00:09:09,300 --> 00:09:13,310
You can see our actual payload which comes from the HTTP post operations.

123
00:09:13,320 --> 00:09:20,670
So in order to deploy these notification microservices, please copy all codes and go to the OR a lambda

124
00:09:20,670 --> 00:09:27,690
environment, go to functions and open the notification microservices, go to code window and you can

125
00:09:27,690 --> 00:09:33,510
remove and copy paste codes from your widgets to the code environment and click the deploy button.

126
00:09:36,080 --> 00:09:36,280
Okay.

127
00:09:36,320 --> 00:09:36,920
Very good.

128
00:09:36,950 --> 00:09:42,970
So as you can see that we have successful develop the microservices and also notification microservices.

129
00:09:42,980 --> 00:09:48,320
So that means we will finished all development parts and now it is time to perform end to end test.
