Debugging the Mule ESB 4.x

ANUPAM GOGOI
4 min readMar 3, 2022

--

Intro

Introduction

This article is not related to debugging a Mule Application in Anypoint Studio. Rather than that it's related to understand the internals of the MuleSoft ESB by debugging it. Unfortunately I couldn’t find too much information in the internet. So, I thought of writing some initial stuffs on it and later on explore in depth.

Source Code

Mule ESB has two versions. One is the Community Version and the another is the Enterprise Edition.

The easiest way to debug the ESB is to run the MuleSoft Enterprise Edition runtime in your localhost and debug it in IntelliJ. Below is the simplest approach I did.

Set-up IntelliJ

Create a java project in IntelliJ and import the following libraries into it.

Mule Enterprise Runtime

Below is my IntelliJ setup.

Configure MuleESB

Next, you need to run the MuleESB in debug mode. It can be done easily by changing the configuration in the below configuration file.

mule-enterprise-standalone-4.4.0/conf/wrapper.conf

Check the configuration below.

Entry-point of Mule ESB

Well, where is the entry-point (a main method) to the MuleESB? It's also simple to find it out. Check the same wrapper.conf.

Entry point

It's the class,

org.mule.runtime.module.reboot.MuleContainerBootstrap

Pretty cool. Huh!!

Browse to the class and you can see the beautiful main() method.

MuleContainerBootstrap

At line 80, you can see that it's calling a Wrapper called EEMuleContainerWrapper. So, when the line 80 is executed,

WrapperManager.start(new EEMuleContainerWrapper(), remainingArgs);

The whole initialization of the ESB takes place. Check how it happens.

Let’s look at the class definition of EEMuleContainerWrapper.

EEMuleContainerWrapper

Check that it's super class is MuleContainerWrapper. Let's look at its content.

MuleContainerWrapper

Voila!!! This is all we need at this moment to know from where exactly everything gets initialized. Check the line 28. The code initializes the below class through reflection.

org.mule.runtime.module.launcher.MuleContainer

And invokes its start() method at line 31 & 32. Now, let's check the MuleContainer class and its start() method and you can see the whole initialization of the Mule Runtime.

MuleContainer

Pretty cool, right!

Start Debugging

Now create a Remote debug configuration in IntelliJ as shown below. Note that I am using the port 5000 as I configured in the MuleESB wrapper.

IntelliJ remote debug

Start the Mule ESB by running the below command:

$ ./mule

You can see that the execution halts at the below point.

Run Mule

Now, put some debug point at the main() method of MuleContainerBootstrap and run your Remote Debug in the IntelliJ. You should be able to debug the ESB.

Debug

Conclusion

In this short article, I have explored how to debug the Mule ESB (EE). It's not even required in a day-to-day basis for a common MuleSoft user but if you want to go in depth to learn what goes on inside the ESB this is a good point of entry.

Happy learning. Thanks!!!

--

--