In this video, we are going to develop the target systems, which is the ordering microservices and
also notification microservices.
So as you know that we have created the DB table for the order operations.
So that's why I would like to start with the order microservices.
See that there is a dynamo DB on our environment and the name of the diamond v table is ordered and
the partition key is the ID.
So basically we will start with the implementing and developing order.
Microservices, please open the visitor code.
I have created separate lecture folder and if you follow the command text we will see the dynamo DB
table and see that these Dynamo DB table will be used from the order microservices and Order Microservices
is triggered from the API Gateway Basket event, which is an order you can follow from the our main
architecture.
The user sent HTTP post request to API gateway and this will be goes to basket microservices and basket
microservices publish checkout event to Amazon event page.
And this is the target to the Amazon case.
Amazon is pulling from the ordering microservices, so now we are starting to developing and interact
with Dynamo DB for that purpose.
If you open the OR we just do a code, if you come to order event JSON, you can see the incoming event,
the trigger to order microservices here you can see the records array and in the resource array we have
a board section and in the board section we are receiving an event coming from the UN page and we will
get the detail of this attribute into the our architecture to get the actual payload from our application.
Here you can see the detail.
Okay, so after examine the incoming logs and see the Dynamo DB table, I'm going to start with implementing
make this folder as a Node.js module for the ordering microservices.
To do that, please run the API in command, but before that, open the terminal and locate the correct
folder.
And in here I'm going to use order microservices and run the API init command in order to create a package
json file.
And the first thing I am doing as a type is module.
And after that, if you follow the commands, basically we will install the required package which is
the client dynamo and util dynamo because we would like to insert a new item into dynamo.
DB table from the incoming event comes from the basket microservices.
For that purpose please run NPM commands for Dynamo DB.
So I'm going to copy paste for the client Dynamo DB operation.
And also I would like to run Util Dynamo DB to make it simpler when we are using to put item command
in Dynamo db OC, this will be installed required package for Dynamo DB.
We have the same operation and several times during our hands on labs, so that's why I'm not going
to go to documentation.
Okay.
Now our NPM commands and installations are ready.
You can confirm from the package and dependencies.
Now we can start with development.
For that purpose I have create the index case which is the basic implementation of lambda handed method
and put the log method for the incoming evaluation and core we to try case block.
Since these lambda function is pulling from the ESCs, this will be trigger synchronous but not required
any response for that purpose we will develop according to incoming event JSON from the Amazon space.
So I'm going to handle incoming event from the order.
Amazon is in the order function code and let's make a plan with writing code for that purpose.
We will start with the making.
For example, in the first step we would like to iterate the ASCS records because the records array
comes from the case and after that get requests by the payload of event bridge.
When we get the case record body, this will be get payload from the Amazon event bridge and after that
we will get the actual payload which comes from the deposit request and we will get the actual payload
from event detail object.
You can see the order event JSON file from the previous lecture and see that we got the records and
body in the body we go to the detail object to get the actual logic actual payload from the deposit
operation after getting the actual payload.
The thing we should do that save order item into our order dynamo DB table using Dynamo DB SDK package.
This is the our business logic.
So these are the our main four step that we are going to implement and develop in the 100 method of
to order microservices.
And if you go back to common text, you can see the expected payload comes from the H2 Post request
and we are trying to reach these expected payload.
And after that we will we will insert these payload into the order table of Dynamo DB.
Please go back to index and start implementation before we start.
The first thing we should do that create the DB client JS is remember that we have created a separate
node module in order to expose dynamo DB client object and interact with the Dynamo DB.
Please create this file and after that we will import the card statement.
Basically, we will perform the put item command.
So that's why I have import to put item command flow from the client dynamo db at the util dynamo we
use Marshall and this is the Dynamo db db client for interacting dynamo db.
So now we can start with the implementation.
We will start with the four statements, as you remember, that we will four for each and iterate the
case records.
You can come here, let me copy paste first and I will explain after that.
So basically we have a for loop and in this loop we will.
Iterate the event records, which is the incoming event records.
You can come here and see the order event.
We are got the order records and that means the first item we are reaching.
And after that, if you go back to our first statement, we log the record statement and after that
in the second step we get request but the information from the event payload.
So in the record we have a body section and we get the body section which is the event piece, published
message.
So after that we will also reach the event page message to the detail in order to get actual order data,
which is the basket data, which is the actual payload from the HTTP post operation.
And after that we will perform the business logic, which is a save order item in the MDB.
For that purpose, I have set the ID information as a hardcoded.
If you come here you can see the partition key is the ID and you can generate this ID from the UUID.
But make it simple.
I set the ID information as a one and after that we will prepare the parameters of the item command
in the parameters we pass the table name and we paste the item order the data with Marshall Operation
and all the data include the payload, also ID information in order to save order item into the Dynamo
DB and we will use port item command and Dynamo DB client send operation in order to interact and save
put item in Dynamo DB okay, very good.
We have finished the ordering microservices and now it is time to deploy our code.
If you come to lecture folder right click reveal in Explorer Select all remove commands right click
send to zip file.
And this will be the order MBS.
Order microservices.
Now if you go to the our.
A management console, go to order Microsoft's function and click the upload from zip file, select
the upload and go to correct folder and select the order MBS and click the say button.
So this will be upload or order mix source code into lambda function environment and you will check
the codes reading on the code window.
Yes.
If you come here and see that.
Review the indexes and we don't have any exception and we have developed our order microservices.
Now it is time to develop our notification microservices.
We open the Visual Studio code and go to our previous lecture and open the notification event.
JSON.
This JSON object is triggered to our notification microservices when it comes to a target from the Amazon
event page.
So this is the incoming event that we develop our notification microservice.
According to this event, for that purpose, I have created in our lecture notification messages.
If you open this file, this is the basic handle operation for the notification microservices.
We basically log the incoming event and after that we will check the event.
Detail type is not null and after that we will basically parse the incoming detail object or the data
and log the order data.
This is very basic operation that we handle in the notification microservices.
We basically logging the incoming order data so we get the event at the tail.
If you go back to notification event, you can see that in the detail object.
You can see our actual payload which comes from the HTTP post operations.
So in order to deploy these notification microservices, please copy all codes and go to the OR a lambda
environment, go to functions and open the notification microservices, go to code window and you can
remove and copy paste codes from your widgets to the code environment and click the deploy button.
Okay.
Very good.
So as you can see that we have successful develop the microservices and also notification microservices.
So that means we will finished all development parts and now it is time to perform end to end test.