Mule VM Transport with HTTP Example

This tutorial will show you how to use VM Transport with HTTP Connector in Mule based application.

What is VM Transport

The VM transport is nothing but an in-memory transport. Therefore when a message has to be passed through a VM endpoint, i.e., the message is being transferred from one endpoint to another endpoint in memory. So the VM transport can be used for intra-JVM communication between Mule flows. It can be used only in single Mule application and cannot be used to communicate between two or more Mule applications. This transport by default uses in-memory queues but can optionally be configured to use persistent queues. However, VM file persistency does not work on clusters.

By default VM transport is synchronous – messages pass through VM transport are delivered in a point-to-point fashion.


Mule Studio 3.x(Anypoint Studio) (Download from
Maven 3.2.1 (Download from
JDK 1.7 (Download from

Configure JDK, Maven and Mule Studio

Step 1. First install JDK
Step 2. Add the Java_Home/bin directory to your system’s PATH.
Step 3. After downloading Maven, extract it to a drive
Step 4. Add the M2_Home/bin directory to your system’s PATH.
Step 5. Download and extract Mule Studio to a drive
Step 6. Now start Mule Studio by clicking on AnypointStudio exe icon in the folder <physical drive>/AnypointStudio
Step 7. Once started, close the startup page
Step 8. In Mule Studio, go to Window -> Preferences. Expand Java, then click on Installed JREs. Add JDK 1.7 and select it. In expanded Java, click on Compiler and select the compiler level as 1.7
Step 9. Now expand Anypoint Studio and click on Maven Settings. Then select appropriate Maven installation home directory using Browse button.
Step 10. If you want you can input Default groupId for new projects, it will save your time every time when you want to create a new project.

Create Mule project in Mule Studio

Now we will see how to create a new project in Mule Studio(Anypoint Studio).

Step 1. In Anypoint Studio, go to File -> New -> Mule Project
Step 2. Input Project Name: mule-3, Runtime is by default selected, tick on Use Maven; here the artifactId is automatically picked up from the Project Name:, the Group Id is picked up from the Default groupId for new projects and version is also a default value.
Step 3. Click Next and verify the JDK, mainly select Use default JRE(currently ‘jdk1.7.0_x’)
Step 4. Click on Next and click on Finish.

So when the project mule-3 is created in the Anypoint Studio, the project structure looks like below

mule stdio


Final Output in the browser

mule vm transport

VM example

The layout of the VM configuration in the Anypoint Studio visual editor

mule vm transport

In this example, if you configure an outbound VM endpoint called vm://vm-path but do not have a corresponding inbound endpoint, Mule will raise an error and explain that this message cannot be routed.

Here the VM transport is configured as a request-response exchange-pattern.

In the above screen-shot we have two Mule flows – vmFlow1 and vmFlow2.

In vmFlow1 we have HTTP and VM connectors. Here the address for VM transport is given as address=”vm://vm-path” (equivalent to path=”vm-path”), see in the below vm.xml configuration.

Here HTTP connector acts as an inbound endpoint and VM acts as an outbound endpoint.

When you type the URL http://localhost:8081/Hello in the browser, the payload “Hello” is routed to vm-path(or vm://vm-path).

In vmFlow2 we have VM connector, Set Payload component and Logger component. Here the path of the VM transport is given as path=”vm-path” (equivalent to address=”vm://vm-path”), see in the below vm.xml configuration.

Here VM transport acts as an inbound endpoint. The VM transport receives the payload from vm://vm-path (or vm-path).

Set Payload component sets the incoming payload coming from VM transport.

Logger component displays the payload coming from Set Payload in the console.

Step 1. You can rename the src/main/app/mule-3.xml file as vm.xml file.
Step 2. Open the vm.xml file and click on Configuration XML view in the Editor
Step 3. Modify the vm.xml file as shown below

In the above vm.xml configuration you can use either address or path or ref in VM transport.

Running the application

Now do a right-click on the stdio.xml file or on the mule-3 project and click on Run As -> Mule Application. Then you will see something like below in Console when the application runs

Console output

Thanks for reading.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.