Posts

Reduce Anypoint Costs: Use Shared Flows Instead of System APIs

Image
This document talks about how to use Shared Flows in MuleSoft. Usually in an API-led connectivity architecture, we have 3 layers: Experience APIs, Process APIs, and System APIs. This drives business agility for an organization, but at the same time increases costs in Anypoint Platform. Specifically, we are talking about costs associated with the Cloudhub Workers (Number and Size of vCores). A Cloudhub Worker is a dedicated Mule instance where an API runs. So, the number of workers required by an organization is at least equal, if not greater than the number of APIs in the application network. This number quickly gets multiplied by 3 or more, based on the number of Non-Prod and Prod environments. One way of saving these costs is replacing System APIs (at least the simpler ones) with Shared Flows. We create a Mule project with generalized flows and publish that project to Anypoint Exchange as a Mule-Plugin. Then, we include that Mule-Plugin as a dependency in other Mulesoft APIs and re-u...

DLQ Dashboard using React JS & Mulesoft

Image
This document talks about one of my most passionate projects  –  the DLQ Dashboard. In short, it's a user-friendly visualization of SQS FIFO Queues, capable of executing basic operations on queue messages. Its frontend is written in React JS, and the backend is coded in Mulesoft. I've polished it a lot and now it's open-source. Alright, that's enough for the introduction. Without further ado, let us jump right into the demo. I've included English Subtitles too; be sure to enable them if needed. Demo Video Now that you've seen the demo, I believe you have a good understanding of what this project is all about. If you want to take a look under the hood and setup these codes in your local environment, I've added repository URLs below. Repository URLs Frontend: React JS Code Backend:  Mulesoft Code Don't forget to checkout the README.md files of these projects to learn more. Useful I...

Dataweave Code to Sort Nested JSON Objects & Arrays

Image
This document covers Dataweave code to sort nested JSON objects and arrays. For this demonstration, we are using Mulesoft's Online Dataweave Playground - Link as an IDE. Let’s begin... Solution Preview Code Snippet %dw 2.0 fun sortObjectAndArray (inputPayload) = (   if(inputPayload is Object) (     inputPayload mapObject ((value, key, index) ->        (key): sortObjectAndArray (value)     ) orderBy $$   )   else if(inputPayload is Array) (     if(inputPayload[0] is Object)       inputPayload map ((item, index) ->          sortObjectAndArray (item)       )     else       inputPayload orderBy $   )   else inputPayload ) output application/json --- sortObjectAndArray (payload) Brief Explanation This code traverses through a nested JSON Object or Array input and sorts it. Here we have a user-defined function named sortObjectAndArra...

GitLab CI/CD Pipeline for CloudHub 2.0 Deployment (with Auto Incrementing Version)

Image
This document covers GitLab CI/CD Pipeline Script for deploying Mule App to CloudHub 2.0. If you are experienced in setting up CI/CD Pipeline for CloudHub 1.0 and have tried to re-use the same script for CloudHub 2.0, then you must have found that it doesn't work. The fact is that Mulesoft's CloudHub 2.0 deployments are tightly coupled with Anypoint Exchange, viz., every Mule App that is deployed in Runtime Manager must be linked with a corresponding instance in Anypoint Exchange. One common hurdle that Mule Developers face when setting up CloudHub 2.0 specific pipelines is how Mule App's version can be automatically incremented whenever a pipeline is started. This is again due to CloudHub 2.0 being tightly coupled with Anypoint Exchange. This document also covers logic to handle that in POM file. Let’s begin... Pre-requisites Mule App GitLab Account with available Runners & configured Deployment/Environment Variables Connected App in Anypoint Platform with Correct Perm...

Role-based AWS Setup for Mulesoft S3 Connector's On New Object Component (Including Local Run Setup)

Image
This document covers setting up AWS Services when using Mulesoft S3 Connector's On New Object component. We'll cover the minimum permissions required (Least-Privilege Access) by this component. The S3 Connector here is configured to use AWS IAM Role-based authentication which is only applicable for CloudHub 2.0 deployments targeted inside a Private Space. The role-based authentication is only supported by latest versions of this connector viz. 6.2.0+. The On New Object component is an event source which triggers Mule flow whenever a new file is uploaded in a S3 Bucket. It sends metadata of the uploaded file as payload. For this component to work, the S3 Bucket must have a notification configuration attached to it with destination set to an SQS Queue. In the end, we'll look over how to deploy and run such Mulesoft Application locally. Let’s begin... Pre-requisites Anypoint Studio (S3 Connector V6.2.0+) Mulesoft Anypoint Platform Account Private Space in Anypoint Platform AWS...