In our previous article “Migration from Mulesoft to Kumologica — Part 1” 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 and Mulesoft. If you haven’t got chance to read the article I would suggest to go through our part 1 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 and youtube videos to get an insight. Kumologica 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.
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.
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.
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
- Kumologica designer installed in your machine. https://kumologica.com/download.html
Steps
exp-orderprocessing-service
Open Kumologica Designer, click the Home button and choose Create New Kumologica Project.
Enter name (exp-orderprocessing-service) and select directory for project.
press Create Button.
-
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 -
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"}
-
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
}
} -
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 Add Logger node and follow procedure in step 5.
-
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
Add the catch node.
Add the logger node and wire to catch node and follow as in step 5.
-
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 -
Add EventListener End node and provide the following.
Name : Failure
Payload : {"status" : "Failed"}
Status Code : 500
Content-Type : application/json
biz-orderprocessing-service
Open Kumologica Designer, click the Home button and choose Create New Kumologica Project.
Enter name (biz-orderprocessing-service) and select directory for project.
press Create Button.
-
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.
-
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"}
-
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 Add the Scatter node and wire to Set-Property node.
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.
-
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 Add the logger node after both HTTP Req node and follow as in step 5.
Add the Gather node to the canvas and wire both the logger nodes to the input terminal of gather node.
Add the logger node for Exit point. Follow the procedure as in step 5.
-
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
Add the catch node.
Add the logger node and wire to catch node and follow the procedure as in step 5.
-
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 -
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 -
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 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 .
Top comments (0)