How do you run the application in the background

We all know about API led approach in MuleSoft, where we work with 3 layers e.g. experience layer, process layer and system layer. In smaller scale project you might not come across any problems but at enterprise applications, you might need to work with two or more layers at a time. Let’s assume, we are working with process layer which connects to system layer, while we’re working with process layer we might need to run the system layer as well to successfully run/debug the process layer. Because if your system layer is not available/running while you’re running/debugging process layer it will throw you error like below when it would try to connect to system layer.

“Error sending request to http://localhost:8081/somepath/

There are multiple ways you can solve this problem. One way import system and process layers projects into same workspace and then configure Run Configurations/Debug Configurations to run and/or debug both applications simultaneously.

Though it’s good way to go but there’s a major drawback of doing this and that is whenever you want to stop one application it will stop other application as well. That means, you might want to stop running process layer and do some modification but in the process it will also stop the system layer as well. Every time you want to run or debug the process layer, system layer will also start running which is not necessary and can be time consuming in case of large scale applications. What if you want to keep system layer running while you constantly working on process layer?

There is another drawback in this process which is more obvious. You can not change the way of running of each layer projects. That means, if you start your process layer in debug mode, it will also kick off system layer in debug mode. But what if you want to run process layer application in debug mode because you want to debug through the flows but you don’t want to debug system layer?

To address these drawbacks, Mule Runtime Standalone Engine comes to rescue. Let’s see how we can achieve this:

Step 1: Download and install JDK 1.8.xxx from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html . Please note JDK 1.8 with any minor version is recommended. Do not install JRE or JDK with different major version other than 1.8

Step 2: Download Mule 4 Standalone Runtime from https://www.mulesoft.com/lp/dl/mule-esb-enterprise

Step 3: Extract Mule 4 Runtime in root folder. I will demonstrate in terms of Windows OS. It’s recommended to put Mule 4 Runtime in any drives with less or no nested folder hierarchy. This is because Windows has character limitations in folder/file path which might be the issue while extracting contents from compressed folder.

Step 4: After extracting navigate inside Mule runtime folder and then navigate to /bin folder. Run command prompt/terminal window from that location.

Step 5: Execute following command to run Mule Runtime in your machine.

Windows: mule.bat (or mule)

Unix: sudo ./mule

This will kick off Mule Runtime Server in your machine. Wait for it to start.

Step 6: Once server is started navigate to the Mule Runtime installation location and look for /apps folder.

Step 7: Put your application deployable jar file inside that folder. In our case we want to run system layer in Mule Runtime. Let’s try to do that and have a look at the terminal window, you’ll see that your application will be deployed in some time.

Please note that if your application belongs to different domain other than default then you need to deploy your domain projects first before you can deploy your application otherwise it will throw error. To deploy your domain projects, navigate to the /domains folder and paste your domain project jar. It will kick off domain project and then you can follow Step 7 to deploy your application.

Now, your system layer application will run inside Mule Runtime while you can run or debug your process layer from Anypoint Studio. You don’t have to run system layer every time.

To see logs of applications running in your Mule Runtime, navigate to /logs folder inside your Mule Runtime installation directory, then you can see a log file has been created with same name as your application name.

Author

Jyoti Choudhury

Written by Incepta

March 27, 2019

You May Also Like…

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Connect With Us

Our Office

Incepta Solutions
Suite 303, 2585 Skymark Avenue,
Mississauga,
ON, L4W 4L5

Contact Us

(905) 754-0557
hello@inceptasolutions.com

Office Hours

Mon-Fri: 9am - 5pm
Sat-Sun: Closed

Pin It on Pinterest