In this video, we are going to perform end to end test for our hands on lab.
Basically, we will start from sending a deposit request from the user and this will be accommodated
from the API, gateway basket API and redirect to Lambda function basket function.
And this will be checkout event published checkout event to Amazon event which and execute to event
patterns and after that some to target systems, which is the Amazon case and notification microservices.
After that Amazon record pulling from the order microservices and save item in order dynamo DB table
and we sent.
But this time we will send two type of request from the user.
This will send message to Amazon event page, but these message sent to microservices according to detail
type and source information as you remember that we have created to rule definition into Amazon event
page with different event patterns.
So we will send different event patterns, payload and see how we trigger to our lambda function target
systems with differently.
If you open the or we just to do code environment, you can see that we will test from the postman and
this will go to these services.
But this time we will send to type of request, as you remember, that we have created a custom event
for us.
Which name is checkout basket event?
Plus in this custom universe we have two event rules rule.
So the first one is checkout basket event rule and each event pattern is detailed type checkout basket
and source is com SVM basket and checkout basket.
And in the notification rule we have second rule which names notification rule and event pattern is
seems that in detail type is a notification and source is a contact is the one basket notification.
So if you scroll down, you can see that these are the two use cases that we are going to do.
We will send a post request for this payload.
This is the new checkout item payload, including the item price detail type checkout basket and source
checkout basket.
And the second payload is notifying the price update and we are adding to notify attribute price detail
type is a notification source is a notification.
So let's check the our event bridge and patterns and review.
Again, if you open the case management console, go to Amazon Event Bridge and select the rules.
You can see that we will select event pass select please our custom event plus which team is checkout
basket event pass see that we have to rule definition.
I'm going to open checkout basket rule first and see that this is the our checkout basket rule definition.
And here you can see the event pattern.
So we will use this pattern and this pattern has two targets when we are running the checkout basket
rule, this will trigger order queue and also notification microservices.
If you come back to our rules, we have also one more rule which is notification rule.
And if you come to notification rule here, you can see the event pattern detail type is a notification
and if you go to target this time we have only one target which is a notification microservices because
notifications are not interested with the order microservices.
Okay.
So now let's start to perform the test for that purpose.
Please open the postman and go to the 82 post request of our API gateway which expose from the basket
API.
And here you can see the example payload.
If you open the widget to the code, you can see that the first payload is in here.
We can copy and paste in here.
This is the exact same payload.
Okay, so now let me send these HTTP post requests one by one.
I'm going to send the first request again.
Click the send button.
Okay.
It is response back to successful response.
So now after that please copy payload to and remove this payload and paste the payload to which is the
detail type is a notification and click the send button.
See that we have also sent the notification to the basket operation.
So now what we have expect now if you open the our architecture basically we will send to the post request
with different detail type.
This will be published checkout event, Amazon event page and this will be run the event patterns and
try to match these event patterns.
The first event will be matched to the our checkout basket event pattern and target to the Amazon case
and notification microservices.
The second incoming event match to the notification rule and this will be only target to the notification
microservices.
So that means we will see two invocation for the notification microservices and one invocation for the
organic microservices.
Let's see how it's coming in.
The Cloud Watch looks to learn the functions and open the order microservices and to go to monitor and
we cloud watch.
So if you open the cloud, please open the latest lucid dream.
You can see that incoming message from the sky is pulling from that.
And after that we will save these messages into our application.
So I think there is a problem when we are passing the event, an object.
If you open the widget to the code in the index case of all the microservices, we are passing the incoming
record body and the gate, the tail object.
Somehow we got the exception in this line of code.
Please ignore this exception for now because I would like to emphasize that the important thing is here
to figure out that order microservices trigger one time, not two times.
So that means second request message.
Do not forward the order due to event pattern cannot match to order microservices.
So the important thing is we send that to the post request but we solve that one invocation from the
order microservices.
So please go to the notification microservices and see what's going on on that place.
Open the notification microservices and go to monitor and we will close.
If you scroll down and go at the end of this page, you can see the latest to log.
Please check the info event, which is the log incoming event from the Amazon event.
Please please expand this one.
As you can see that here, you can see one invocation from notification side.
There is a notification detail type and source.
And if you scroll up, go to different info event segment.
You can see that we have also one more invocations comes from the detail type check out source.
But when we check the order Lambda Microservice, look, you can see that we have only one invocation
and it comes from the, the type of checkout basket and the source is checkout basket.
So as you can see that we have verified that in notification microservices trigger two times and all
the microservices trigger one times.
So that means both request message matched the target notification event pattern rules and invoke notification
microservice two times.
By this way, we can design and implement our distributed transactions with event driven approach.
Using event builds custom UN and event patterns.
So in this hands on up, we simulate event driven microservice communications with events to perform
checkout basket event between distributed microservices.
This is event driven orchestration to redirect events according to event patterns, and this is the
first approach when implementing such a pattern and distributed transactions.
In the next section we will learn serverless orchestration service, which is the step functions.
That is another way to implement these kind of use cases.
As you can see that we have successfully finished end to end test our hands on lab event driven microservice
architecture using Amazon event skills and lambda function.