Mule Sample Examples

Mule is a lightweight integration platform that enables you to connect anything, anywhere. Rather than creating multiple point-to-point integrations between systems, services, APIs, and devices, you can use Mule to intelligently manage message routing, data mapping, orchestration, reliability, security, and scalability between nodes. Plug other systems and applications into Mule and let it handle all the communication between systems, enabling you to track and monitor everything that happens.

Mule is so named because it "carries the heavy development load" of connecting systems.

Mule ESB hello world example

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
	xmlns:spring="http://www.springframework.org/schema/beans"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	http://www.mulesource.org/schema/mule/core/2.2
	http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
	http://www.mulesource.org/schema/mule/stdio/2.2
	http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd">
	<stdio:connector name="SystemStreamConnector"
		promptMessageCode="3" promptMessage="Welcome to Mule Munna"
		messageDelayTime="1000" />
	<model name="welcomeModel">
		<service name="welcomeService">
			<inbound>
				<stdio:inbound-endpoint system="IN" />
			</inbound>
			<outbound>
				<pass-through-router>
					<stdio:outbound-endpoint system="OUT" />
				</pass-through-router>
			</outbound>
		</service>
	</model>
</mule>

Here, mule is the main tag and inside model is set of services. As per above program find the core concepts.
Connector:
STDIO Connector (Standard input output) means input will pass through console and output will display at console. Here inbound and outbound is stdio connector only.
Endpoints:
STDIO inbound and outbound endpoints.
Router:
pass-through-router will do whatever input is coming from inbound, it will send as it is to outbound.
Here we are not using any Transformer, Filters and Components.
After writing mule configuration we can start the mule server by running this configuration.
Right click on mule configuration file (xml)->Run as->Mule server.
Below is our output:
Welcome to Mule Munna
INFO   2012-08-05 17:56:07,304 [SystemStreamConnector.dispatcher.1]
org.mule.transport.stdio.StdioMessageDispatcher:
Connected: endpoint.outbound.stdio://system.out
HI

Welcome to Mule Munna
INFO; 2012-08-05 17:56:08,385 [SystemStreamConnector.dispatcher.2] 
org.mule.transport.stdio.StdioMessageDispatcher:
Connected: endpoint.outbound.stdio://system.out
HI

Welcome to Mule Munna
Hi
INFO   2012-08-05 17:56:12,016 [SystemStreamConnector.dispatcher.3]
org.mule.transport.stdio.StdioMessageDispatcher:
Connected: endpoint.outbound.stdio://system.out
Hi
Welcome to Mule Munna
Hi

Output Details:
"Welcome to Mule Munna" will be displayed by program then it will wait for our input through console. I have given "HI". In this program I am not doing any operation on input. Directly whatever input we are getting from console, it will display at console. Program execution will be 3 times extra with messageDelayTime.
<stdio:connector name="SystemStreamConnector"
       promptMessageCode="3" promptMessage="Welcome to Mule Munna" messageDelayTime="1000"/>