Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

High Availability in Mule 4: Using Clusters

DZone 's Guide to

High Availability in Mule 4: Using Clusters

Here's how you can achieve high availability in your Mule 4 applications.

· Performance Zone ·
Free Resource

Mule Enterprise Edition supports scalable clustering to provide high availability (HA) for applications. High availability is essential for any organizations interested in protecting their business against the risk of a system outage, loss of transactional data, incomplete data, or message processing errors. These risks, in some situations, can add up to millions of dollars in revenue loss. For a business interested in being available at all times, HA clustering is a practical solution.

What Is Clustering?

A cluster is a set of Mule runtime engines that act as a unit. In other words, a cluster is a virtual server composed of multiple nodes. The nodes here refer to Mule runtime engines. The nodes in the cluster communicate and share information through a distributed shared memory grid.

If a Mule runtime engine node becomes unavailable due to failure, another node in the cluster can assume the workload and continue to process the existing events and messages.

Image title

STEP 1:

Download the new Mule standalone runtime version. Example: mule-enterprise-standalone-4.2.0 (in my case). You can download the recent Mule 4 Standalone here.

STEP 2:

Unzip the downloaded zip file. Examine the different folders in mule-enterprise-standalone-4.2.0 folder. Create a folder with the name cluster and two subfolders inside it with the name "Server1" and "Server2" respectively.

Image title

In both folders (server 1 and server 2), copy all files that you located in mule-enterprise-standalone-4.2.0 folder, except the cluster folder (as shown above).

Look at the screenshot below to help make you understand better.

Image title

STEP 3:

Log in to the Anypoint Platform and go to the Runtime Manager --> Servers. Initially, you will find that there is no server listed.

Click on "Add Server" and copy the command that is displayed on the screen.

Image title

STEP 4:

Go to mule-enterprise-standalone-4.2.0 --> cluster --> Server1 --> bin and execute the command.

Image title

Once the command is executed successfully, go to Runtime manager --> Servers and you will see a server listed with the status "Created."

Return to mule-enterprise-standalone-4.2.0 --> cluster --> Server1 --> bin and open a new command prompt and execute mule.bat command, listed at last in the bin folder.

Once the command is executed successfully, return again to Runtime Manager --> Servers, and this time, you will see that status of the server has changed from "Created" to "Running."

STEP 5:

Click on "Add Server"  again to create another server and copy the command displayed on the screen. Perform the same process again as we did in STEP 4, but this time, the command will be executed in mule-enterprise-standalone-4.2.0 --> cluster --> Server2 --> bin (server 2).

Once commands are executed successfully, you will see the two servers listed in Runtime Manager, with the status "Running."

Image title


STEP 6:

Click on Create Cluster. Add server name, pick a cluster type, and select both servers to be added to the Cluster.

Image title

Once you click on "Create Cluster," the Anypoint Platform will restart all servers assigned to the Cluster in order to apply new cluster settings.

Once servers are restarted, the cluster will be displayed in Runtime manager with the status "Running."

Image title

STEP 7:

Go to Applications. Click on Deploy Application. Select the Deployment Target. You will see that your cluster is listed in Deployment Target.

Image title

Choose your cluster as the deployment target whenever you want to deploy your application and the application will be deployed to both servers associated with the cluster.

Happy Learning!!

Topics:
integration ,mule 4

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}