Serverless Orchestration in lambda
Tags: serverless, aws, kumologica, lowcode
Published: 2020-06-25 04:33:03

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](https://en.wikipedia.org/wiki/Enterprise_application_integration)(EAI), which enables data integration, and the use of a central messaging engine such as an [Enterprise Service Bus](https://en.wikipedia.org/wiki/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.

![](https://cdn-images-1.medium.com/max/2000/1*5G0HTR1tDhN83nEGKoC1KQ.png)

Kumologica is a free low-code development tool to build serverless integrations. You can learn more in this [medium article](https://medium.com/@kumologica/kumologica-first-low-code-development-tool-for-aws-lambda-8831b5237428) or on our [website](http://kumologica.com/).

**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**

1. 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](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](https://medium.com/@kumologica)

4 . An AWS account to deploy your Kumologica service

**Implementation**

1. Open the Kumologica designer and Create a New project.

2. Remove the default hello world flow.

3. 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

4. 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

5. Wire EventListener node to HTTP Req node.

6. Add JSON node to canvas for transforming JSON string to Javascript Object.

7. Wire HTTP Req node to JSON node.

8. Add Set-property Node to the canvas. This is to store the check_status field value from the credit check (http) response.

9. 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”

10. Write the JSON node to Set-Property Node and Set-Property node to Switch Node.

11. 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

12. Drag and Drop another Set-Property node to the canvas and set the msg.payload as {“message” : “Cannot process the quote”}

13. 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.

14. Drag and drop the EventListener End node to the canvas and set the Payload as msg.payload and leave other fields as default.

15. 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](https://github.com/KumologicaHQ/kumologica-demos/tree/master/LoanBorkerApplication)

![Loan Broker service flow in Kumologica Designer Canvas](https://cdn-images-1.medium.com/max/3064/0*Nhfk7aLTJEEqTB4Q)*Loan Broker service flow in Kumologica Designer Canvas*

Now we are done with the implementation. Let’s deploy the flow to your AWS account.

2. 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.

3. Select the API Gateway under the trigger section and leave all other fields as default.

4. Click Deploy.

5. 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](http://kumologica.com/) and subscribe to our video in youtube at [https://www.youtube.com/channel/UCsTDAlhijUFpsfThJu3hF9g](https://www.youtube.com/channel/UCsTDAlhijUFpsfThJu3hF9g).