Mule ESB

Mule is a lightweight open source ESB that is not bogged down by standards but yet enables to integrate applications that support various open standards. By bogged down I mean – its not a JBI compliant ESB. Yes and it supports JMS, Web Services, Java POJO.

For a general overview of ESB see my article from some time back – Enterprise Service Bus. An ESB is made up of a high-performance messaging layer (such as ActiveMQ) and the ESB software itself (Mule). The ESB software provides integration services to create/host/manage business services, mediation, content transformation, routing, security and so on.

To get started go to and download the software. I downloaded the full version – 2.2.1. For the messaging layer go download ActiveMQ from (the version I used is 5.2.0 … latest as of today is 5.3.2). Finally I am using Eclipse 3.5 and also installed the Mule IDE Eclipse Plugin (Plugin).

Once you have the Mule Eclipse plug-in installed , create a new Mule project and then add the code below to make it work.

Our use case is:

  • Purchase Orders come in XML .dat files to a folder.
  • We want to scan the folder periodically and load up any incoming files.
  • Now we want to check if the PurchaseOrder for item with part number as “WXJ-1”.
  • If the part number is found then that purchase order is routed to the JMS Queue “ImportantPOQ”
  • All other orders are routed to JMS Queue “AllOtherPOsQ”

To begin, configure the JMS connector in the mule-config.xml:

Next Configure the file connector to poll for incoming files:

The service itself is configured as:

A Mule Service has a inbound router , a service component and an outbound router. The inbound router is used to configure how the service will consume messages and from where. In this case you can see the use of the file connector to read files from a predefined folder.

The Service component typically contains your business logic. For the purposes of this article I do not have a service component. Instead I use a predefined log component to print out the file contents to the console.

The outbound router is used to configure where the processed messages will go once the business component is finished with it. In this case I configure a filtering-router which sends messages to the queue ImportantPOQ if the part number is WXJ-1. The forwarding-catch-all-strategy router is used for all other unmatched messages.

I have a little utility class that spits out a bunch of test xml files. The project structure in Eclipse should look like this…

Ignore the java classes since my next task is to send the PurchaseOrder to a POJO service component. For the purposes of this article there is no java code used.

Start your ActiveMQ server and create the two queues noted in the mule-config.xml. Right click on the mule-config.xml -> RunAs -> Mule Server. If everything goes well the server should start and be polling for files in the predefined folder. Run the to put some files into your folder and in a few seconds you should see that the files are processed, moved to the processed folder. Go to the ActiveMQ web admin page at localhost:8161/admin/queues.jsp. You should see messages in both queues. Most will end up in the AllOtherPOsQ. Any messages with partnumber as WXJ-1 will end up in the ImportantPOQ.

Download the project by clicking here Mule Sample.