1
00:00:00,120 --> 00:00:04,620
In this video, we are going to perform end to end test for our hands on lab.

2
00:00:04,710 --> 00:00:10,800
Basically, we will start from sending a deposit request from the user and this will be accommodated

3
00:00:10,800 --> 00:00:15,840
from the API, gateway basket API and redirect to Lambda function basket function.

4
00:00:15,840 --> 00:00:21,000
And this will be checkout event published checkout event to Amazon event which and execute to event

5
00:00:21,000 --> 00:00:26,710
patterns and after that some to target systems, which is the Amazon case and notification microservices.

6
00:00:26,730 --> 00:00:33,510
After that Amazon record pulling from the order microservices and save item in order dynamo DB table

7
00:00:33,870 --> 00:00:34,830
and we sent.

8
00:00:34,830 --> 00:00:38,190
But this time we will send two type of request from the user.

9
00:00:38,220 --> 00:00:44,760
This will send message to Amazon event page, but these message sent to microservices according to detail

10
00:00:44,760 --> 00:00:50,970
type and source information as you remember that we have created to rule definition into Amazon event

11
00:00:50,970 --> 00:00:52,920
page with different event patterns.

12
00:00:52,920 --> 00:00:59,250
So we will send different event patterns, payload and see how we trigger to our lambda function target

13
00:00:59,250 --> 00:01:00,870
systems with differently.

14
00:01:01,080 --> 00:01:07,320
If you open the or we just to do code environment, you can see that we will test from the postman and

15
00:01:07,320 --> 00:01:09,840
this will go to these services.

16
00:01:09,840 --> 00:01:14,760
But this time we will send to type of request, as you remember, that we have created a custom event

17
00:01:14,760 --> 00:01:15,060
for us.

18
00:01:15,060 --> 00:01:16,530
Which name is checkout basket event?

19
00:01:16,530 --> 00:01:20,160
Plus in this custom universe we have two event rules rule.

20
00:01:20,160 --> 00:01:26,310
So the first one is checkout basket event rule and each event pattern is detailed type checkout basket

21
00:01:26,310 --> 00:01:30,060
and source is com SVM basket and checkout basket.

22
00:01:30,210 --> 00:01:35,850
And in the notification rule we have second rule which names notification rule and event pattern is

23
00:01:35,850 --> 00:01:42,060
seems that in detail type is a notification and source is a contact is the one basket notification.

24
00:01:42,060 --> 00:01:47,250
So if you scroll down, you can see that these are the two use cases that we are going to do.

25
00:01:47,250 --> 00:01:50,340
We will send a post request for this payload.

26
00:01:50,370 --> 00:01:56,730
This is the new checkout item payload, including the item price detail type checkout basket and source

27
00:01:56,730 --> 00:01:57,900
checkout basket.

28
00:01:57,900 --> 00:02:04,500
And the second payload is notifying the price update and we are adding to notify attribute price detail

29
00:02:04,500 --> 00:02:07,350
type is a notification source is a notification.

30
00:02:07,470 --> 00:02:10,980
So let's check the our event bridge and patterns and review.

31
00:02:10,980 --> 00:02:16,290
Again, if you open the case management console, go to Amazon Event Bridge and select the rules.

32
00:02:16,290 --> 00:02:21,600
You can see that we will select event pass select please our custom event plus which team is checkout

33
00:02:21,600 --> 00:02:25,080
basket event pass see that we have to rule definition.

34
00:02:25,080 --> 00:02:31,080
I'm going to open checkout basket rule first and see that this is the our checkout basket rule definition.

35
00:02:31,080 --> 00:02:33,150
And here you can see the event pattern.

36
00:02:33,150 --> 00:02:39,900
So we will use this pattern and this pattern has two targets when we are running the checkout basket

37
00:02:39,900 --> 00:02:44,280
rule, this will trigger order queue and also notification microservices.

38
00:02:44,550 --> 00:02:49,380
If you come back to our rules, we have also one more rule which is notification rule.

39
00:02:49,380 --> 00:02:54,810
And if you come to notification rule here, you can see the event pattern detail type is a notification

40
00:02:54,810 --> 00:03:00,240
and if you go to target this time we have only one target which is a notification microservices because

41
00:03:00,240 --> 00:03:03,990
notifications are not interested with the order microservices.

42
00:03:04,260 --> 00:03:04,770
Okay.

43
00:03:04,770 --> 00:03:08,130
So now let's start to perform the test for that purpose.

44
00:03:08,130 --> 00:03:14,850
Please open the postman and go to the 82 post request of our API gateway which expose from the basket

45
00:03:14,850 --> 00:03:15,510
API.

46
00:03:15,510 --> 00:03:18,030
And here you can see the example payload.

47
00:03:18,030 --> 00:03:22,590
If you open the widget to the code, you can see that the first payload is in here.

48
00:03:22,590 --> 00:03:24,510
We can copy and paste in here.

49
00:03:24,510 --> 00:03:26,250
This is the exact same payload.

50
00:03:26,310 --> 00:03:31,020
Okay, so now let me send these HTTP post requests one by one.

51
00:03:31,020 --> 00:03:33,120
I'm going to send the first request again.

52
00:03:33,120 --> 00:03:34,260
Click the send button.

53
00:03:36,170 --> 00:03:36,580
Okay.

54
00:03:36,590 --> 00:03:39,080
It is response back to successful response.

55
00:03:39,080 --> 00:03:46,820
So now after that please copy payload to and remove this payload and paste the payload to which is the

56
00:03:46,820 --> 00:03:49,940
detail type is a notification and click the send button.

57
00:03:50,990 --> 00:03:55,880
See that we have also sent the notification to the basket operation.

58
00:03:55,880 --> 00:04:02,840
So now what we have expect now if you open the our architecture basically we will send to the post request

59
00:04:02,870 --> 00:04:04,490
with different detail type.

60
00:04:04,490 --> 00:04:11,000
This will be published checkout event, Amazon event page and this will be run the event patterns and

61
00:04:11,000 --> 00:04:13,040
try to match these event patterns.

62
00:04:13,070 --> 00:04:19,390
The first event will be matched to the our checkout basket event pattern and target to the Amazon case

63
00:04:19,400 --> 00:04:21,020
and notification microservices.

64
00:04:21,020 --> 00:04:27,410
The second incoming event match to the notification rule and this will be only target to the notification

65
00:04:27,410 --> 00:04:28,250
microservices.

66
00:04:28,250 --> 00:04:34,820
So that means we will see two invocation for the notification microservices and one invocation for the

67
00:04:34,820 --> 00:04:36,110
organic microservices.

68
00:04:36,110 --> 00:04:37,970
Let's see how it's coming in.

69
00:04:37,970 --> 00:04:45,170
The Cloud Watch looks to learn the functions and open the order microservices and to go to monitor and

70
00:04:45,170 --> 00:04:46,010
we cloud watch.

71
00:04:47,950 --> 00:04:51,580
So if you open the cloud, please open the latest lucid dream.

72
00:04:51,640 --> 00:04:55,540
You can see that incoming message from the sky is pulling from that.

73
00:04:55,540 --> 00:04:59,500
And after that we will save these messages into our application.

74
00:04:59,500 --> 00:05:04,460
So I think there is a problem when we are passing the event, an object.

75
00:05:04,480 --> 00:05:10,750
If you open the widget to the code in the index case of all the microservices, we are passing the incoming

76
00:05:11,140 --> 00:05:14,110
record body and the gate, the tail object.

77
00:05:14,110 --> 00:05:17,110
Somehow we got the exception in this line of code.

78
00:05:17,140 --> 00:05:23,050
Please ignore this exception for now because I would like to emphasize that the important thing is here

79
00:05:23,110 --> 00:05:27,580
to figure out that order microservices trigger one time, not two times.

80
00:05:27,580 --> 00:05:29,980
So that means second request message.

81
00:05:29,980 --> 00:05:35,350
Do not forward the order due to event pattern cannot match to order microservices.

82
00:05:35,350 --> 00:05:42,370
So the important thing is we send that to the post request but we solve that one invocation from the

83
00:05:42,370 --> 00:05:43,630
order microservices.

84
00:05:43,630 --> 00:05:48,870
So please go to the notification microservices and see what's going on on that place.

85
00:05:48,880 --> 00:05:55,200
Open the notification microservices and go to monitor and we will close.

86
00:05:59,180 --> 00:06:04,640
If you scroll down and go at the end of this page, you can see the latest to log.

87
00:06:04,730 --> 00:06:11,600
Please check the info event, which is the log incoming event from the Amazon event.

88
00:06:11,600 --> 00:06:13,490
Please please expand this one.

89
00:06:13,520 --> 00:06:17,750
As you can see that here, you can see one invocation from notification side.

90
00:06:17,780 --> 00:06:20,210
There is a notification detail type and source.

91
00:06:20,210 --> 00:06:24,300
And if you scroll up, go to different info event segment.

92
00:06:24,320 --> 00:06:29,420
You can see that we have also one more invocations comes from the detail type check out source.

93
00:06:29,570 --> 00:06:36,650
But when we check the order Lambda Microservice, look, you can see that we have only one invocation

94
00:06:36,650 --> 00:06:42,410
and it comes from the, the type of checkout basket and the source is checkout basket.

95
00:06:42,410 --> 00:06:49,790
So as you can see that we have verified that in notification microservices trigger two times and all

96
00:06:49,790 --> 00:06:51,740
the microservices trigger one times.

97
00:06:51,740 --> 00:06:58,670
So that means both request message matched the target notification event pattern rules and invoke notification

98
00:06:58,670 --> 00:07:00,100
microservice two times.

99
00:07:00,110 --> 00:07:05,690
By this way, we can design and implement our distributed transactions with event driven approach.

100
00:07:05,690 --> 00:07:09,200
Using event builds custom UN and event patterns.

101
00:07:09,200 --> 00:07:14,870
So in this hands on up, we simulate event driven microservice communications with events to perform

102
00:07:14,870 --> 00:07:18,350
checkout basket event between distributed microservices.

103
00:07:18,350 --> 00:07:23,900
This is event driven orchestration to redirect events according to event patterns, and this is the

104
00:07:23,900 --> 00:07:27,890
first approach when implementing such a pattern and distributed transactions.

105
00:07:28,220 --> 00:07:33,020
In the next section we will learn serverless orchestration service, which is the step functions.

106
00:07:33,020 --> 00:07:35,930
That is another way to implement these kind of use cases.

107
00:07:36,020 --> 00:07:41,540
As you can see that we have successfully finished end to end test our hands on lab event driven microservice

108
00:07:41,540 --> 00:07:45,140
architecture using Amazon event skills and lambda function.
