Professional Documents
Culture Documents
Mule Framework Guideline
Mule Framework Guideline
Mule Framework Guideline
2009
2009
Table of Contents
1.1.
Introduction
Installation
1.2.
Prerequisites
1.2.1.
Download
1.2.2.
4
5
5
5
1.3.
1.4.
Configuration File
1.5.
Running Mule
Mule Examples
1.6.
Hello World Example
1.6.1.
Loan Broker Example
1.6.2.
10
10
10
12
12
12
12
13
16
16
18
18
19
Mule as ESB
1.9.
Mule JMS EventBus Example
1.9.1.
21
23
Abbreviation
UMO = Universal Message Object
ESB = Enterprise Service Buss
2009
2009
1.1. Introduction
Mule is a light-weight messaging framework. It is a highly distributable object broker that can seamlessly handle
interactions with other applications using disparate technologies, transports and protocols.
The Mule framework provides a highly scalable environment in which you can deploy your business components.
Mule manages all the interactions between components transparently whether they exist in the same VM or over the
internet and regardless of the underlying transport used.
Mule was designed around the Enterprise Service Bus architecture, which stipulates that different components or
applications communicate through a common messaging bus, usually implemented using Jms or some other
messaging server.
Mule architecture is scalable, highly distributable object broker that can seamlessly handle interactions across legacy
systems, in-house application and almost all modern transports and protocols. Mule is feature rich & easy to deploy.
The diagram below shows a common scenario with Mule. Mule applications usually consist of many Mule instances
across the network. Each instance is a light-weight container that hosts one or more UMO component. Each UMO
component will have one or more endpoints that it will send and receive events through.
2009
1.2. Installation
1.2.1. Prerequisites
Following are the prerequisites you must meet before you can install Mule.
Supported Operating Systems
Mule will run on any platform that supports JAVA, including:
Mac OSX
Java Developer Kit (JDK) 1.4x or greater is required for deploying Mule. JDK 1.5.x is required for building Mule
from the source code. Download.
The JAVA_HOME environment variable must be set to the directory where the JDK is installed, e.g.
C:\java\j2sdk1.4.2_08
Your path environment variable must contain the path to the JDK bin directory, such as
C:\java\j2sdk1.4.2_08\bin.
Ant 1.7.0 is required to build from source code & running some examples.
Maven 1.0.2 is required for building from the source code and running some of the examples. Download.
A compression tool such as WinZip (Windows) or GZip (Linux/Unix) is required for decompressing the Mule
distribution of the community edition, snapshot release, or source code.
For Linux/Unix users working from a shell, a download tool such as wget or _ftp _is required for downloading
the Mule distribution.
1.2.2. Download
Latest editions of mule are available at the following link. Download the full distribution of Mule2.0. Downloading
mule will take good amount of time so start downloading go to grab a cup of tea.
http://mule.mulesource.org/display/MULE/Download
5
2009
/bin - Shell and batch scripts for controlling Mule from the command line
/docs - API documentation (Javadoc) for Mule and its sub-projects (not included in the Developer releases)
/examples - Example applications you can run and try building yourself (not included in the source
distribution)
/lib/boot - Libraries used by the Java Service Wrapper to boot the server
/lib/user - Your custom classes and libraries. This directory comes before
/lib/mule on the classpath and can therefore be used to patch the distributed Mule classes if necessary. If
you add files to this directory when Mule is already running, you must restart Mule after adding the files.
/src - The source code for all Mule modules. You can import this into your IDE.
Download mail-1.4.jar from the following link & put it in <MULE_HOME>/lib/boot directory.
http://repo1.maven.org/maven2/javax/mail/mail/1.4/mail-1.4.jar
Note: Mule includes connectors for a wide variety of technologies. Some connectors use libraries that cannot be
distributed as part of Mule because of licensing restrictions. For these connectors, you must obtain the required
libraries and place them in the MULE_HOME/lib/user directory.
Visit the following link for more information about installation.
http://mule.mulesource.org/display/MULE2INTRO/Home
2009
2009
2009
2009
2009
All other examples can be run in the same way explained above. Visit the following link for more examples
http://mule.mulesource.org/display/MULE2INTRO/Home
11
2009
1.7.2. Prerequisites
Java 5 or higher
Mule IDE has been tested with the Europa (3.3) version of Eclipse IDE for Java Developers using a Java 5 JRE.
2009
7. Now restart the eclipse & follow the same steps to install plug-in MuleIDE-2.0.0.M2-I200804251604.
Visit the following link for more information on MuleIDE installation.
http://www.mulesource.org/display/MULEIDE/Mule+IDE+2.0
13
4. Run application on mule server using configuration file shown in the figure below.
14
2009
15
2009
2009
Visit the following link to know more about mule spring integration.
http://mule.mulesource.org/display/MULE2USER/Spring
Mule Manager
The Mule Manager is the primary component for each instance of a Mule server and is used to manage all Mule
objects (connectors, endpoints, transformers, etc.) for each Mule server instance. All objects are registered with
the MuleManager. The AutowireUMOManagerFactoryBean is responsible for determining the UMOManager to
implement, creates a default UMOModel and autowires the components to the model and all other global
objects to the MuleManager.
16
2009
Mule name processors are use to set mule object names to their corresponding bean id.
Connector
A connector is the object that sends and receives messages on behalf of an endpoint. Connectors are bundled as
part of specific transports or providers.
Transformer
Transformers are used to convert inbound data to an object type required by the UMO Component or outbound
to an object type required by the transport such as a JmsMessage. Transformers can be configured on Endpoints
that receive data to ensure that the expected object type is always received by an UMO Component.
Transformers configured on an Outbound endpoint ensure that the endpoint receives the the correct object type
before dispatching the event. Multiple transformers can be chained together to allow for finer grained
transformer implementations that are easier to reuse. To configure an Endpoint to use more than one
transformer, just specify a space separated list of transformers in the config file or programmatically chain the
transformers together using the setTransformer() method on the transformer.
Interceptor
An interceptor is a piece of code that can be configured to execute before and/or after an event is received for a
component. User can define a stack of interceptors that will be executed in sequence. User can then configure
the stack on your components. Note the interceptor stack must not be a singleton. Each component needs its
own copy of an interceptor stack.
A Mule descriptor defines all the necessary information about how your components will interact with the
framework, other components in the system and external sources.
Sample configuration file is attached here.
17
2009
18
2009
This example is about Restaurant Service. This application consists of following package.
com.agilent.mulespring
This package consists of following classes & one application config file.
RestaurantWaiter.java
RestaurantWaiterInput.java
Transformer
RestaurantWaiterPayload.java Payload
KitchenService.java
KitchenServiceInput.java
Transformer
KitchenServiceOutput.java
Transformer
KitchenServicePayload.java
Payload
In this application it is show how to start mule service via spring application context xml file. You can see the config
file attached in section 1.8.1
19
2009
This example demonstrates that two spring components can exchange messages / objects using mule services. This
application is ready & working in my Eclipse environment. If the readers want to have a glance to code the let me
know I will share the project.
Note: Currently this example is implement using mule 1.4.3. Documentation & examples for Mule 2.0 is not available
for now. We need to do little investigation for the same.
20
2009
With ESB
21
2009
Mule is a light-weight messaging framework. It is a highly distributable object broker that can seamlessly handle
interactions with other applications using disparate technologies, transports and protocols. Mule was designed
around the Enterprise Service Bus architecture Mule's ultimate goal is to be the "Swiss-army knife" of integration.
Mule talks lots of different protocols
Mule can route, transform and filter messages, transactions, security, management etc.
Mule support the following implementations of JMS.
ActiveMQ
JBoss MQ
Joram
OpenJms
Oracle AQ
SeeBeyond
SonicMQ
Tibco EMS
UberMQ
22
Weblogic Jms
IBM WebSphere MQ
SwiftMQ
FioranoMQ
2009
We have looked in to ActiveMQ implementation of JMS. Following is the JMS ActiveMQ configuration. This
configuration will go in mule-config.xml file.
I am not able to implement JMS using spring application. Investigation is going on for the same. I will update this
document with all my findings.
23
2009
Sample application comprises of two components as show above Component1 & Component2. Both component take
inputs from console & send it to other component that display it on console. User has to type message from console.
Component1 is a publisher of topic my.q1 & Component2 is a consumer of topic my.q1 & viceversa. Both
components exchanges messages using ActiveMQ JMS.
Note: ActiveMQ server is running on machine1. Mule is not JMS server. We need to run ActiveMQ server separately.
Message exchange between these two components is using ActiveMQ JMS. We have to provide following
information in mule-config.xml
Connectors:
Transformers:
Interceptors:
Application Components:
Sample application is using following connectors
24
25
2009
Both components shown above consist of two UMOs i.e PublisherUMO & ConsumerUMO.
UMO configuration of Component1 is as follow
26
2009
2009
As show in above configuration setting, publisherUMO is reads input from console & send it to other component.
ConsumerUMO receives JMS message from other component & displays that message on the console.
Execution
Following figure shows, sender sends a message using publisherUMO & receives an response using consumerUMO.
27