Migration from Mulesoft to Kumologica — Part 2
Tags: aws, microservices, integration, serverless
Published: 2020-12-12 21:53:09

In our previous article “[Migration from Mulesoft to Kumologica — Part 1](https://kumologica.medium.com/migration-from-mulesoft-to-kumologica-part-1-ac2ed8e25263)” we took you through the basic nodes in Kumologica that can replace the Mulesoft processors. We also discussed about some of the popular patterns used in [Kumologica](https://www.kumologica.com) and Mulesoft. If you haven’t got chance to read the article I would suggest to go through our [part 1](https://kumologica.medium.com/migration-from-mulesoft-to-kumologica-part-1-ac2ed8e25263) article to get the basics ready for the migration exercise.

This is the second part of our four part series which will take a deep dive through a real-time use case of migrating a service that is developed on Mulesoft. The Mulesoft service described in this article will cover some of the patterns mentioned in our earlier article and we will learn how to migrate this service into Kumologica without negotiating the pattern.

For those who are new to Kumologica I would recommend to go through our [articles](https://medium.com/@kumologica/) and [youtube](https://www.youtube.com/channel/UCsTDAlhijUFpsfThJu3hF9g) videos to get an insight. [Kumologica](https://kumologica.com/) is one of the early players in this space which brings the benefits of the low-code integration capability of traditional integration like Mulesoft to the new world of Serverless. It provides a drag and drop visual designer and low code approach to ensure the greatest speed and flexibility to support a wide range of integrations compatible with most of the platforms and cloud providers.

## Use case

An order processing service for an e-commerce platform is developed in Mulesoft Anypoint studio and deployed on CloudHub. The service consists of an API that accepts the order processing request (experience api) from the e-commerce UI and puts into Amazon SQS queue. Another service (process) that listens to the Amazon SQS queue to get the request message and send to two different service in parallel for processing i.e packaging service(out of scope) and logistic service(out of scope). In case of a failure the order processing request will be pushed into the re-processing queue in Amazon SQS. This design is typically based on API led approach of Mulesoft.

![High level service layout](https://cdn-images-1.medium.com/max/2000/1*8rc7vhCaqif2bUFgdcxK9g.png)

### **Order Processing Service (Mulesoft)**

The experience API in Order processing service is named as exp-orderprocessing-service. The e-commerce platform UI invokes the exp-orderprocessing-service which accepts the request message and publish into the SQS queue (order_process_queue). The service transforms the request message into a canonical structure before publishing to the queue. In case of a failure the error the will be notified via email.

![*exp-orderprocessing-service*](https://cdn-images-1.medium.com/max/2000/1*AVGTbVns3NwFQnxtwl12jQ.png)**exp-orderprocessing-service**

The process API in Order processing service is named as biz-orderprocessing-service. The service listens to the order_process_queue which receives the canonical message which will be transformed and send to packaging and logistics service in parallel for further processing. Mulesoft service uses scatter gather pattern processors to broadcast the message to the services in parallel. In case of a failure the payload will be submitted to re-process queue (order_reprocess_queue) and the error will be notified via email.

![biz-*orderprocessing-service*](https://cdn-images-1.medium.com/max/2000/1*-ozrtJunULqSAukgXT2uzw.png)

## Migrating to Kumologica

In this exercise we have two Mulesoft service to migrate which are developed on Mule 3.9.0. The first service to migrate will be the experience API (exp-orderprocessing-service) and the second service is the process API (biz-orderprocessing-service).

### Prerequisite

1. Kumologica designer installed in your machine. [https://kumologica.com/download.html](https://kumologica.com/download.html)

### Steps

***exp-orderprocessing-service***


![*exp-orderprocessing-service*](https://cdn-images-1.medium.com/max/3168/1*s3IAz5e87vFLzfAX5TUj3A.png)

1. Open Kumologica Designer, click the *Home* button and choose *Create New Kumologica Project*.

2. Enter name (***exp-orderprocessing-service***) and select directory for project.

3. press *Create* Button.

4. Drag and drop EventListener node to the canvas. From mulesoft flow HTTP listener copy the Name, Path and the Method. Open the EventListener settings and provide as given below.

    Name = Name copied from Mulesoft HTTP listener
    Path = Path copied from Mulesoft HTTP listener
    Verb = Method copied from Mulesoft HTTP listener
    Event Source : Amazon API gateway

5. Add Logger node and provide the message provided in Mulesoft flow.

    Name = Name copied from Mulesoft Logger
    Message = Message copied from Mulesoft Logger

Edit the MEL expression as given below.

    **MEL expression in logger**
    #[{"service name" : "exp-orderprocessing-service","object": "order","payload": **message**.**payload**,"logpoint": "Entry"}]

    **Modified expression in Kumologica logger
    **{"service name" : "exp-orderprocessing-service","object": "order","payload": **msg**.**payload**,"logpoint": "Entry"}

6. Add datamapper and provide the following.

    Dataweave expression in Mulesoft
    
    {
    "tx_orderid": payload.OrderID,
    "tx_product": {
    "tx_productname": payload.Product.'ProductName',
    "tx_productid": payload.Product.ProductID,
    "tx_sku": payload.SKU,
    "tx_desc": {
    "Colour": payload.Description.Colour,
    "Width": payload.Description.Width,
    "Height": payload.Description.Height,
    "Depth": payload.Description.Depth,
    "Weight": payload.Description.Weight
    },
    "tx_qty": payload.Quantity
    },
    "t_processdate" : now(),
    "t_deldate" : payload.DelDate,
    "t_addr" : {
    "unit" : payload.Address.Unit,
    "strt" : payload.Address.Street,
    "state" : payload.Address.State,
    "country" : payload.Address.Country,
    "pin" : payload.Address.Pin
    }
    }

    Modified expression in Kumologica

    {
    "tx_orderid": msg.payload.OrderID,
    "tx_product": {
    "tx_productname": msg.payload.Product.'ProductName',
    "tx_productid": msg.payload.Product.ProductID,
    "tx_sku": msg.payload.SKU,
    "tx_desc": {
    "Colour": msg.payload.Description.Colour,
    "Width": msg.payload.Description.Width,
    "Height": msg.payload.Description.Height,
    "Depth": msg.payload.Description.Depth,
    "Weight": msg.payload.Description.Weight
    },
    "tx_qty": msg.payload.Quantity
    },
    "t_processdate" : now(),
    "t_deldate" : msg.payload.DelDate,
    "t_addr" : {
    "unit" : msg.payload.Address.Unit,
    "strt" : msg.payload.Address.Street,
    "state" : msg.payload.Address.State,
    "country" : msg.payload.Address.Country,
    "pin" : msg.payload.Address.Pin
    }
    }

7. Add Amazon SQS node and provide the following

    Name = Name copied from Mulesoft SQS connector
    QueueUrl = Queue url copied from Mulesoft SQS connector
    MessageBody = msg.payload

8. Add Logger node and follow procedure in step 5.

9. Add EventListener End node and provide the following. EventListener End node is the final node in any Kumolgica flow and this step is the only additional component when compared to Mulesoft flow.

    Name : Completed
    Payload : {"status" : "completed"}
    Status Code :  200
    Content-Type :  application/json

*For the exception handling*

10. Add the catch node.

11. Add the logger node and wire to catch node and follow as in step 5.

12. Add the Email node and wire to logger node. Provide the following.

    Name = Name copied from Mulesoft SMTP node
    Host = Host copied from Mulesoft SMTP node
    Port = Port copied from Mulesoft SMTP node
    Username = Username copied from Mulesoft SMTP node
    Password = Password copied from Mulesoft SMTP node
    To = To copied from Mulesoft SMTP node
    From = From copied from Mulesoft SMTP node
    Cc = Cc copied from Mulesoft SMTP node
    Body =  msg.payload

13. Add EventListener End node and provide the following.

    Name : Failure
    Payload : {"status" : "Failed"}
    Status Code :  500
    Content-Type :  application/json

***biz-orderprocessing-service***

![biz-orderprocessing-service](https://cdn-images-1.medium.com/max/4868/1*9xprh7g5CAMcH9WyLtbEzA.png)

1. Open Kumologica Designer, click the *Home* button and choose *Create New Kumologica Project*.

1. Enter name (biz-orderprocessing-service) and select directory for project.

1. press *Create* Button.

1. Drag and drop EventListener node to the canvas and provide the settings as given below.

    Name : Name from Mulesoft SQS listener connector
    Event Source : SQS

Note : SQS queue is attached to the biz-orderprocessing-service flow during the deployment under the cloud tab and hence queue url details is not provided in this node. We will be covering this in detail in our next article.

5. Add Logger node and provide the message provided in Mulesoft flow.

    Name = Name copied from Mulesoft Logger
    Message = Message copied from Mulesoft Logger

Edit the MEL expression as given below.

    MEL expression in logger
    #[{"service name" : "biz-orderprocessing-service","object": "order","payload": message.payload,"logpoint": "Entry"}]

    **Modified expression in Kumologica logger
    **{"service name" : "biz-orderprocessing-service","object": "order","payload": msg.payload,"logpoint": "Entry"}

6. Add the Set-Property node to store the payload. This is required for message re-processing incase of a failure.

    Set 
        $vars.setpayload
    from
        msg.payload

7. Add the Scatter node and wire to Set-Property node.

8. Add two Datamapper node and wire both the datamapper node to the Scatter node. Follow the procedure as in step 6 of exp-orderprocessing-service.

9. Add two HTTP Req node and wire the each node to the datamapper node. From the mulesoft copy the details from HTTP requestor node from InvokePackagingService and InvokeLogisticsService. Provide the copied detail as given below .

    Name : Name of the Mulesoft HTTP Requestor node
    Path : Path of the Mulesoft HTTP Requestor node
    Method : Path of the Mulesoft HTTP Requestor node
    Header : Header of the Mulesoft HTTP Requestor node

10. Add the logger node after both HTTP Req node and follow as in step 5.

11. Add the Gather node to the canvas and wire both the logger nodes to the input terminal of gather node.

12. Add the logger node for Exit point. Follow the procedure as in step 5.

13. Add EventListener End node and provide the following. EventListener End node is the final node in any Kumolgica flow and this step is the only additional component when compared to Mulesoft flow.

    Name : Completed
    Payload : {"status" : "completed"}
    Status Code :  200
    Content-Type :  application/json

*For the exception handling*

14. Add the catch node.

15. Add the logger node and wire to catch node and follow the procedure as in step 5.

16. Add the SQS node and provide the following.

    Name = Name copied from Mulesoft SQS connector
    QueueUrl = Queue url copied from Mulesoft SQS connector
    MessageBody = vars.storepayload

17. Add the Email node and wire to logger node. Provide the following.

    Name = Name copied from Mulesoft SMTP node
    Host = Host copied from Mulesoft SMTP node
    Port = Port copied from Mulesoft SMTP node
    Username = Username copied from Mulesoft SMTP node
    Password = Password copied from Mulesoft SMTP node
    To = To copied from Mulesoft SMTP node
    From = From copied from Mulesoft SMTP node
    Cc = Cc copied from Mulesoft SMTP node
    Body =  msg.payload

18. Add EventListener End node and provide the following.

    Name : Failure
    Payload : {"status" : "Failed"}
    Status Code :  500
    Content-Type :  application/json

## Conclusion

This article has shown you how easy to move a Mulesoft flow to Kumologica without any changes to the flow pattern and with very minimal changes to the MEL expressions used in Mulesoft. Stay tuned for our next part in this series with more interesting use case and migration tricks.

Remember Kumologica is totally free to [download](https://kumologica.com/download.html) and use. Go ahead and give it a try, we would love to hear your feedback. For more details and enterprise support on moving your Mulesoft flows to Kumologica [connect with us ](https://kumologica.com/contact.html).