Mule ESB Hello World Example

 

Mule ESB is a Java-based Enterprise Service Bus (ESB) that allows to implement communication between applications in a service oriented architecture (SOA).

In this example, we will create a simple Mule application to implement the following flow :

Mule-ESB-Hello-World-Example-1

The flow accepts HTTP requests, sets a payload on the message, applies some transformation on the payload, and finally returns a response to the end user.

So we will use  :

  • HTTP endpoint : it allows, in the beginning of the flow, to receive request from the end user, and, in the end of the flow, to return the message as response to the end user.
  • Java Transformer : to apply a custom transformation on the payload : "Hello " + {payload}
  • Echo component : to display the message payload.

 

1. Technologies used

  • Anypoint Studio
  • JDK 1.7

 

2. Mule XML Editor

The following is the flow in XML representation :

 

3. Java Transformer

To apply a custom transformation on the message payload, we have used Java Transformer.

The following is the class called by the Java Transformer :

 

5. The video tutorial

It demonstrates how to build and test the Mule application used in this tutorial :

 

Download source code

  • Abhishek Bhatt

    I am following the video tutorial for Key Transformer. The application is deployed successfully, but localhost shows Hello NullPayload} every time. Any inputs on how to resolve the problem?

    • Ali Baba

      You should replace your “Mule XML Editor” in tab “Configuration XML” by the XML represented above.