0% found this document useful (0 votes)
109 views

Mule ESB Hello World Example

This document provides an example of creating a simple "hello world" Mule application that accepts HTTP requests, transforms the payload by adding "Hello" to the string, and returns a response. It includes the XML configuration, a Java transformer class to do the transformation, and a note about a video tutorial demonstrating how to build and test the Mule application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views

Mule ESB Hello World Example

This document provides an example of creating a simple "hello world" Mule application that accepts HTTP requests, transforms the payload by adding "Hello" to the string, and returns a response. It includes the XML configuration, a Java transformer class to do the transformation, and a note about a video tutorial demonstrating how to build and test the Mule application.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ABOUT ME CONTACT FEED RSS

Home All tutorials Java Frameworks Spring SOA Mobile

More..

Home / 2014 / November / 18 / Mule ESB Hello World Example

Mule ESB Hello World Example


November 18, 2014 – by walid 2 Comments

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

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

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

So we will use  :

HTTP endpoint : it allows, in the beginning of the ow, to receive request from the end user, and, in the
end of the ow, 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 ow in XML representation :

1 <?xml version="1.0" encoding="UTF-8"?>


2 <mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/sche
3     xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
4     xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0"
5     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.
7 http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.
8 http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-
9  
10     <flow name="mulehelloworldexampleFlow1" doc:name="mulehelloworldexampleFlow1">
11         <http:inbound-endpoint exchange-pattern="request-response"
12             host="localhost" port="8081" doc:name="HTTP" />
13         
14         <custom-transformer class="com.keylesson.transformer.KeyTransformer"
15             doc:name="Key Transformer" />
16         
17         <echo-component doc:name="Echo" />
18     </flow>
19 </mule>

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 :

1 package com.keylesson.transformer;
2  
3 import org.mule.api.transformer.TransformerException;
4 import org.mule.transformer.AbstractTransformer;
5  
6 public class KeyTransformer extends AbstractTransformer {
7     @Override
8     protected Object doTransform(Object src, String enc)
9             throws TransformerException {
10         return "Hello " + src.toString().substring(1);
11     }
12 }

5. The video tutorial
It demonstrates how to build and test the Mule application used in this tutorial :

You might also like