Service orchestration is an architectural design where a single centralised service is responsible for coordinating and interacting among different services. They invoke different services and combine them together . The orchestration unit is abstracted and exposed as a single service.
Orchestration is usually accomplished through Enterprise Application Integration(EAI), which enables data integration, and the use of a central messaging engine such as an Enterprise Service Bus(ESB), which routes, transforms and enriches messages.
In this article we will see how orchestration can be achieved in a serverless world using Kumologica and AWS Lambda.
Kumologica is a free low-code development tool to build serverless integrations. You can learn more in this medium article or on our website.
Use case
To get a better sense of orchestration , we will create a loan broker service which will be making a loan request on behalf of a customer. The service will invoke the sub services which are involved in the loan request. These sub services include credit score from credit agencies, quotes from different banks etc. Each of these sub services are external services which need to be invoked in a sequence by the orchestration service and finally returns a list of quotes from potential lenders to the broker who made the original request.
Prerequisite
- For the above use case we will be creating mock API’s in mockable.io for credit score check. Below is the sample mock response data for a credit score check.
{
"check_status" : "pass",
"score" : 600,
"SSN" : "ABHY888-999-HT",
"Agency" : "ABC Provider",
"Date" : "08-09-2019 10:00:00"
}
2 . Below is the Bank quote Mock response for the Bank Quote mock API.
[{
"Bank_Name" : "ABC Corp",
"Quote" :{
"Min" : "600000",
"Max" : "800000",
"Currency" : "AUD"
}
},
{
"Bank_Name" : "HSKC",
"Quote" :{
"Min" : "900000",
"Max" : "1000000",
"Currency" : "AUD"
}
},
{
"Bank_Name" : "Westland",
"Quote" :{
"Min" : "500000",
"Max" : "800000",
"Currency" : "AUD"
}
},
{
"Bank_Name" : "CAN Bank",
"Quote" :{
"Min" : "600000",
"Max" : "900000",
"Currency" : "AUD"
}
}
]
Note : You may use any other services or mechanisms in order to create a mock service.
3 . Kumologica designer installed in your machine. https://kumologica.com/download.html
If you are new to Kumologica then I would suggest reading the following link to kick start. https://medium.com/@kumologica
4 . An AWS account to deploy your Kumologica service
Implementation
Open the Kumologica designer and Create a New project.
Remove the default hello world flow.
-
Drag and drop EventListener Node from the pallet to the canvas and open the EvenListener node settings and configure the following.
Display Name : GET /quote
Event Source : Amazon API gateway
Verb : GET
URL : /quote -
Drag and drop HTTP Req node from the web category in the pallet to the canvas. Open the settings and configure the following.
Display Name : GetCreditCheck
Method : GET
Url : your mock url for credit check.
Return : a UTF-8 string
Response Timeout : 120000ms (default)
Authentication : None Wire EventListener node to HTTP Req node.
Add JSON node to canvas for transforming JSON string to Javascript Object.
Wire HTTP Req node to JSON node.
Add Set-property Node to the canvas. This is to store the check_status field value from the credit check (http) response.
-
Drag and drop the switch node to the canvas and set the condition for verifying whether to proceed for Quote or Not.
Display Name: CreditStatus_Check
Set temp == ‘pass’
Set “otherwise” Write the JSON node to Set-Property Node and Set-Property node to Switch Node.
-
Add another HTTP req node to the canvas and set the following.
Display Name : GetBankQuote
Method : POST
Url : your mock url for credit check
Return : a UTF-8 string
Response Timeout : 120000ms (default)
Authentication : None Drag and Drop another Set-Property node to the canvas and set the msg.payload as {“message” : “Cannot process the quote”}
Wire the “pass” output terminal of Switch node to the HTTP req node (GetBankQuote) and wire the “otherwise” terminal to the second Set-Property node.
Drag and drop the EventListener End node to the canvas and set the Payload as msg.payload and leave other fields as default.
The loan broker service flow will look given below in the canvas.
If you want to try out this application quickly you can import the loan broker flow from the below given git url.
https://github.com/KumologicaHQ/kumologica-demos/tree/master/LoanBorkerApplication
Loan Broker service flow in Kumologica Designer Canvas
Now we are done with the implementation. Let’s deploy the flow to your AWS account.
On the cloud tab click on the Profile drop down menu and select your AWS profile. Ensure that you have the necessary permissions for your flow to be deployed as AWS lambda.
Select the API Gateway under the trigger section and leave all other fields as default.
Click Deploy.
Now you can see the flow is getting deployed to your AWS lambda. And once deployment is completed then you should the endpoint url for your Loan Broker service hosted on AWS API gateway.
Summary
Thanks for reading and I hope you enjoyed this use case and appreciate how simple it is to implement an orchestration service with Kumologica. We would love to hear your feedback, and don’t hesitate to contact us if you have any questions.
To learn more about Kumologica checkout our official documentation at kumologica.com and subscribe to our video in youtube at https://www.youtube.com/channel/UCsTDAlhijUFpsfThJu3hF9g.
Top comments (0)