Copyright
Copyright 2003-2010, MuleSoft, Inc. All rights reserved. No part of this publication may be copied or distributed,
transmitted, transcribed, stored in a retrieval system, or translated into any human or computer language, in any form or
by any means, electronic, mechanical, magnetic, manual, optical, chemical or otherwise; or disclosed to third parties
without the express written permission of MuleSoft, Inc.
Disclaimer
Information in this document is subject to change without notice and does not represent a commitment on the part of
MuleSoft, Inc. The software described in this document is furnished under a license agreement or nondisclosure
agreement. The software may be used or copied only in accordance with the terms of the agreement. It is against the law to
copy the software on any medium except as specifically allowed in the agreement.
In addition, MuleSoft, Inc makes no representation or warranties either express or implied, with respect to this manual
and accompanying software and specifically disclaim any implied warranties of merchantability or fitness for any
particular purpose. This manual and accompanying software are sold as is and MuleSoft, Inc will in no event be liable
for direct, indirect, incidental or consequential damages resulting from any defect, error or failure to perform except as
expressly set forth in the license agreement.
Trademarks
MuleSoft, Mule and MuleForge are among the trademarks of MuleSoft. All other product names are trademarks of their
respective companies.
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Who Should Read This Guide? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Whats the Fastest Way Through This Guide? . . . . . . . . . . . . . . . . . . . . 7
Existing Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Typographic Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Mule Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Chapter 1
Introduction to Mule ESB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
What is Mule ESB? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Understanding the Messaging Framework . . . . . . . . . . . . . . . . . . . . . . 11
Understanding the Mule ESB Architecture. . . . . . . . . . . . . . . . . . . . . . 12
About SOA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Processing the Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Routing Messages Between Service Components. . . . . . . . . . . . . . 14
Separating Business Logic from Messaging . . . . . . . . . . . . . . . . . . 15
Wiring Everything Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Understanding the Logical Data Flow . . . . . . . . . . . . . . . . . . . . . . . . . 18
Integrating Mule ESB into Your Environment . . . . . . . . . . . . . . . . . . . 21
Administering Mule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Managing Your Deployments with the Management Console. . . . 23
Controlling the Infrastructure with the Service Registry . . . . . . . . 23
Monitoring Mule Instances Using JMX . . . . . . . . . . . . . . . . . . . . 24
Compatible Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Application Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
JMS Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Developer Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Transports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Web Service Technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Data Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Deployment Topologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Event Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Chapter 2
Installing and Running Mule. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Installing Mule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Distribution Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Compatible Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Installing Third-Party Software . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Setting Up Your Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Installing Mule Enterprise. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Installing the Community or Snapshot Release . . . . . . . . . . . . . . . 36
Installing Multiple Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Setting Up Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Build the Hello Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Generate the Eclipse Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Configure Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Import the Eclipse Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Configure the Eclipse Build Path . . . . . . . . . . . . . . . . . . . . . . . . . 41
Create a Run Configuration and Run the Application . . . . . . . . . 42
Installing and Configuring Mule IDE . . . . . . . . . . . . . . . . . . . . . . . . . 43
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Installing Mule IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Configuring the Mule Distribution. . . . . . . . . . . . . . . . . . . . . . . . 45
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Running Mule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Create a Service Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Configure the Mule Instance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Configure the Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Extend Mule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Where Do I Go Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Chapter 3
Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Lesson 1: Creating an Application Using Mule IDE . . . . . . . . . . . . . . . 51
Chapter 4
Using Mule IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Creating a New Mule Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Creating a New Mule Configuration File . . . . . . . . . . . . . . . . . . . . . . . 88
Testing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Debugging the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Switching Mule Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Appendix A
Distribution Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Appendix B
Third-party Software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
The Mule Getting Started Guide introduces Mule and related products from MuleSoft. It
provides the conceptual information and context that everyone from decision makers to
programmers need to get started with planning and implementing Mule.
Existing Users
If you are an existing user, go to http://mule.mulesource.org/x/J4H8 to learn about the
new features and how to migrate your configuration files to this release. Mule Enterprise
customers can use the migration tool and follow the instructions in the Migration Guide,
both available from the Downloads page on the MuleSoft customer portal (log in at
http://mulesupport.mulesource.com/portal/login.mule.
Typographic Conventions
The following table describes the typographic conventions used in the Mule documentation:
This chapter describes Mule ESB, its architecture, and how it is useful to your enterprise. It
contains the following sections:
What is Mule ESB? on page 10
Understanding the Messaging Framework on page 11
Understanding the Mule ESB Architecture on page 12
Understanding the Logical Data Flow on page 18
Integrating Mule ESB into Your Environment on page 21
Administering Mule on page 23
Compatible Technologies on page 24
Summary on page 29
The Mule framework is highly scalable, allowing you to start small and connect more
applications over time. Mule ESB manages all the interactions between applications and
components transparently, regardless of whether they exist in the same virtual machine or
over the Internet, and regardless of the underlying transport protocol used.
Mule ESB is based on ideas from Enterprise Service Bus (ESB) architectures. The key
advantage of an ESB is that it allows different applications to communicate with each other
by acting as a transit system for carrying data between applications within your intranet or
across the Internet. There are currently several commercial ESB implementations on the
market. However, many of these provide limited functionality or are built on top of an
existing application server or messaging server, locking you into that specific vendor. Mule
ESB is vendor-neutral, so different vendor implementations can plug in to it. You are never
locked in to a specific vendor when you use Mule ESB.
MuleSoft also provides administration tools that allow you to manage your deployments
(Mule Management Console) and control your infrastructure (Mule Galaxy). These tools are
described in more detail in Administering Mule on page 23.
The next section provides more detail on the messaging framework and how Mule ESB
exchanges data among applications.
Message
Application 1 Application 2
Data
Channel
At the simplest level, when you connect applications to Mule ESB, it reads data from one
application, transforms it as needed so it can be read by the target application, and sends it to
that application. This allows you to integrate all types of applications, even those that were
not built to be integrated.
Mule ESB is a messaging framework based on ideas from Enterprise Service Bus (ESB)
architectures. The key advantage of an ESB is that it allows different applications to
communicate with each other by acting as a transit system for carrying data between
applications within your intranet or across the Internet. The heart of the system is the
message bus, which routes messages between applications.
One difference between Mule ESB and a traditional ESB is that Mule ESB only converts data
as needed. With a typical ESB, you have to create an adapter for every application you
connect to the bus and convert the applications data into a single common messaging
format. The development of these adapters and the time required to process every message
requires a lot of time and effort. Mule ESB eliminates the need for a single message format.
The information is sent on any communication channel, such as HTTP or JMS, and is
translated only as needed along the way. Therefore, Mule ESB increases performance and
reduces development time over a traditional ESB.
The Mule ESB architecture and terminology use the principles described in the book
Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions by
Gregor Hohpe and Bobby Woolf. This book is highly recommended reading for anyone
involved in working with enterprise messaging solutions. For more information, see
http://www.enterpriseintegrationpatterns.com.
Message Message
Order Entry Order
Application Process Invoice Fulfillment
Updated Application
Invoice
Invoice
About SOA
Mule ESB is based on the concept of a service-oriented architecture (SOA). The SOA
approach to development allows IT organizations to create applications by bringing together
components of application functionality, or services. Services are discrete sets of functionality
that are completely separate from each other but can work together on the same objects. For
example, if you need to process invoices, you might have one service that merges customer
data from a database into the invoice and another service that checks the inventory database
to see if the items on the invoice are in stock.
Because each service stands alone, services can be used as building blocks for multiple
processes and do not have to be recreated for each type of process or message. For example,
the service that merges customer data onto the invoice could also be used to merge customer
data onto statements, letters, or other documents. This modular approach allows you to
create functionality once and re-use it as many times as needed, streamlining development.
Using SOA, businesses can realize dramatic savings on development costs and can rapidly
adapt to changing business conditions by reusing and reconfiguring existing services in
developing new applications. SOA also enables better integration of enterprise IT resources,
including previously isolated application silos and legacy systems. Mule ESB fully supports
the SOA approach and orchestrates communication among the services, allowing you to
easily tie all these applications together.
service is the service component. The service component executes business logic on messages,
such as reading the invoice object, adding information to it from the customer database, and
then forwarding it to the order fulfillment application.
Customer Database
Message Message
Customer Data Order
Order Entry
Application Service Fulfillment
Component Updated Application
Invoice
Invoice
Configuration
Settings
Service
An important feature of the service component is that it doesnt have to have any Mule
ESB-specific code; it can simply be a POJO, Spring bean, Java bean, or web service
containing the business logic for processing data in a specific way. Mule ESB manages the
service component, bundles it with configuration settings and exposes it as a service, and
ensures that the right information is passed to and from it based on the settings you specified
for the service in the Mule ESB configuration file.
You can have many different service components that perform different business logic, such
as one that verifies whether the items on the invoice are in stock and one that updates a
separate customer database with the order history. The invoice, which is encapsulated in a
message, can flow from one service component to the next until all the required processing is
complete.
Inbound routers specify which messages the service component will process. They can filter
incoming messages, aggregate them, and resequence them before routing them to a service
component. For example, if a service component subscribes to an RSS feed, the inbound
router could filter which messages it receives from that feed.
After a service component has processed a message, the outbound router specifies where to
dispatch the message. For example, it might route invoices for in-state addresses to one
shipping department and route all other invoices to another shipping department. You can
define multiple inbound and outbound routing constraints and even chain routers together
so that a service component receives and routes messages exactly as required.
Domestic
Customer Data Order
Service Fulfillment
Component Application
Message
Updated
Inbound Router Outbound Router Invoice Inbound Router
International
Message
Order
Fulfillment
Outbound Router
Updated Application
Invoice
Inbound Router
The answer is that service components dont know how to read the messages, because by
default, service components are completely shielded from the message format. Instead, a
transport carries the message along, and transformers change the messages payload (such as
the invoice) as needed to a format the service component can read before the router passes
the message to the service component. For example, if an XML invoice is sent over HTTP,
the HTTP transport carries the message along, routers direct the message to each service
component that needs to process it, and transformers change the invoice along the way (such
as from XML to a Java object) as required by each service component. All the transporting,
transforming, and routing of the message are completely transparent to the service
component.
Service
Customer Data
Service
Component
XML to Message
Java Object
Transformer
Message
JMS Transport
HTTP Transport
Transformers are the key to exchanging data, as they allow Mule ESB to convert the data to a
format that another component or application can understand. Most importantly, data is
transformed only as needed. Instead of converting every message to a single common
messaging format, messages and their data are transformed only as needed for the target
component or application where the message is being sent. Lastly, you can use multiple types
of transports to handle different channels, such as sending the message over HTTP and then
forwarding it as a JMS message after it has been processed by the Customer Data service
component.
The separation of the business logic from the sending and transformation of messages allows
for great flexibility in how you set up your architecture and makes it much simpler to
customize the business logic without having to worry about the various formats in which a
message might arrive. Your service component can work with the raw data of the message if
desired, but it is not required.
Service Service
Order
Customer Data
Fulfillment
Service
Service
Component
Component
A service can receive messages using different transports. For each type of transport that a
service will use, you must specify one or more separate endpoints. For example, if you want
one of your services to handle messages coming in on both the HTTP and JMS channels,
you would specify at least one HTTP endpoint and at least one JMS endpoint in the
inbound router for that service. Mule ESB registers these endpoints with the service, and the
transport uses this registry information at runtime to configure itself and determine where to
send and receive messages.
The router or endpoint can include filters that further specify which messages to send or
receive. For example, you can specify that the service component only receives RSS messages
by a specific author. Specifying routers and endpoints for your services simply requires
editing an XML file. You do not have to write any Java code. As stated previously, your
service components code remains completely separate from messaging and routing, which
you handle through the Mule ESB configuration.
In summary, Mule ESB provides a simple and lightweight way to write service components
that do something to data without needing to worry about the sender or recipient of the
data, the format of the data, or the technology being used to send/receive the data. Although
many brokering and integration technologies offer the ability to connect to disparate data
sources, they often require extra coding to get messages to behave the way you want and to
deliver the data where you want it to go. Mule ESB allows you to quickly develop service
components and then change the way they behave through simple XML configuration
instead of writing Java code.
6 The HTTP transport uses the outbound router configuration to determine that it must
now dispatch the message to http://myfirm.com/verify.
7 The HTTP transport uses the inbound router configuration of the Inventory Verification
service to receive the message and pass it to the service component.
8 The service component updates the invoice with an ID code of the warehouse that has all
the items on the invoice in stock.
9 The outbound endpoint specifies a JMS address, so the JMS transport dispatches the
message to the order fulfillment application, which picks up orders on that address.
Customer Data 5
Service Data
Component
http:// http://
myfirm.com/ myfirm.com/
orders verify
Inbound Router Outbound Router
POJO
XML to
Java Object POJO w/customer data
Transformer
3
6
1 2
Mule ESB also supports other topologies beyond ESB, including pipeline, peer network,
client/server, hub-and-spoke, and more. These topologies can be mixed and matched in an
enterprise service network to model complex enterprise messaging and service requirements, as
shown in the following illustration.
When integrating with Mule ESB, you can start with just a few applications and connect
more applications to Mule ESB over time. For example, one Mule ESB customer started by
integrating six systems. Three years later, they had a total of 71 systems connected using
Mule ESB. Mule ESB allows you to start as small as needed and easily scale over time.
You can have multiple instances of Mule ESB distributed across your network, as shown in
the following illustration. This approach is useful for failover (if one Mule ESB instance
becomes unavailable because the server stops, another Mule ESB instance can take over its
messages) as well as for load-balancing (you can send some messages to one instance and
other messages to another instance to balance the load).
You can deploy each instance of Mule ESB as a stand-alone application, in a web container
(such as Apache Tomcat), or in an application server. You can use proprietary J2EE
application servers such as BEA WebLogic, IBM WebSphere, Oracle Application Server, and
SunOne, as well as in open source products like Geronimo or JBoss.
Designing your system is both an art and a science. It must be done correctly to ensure
scalability. MuleSoft Professional Services can help you by reviewing your architecture,
designing components, or doing the full implementation for you. For more information,
contact your MuleSoft Professional Services representative.
Administering Mule
MuleSoft provides additional tools for monitoring and managing your Mule deployment, as
shown in the following illustration. This section describes these tools and how they can help
you administer Mule.
The management console provides integrated log, configuration, and server event tracking. It
can detect Mule ESB servers and associated software and hardware, and report real-time and
historical details of events.
The management console is available with Mule Enterprise Edition only. It can monitor both
Community Edition and Enterprise Edition instances of Mule 2.x servers (to monitor Mule
1.x, download the previous release, Mule HQ 3.5). The management console fully supports
standalone Mule ESB deployments and provides some monitoring data for embedded Mule
ESB instances.
The service registry can be deployed either alongside Mule or as a standalone component in
an enterprise's SOA infrastructure. The service registry is available with Mule ESB
Enterprise. It is based on the open-source Mule Galaxy project, which can be used with the
community edition of Mule ESB.
Compatible Technologies
Following are the technologies that are known to work with Mule.
Operating Systems
Linux
Windows
Solaris
AIX
HP-UX
Mac OS X
Application Servers
Standalone
Tomcat
WebLogic
WebSphere
Geronimo
JBoss
Jetty
Resin
Containers
EJB 3
jBPM
Spring
JMS Servers
ActiveMQ
FioranoMQ
JBossMQ
OpenJMS
OpenMQ
Oracle AQ
SeeBeyond
SonicMQ
Sun JMS Grid
SwiftMQ
TIBCO EMS
WebLogic JMS
Developer Tools
Ant
Data Mapper (Eclipse IDE, Oakland)
Eclipse
Japex
Maven
Mule IDE
Profiler
Transports
Abdera
Amazon SQS
Axis
BPM
CICS CTG
CXF
Email
FTP
Hibernate
HTTP/S
IMAP/S
JCR
JDBC
Jersey
Jetty/Jetty SSL
JMS
LDAP
Multicast
POP3/S
Quartz
Restlet
RMI
SalesForce
SAP
Servlet
SMTP/S
SOAP
STDIO
TCP
UDP
VM
XMPP
WSDL
Security
WS-Security
Acegi
Jaas
PGP
Spring Security
Databases
Derby
MySQL
Oracle
Languages
Groovy
Java
JavaScript
Jaxen
JRuby
JXPath
Jython (Python)
OGNL
RegEx
SXC
XPath
XQuery
Data Formats
Atom
Base 64 encoded
Byte arrays
CSV
EDI
Encrypted
GZIP
Hex strings
HTML / XHTML
Java objects
JAXB
JSON
Streaming
Strings
XHTML
XML
XML entity encoded
Deployment Topologies
ESB
Client/Server
Peer-to-Peer
Enterprise Service Network
Hub and Spoke
Pipeline
Event Handling
Asynchronous
Routing Patterns
SEDA
Streaming
Synchronous
Transactions
Summary
Mule ESB provides a messaging framework that enables exchange of data among
applications. The application functionality is wrapped as a service, which includes a service
component (the business logic that processes the data), routers (which use endpoints to
specify where to send the message), and other configuration settings. Transports carry the
messages on different channels from service to service, and transformers convert the messages
and data as needed along the way.
Mule ESB is not a replacement for existing application frameworks. Instead, Mule ESB
leverages many open source projects such as Apache CXF, Spring, and ActiveMQ and fills a
void in enterprise Java development where an application requires complex interactions with
a variety of systems on a variety of platforms. Mule ESB makes light work of wiring systems
together in a robust, decoupled environment with little to no code and provides the
necessary support to route, transport, and transform data to and from these systems.
This chapter provided an introduction to the Mule ESB architecture. Now, read Chapter
2, Installing and Running Mule, for more detailed information on how to download,
install, and get started using Mule.
This chapter describes how to get started using Mule. For full details, see the Mule User
Guide at:
http://mule.mulesource.org/documentation/display/MULE2USER/Home
Installing Mule
This section describes how to download and install the three types of Mule distributions.
Install the third-party software and set up your environment first, and then follow the
installation instructions for the distribution type you are downloading.
Note If you need to upgrade from a previous release of Mule, see Existing Users on
page 8.
Distribution Types
There are three types of Mule distributions. The distribution you choose depends on your
business needs and current phase of development.
MuleSoft supported release (Mule Enterprise): the latest, fully tested release of Mule
ESB created by MuleSoft that includes premium features not found in the community
release. Mule Enterprise provides access to technical support, maintenance patches, and
the MuleSoft knowledge base and is suitable for development, pre-production, and
production environments alike.
If you have purchased a license for Mule Enterprise, log in to the customer portal at
http://mulesupport.mulesource.com/portal/login.mule, and then click
Downloads. If you are evaluating Mule, you can download the 30-day trial of Mule
Enterprise at http://www.mulesoft.com/mule-esb-enterprise-trial-download.
Latest stable community release: the latest stable release of the community release of
Mule ESB. This distribution is suitable for people who are evaluating Mule ESB in
development or pre-production environments. (Mule Enterprise is the best choice for
production environments.) To download the community release, go to
http://www.mulesource.org/display/MULE/Download
Snapshot release: the latest Mule distribution built against the very latest code base (the
bleeding edge). Snapshot releases may be unstable, so they are intended for development
environments only, not for production environments. Additionally, snapshot releases do
not include any documentation. To download a snapshot release, go to
http://www.mulesource.org/display/MULE/Download
You can also download the source code and build Mule yourself. For complete information,
see Setting Up the Development Environment
(http://www.mulesoft.org/documentation/display/MULECDEV/Setting+Up+the+
Development+Environment) and Building from Source
(http://www.mulesoft.org/documentation/display/MULECDEV/Building+from+S
ource).
Note If you download one of the compressed distributions, you will need a compression
tool such as WinZip (Windows) or GZip (Linux/UNIX) to decompress the ZIP or TAR file.
Compatible Platforms
Users run Mule on many different operating systems with a variety of messaging platforms
and application servers. The following table lists the platforms that members of the
community have reported are compatible with Mule.
Technology Platforms
Operating Systems Windows XP SP2, Windows 2000, Windows 2003 Server (32-bit if
using the Java Service Wrapper), Linux, Solaris, AIX, HP-UX,
and Mac OSX
Application Servers Tomcat, JBoss, WebSphere, WebLogic, and Jetty
Messaging Any JMS vendor; users have reported integration with Active MQ,
Open MQ, TIBCO EMS, TIBCO Rendezvous, Oracle AQ, and IBM
WebSphere MQ
Java JDK 1.5 and 1.6
Note If you are using UNIX, log in as a non-root user before you proceed. This will ensure
that your environment and Mule installation can support Mule HQ if you decide to install it
later, as Mule HQ requires that you log in as a non-root user before you install it.
If you are using the Mule IDE, you must also endorse the JDK with a proper JAXP (Java
API for XML Processing) implementation. To do this, download Apache Xerces and
Xalan and drop the JARs into your JVM's jre/lib/endorsed directory. If that
directory does not yet exist, create it.
Mule IDE: If you are installing the Mule IDE, install it immediately after installing
Mulesee IInstalling Mule on page 30.
Maven: If you do not want to use the Mule IDE, or if you will be using the Maven
archetypes to create a new transport or module, install Maven.
z Download the Maven distribution from the Maven web site
(http://maven.apache.org/) and unpack it to any folder (for example, c:\Apache).
Since there were some critical bugs in earlier versions, Maven 2.0.9 is recommended. If
you are using a Macintosh, you must use Maven 2.0.9.
z Create a Maven repository directory with no spaces in the path, such as
c:\.m2\repository on Windows. (If Windows Explorer does not allow you to create
the .m2 folder name, use the mkdir command in a console window instead.)
z Open the settings.xml file in your Maven conf directory (e.g.,
c:\apache-maven-2.0.9\conf ) and specify the repository directory. For example:
<localRepository>c:/.m2/repository</localRepository>
Ensure that this entry is not commented out in this file.
Ant: If you want to use Ant to build the examples instead of Maven, download and install
it if you have not done so already.
You can download Ant from http://ant.apache.org/bindownload.cgi.
4 If you will use Ant, create an environment variable called ANT_HOME and set it to your Ant
home directory.
5 Create the MULE_HOME environment variable and set it to the location where you will
install Mule. If you are running Windows, the installation path must not contain any
spaces (for example, you cannot use C:\Program Files). A good workaround is to create
a root directory called Mule (for example, C:\Mule). This step is not required if you will
use the Mule IDE.
6 Update the PATH environment variable so that it includes the path to the JDK, Maven,
and Mule binaries.
If you are using Windows, you can use the System utility in the Control Panel to add the
environment variables and edit your path. Alternatively, you can use the export or set
commands (depending on your operating system) at the command prompt, as shown in the
following examples:
Linux/UNIX
export JAVA_HOME=/opt/java/jdk
export MAVEN_HOME=/opt/apache/maven-2.0.9
export MAVEN_OPTS='-Xmx512m -XX:MaxPermSize=256m'
export MULE_HOME=/opt/mule
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin:$MULE_HOME/bin
Windows
set JAVA_HOME=C:\Program Files\Java\jdk
set MAVEN_HOME=C:\Apache\maven-2.0.9
set MAVEN_OPTS='-Xmx512m -XX:MaxPermSize=256m'
set MULE_HOME=C:\Mule
set PATH=%PATH%;%JAVA_HOME%/bin;%MAVEN_HOME%/bin;MULE_HOME/bin
You are now ready to install Mule. If you are installing Mule Enterprise, read the next
section. If you are installing the community or snapshot release, skip ahead to Installing
the Community or Snapshot Release on page 36.
z If you will use the Mule IDE, see Installing and Configuring Mule IDE on
page 43.
z If you will use Maven, skip ahead to Setting Up the Maven Repository on
page 36.
z Otherwise, go to the section on Running Mule on page 46.
z If you will use the Mule IDE, see Installing and Configuring Mule IDE on
page 43.
z If you will use Maven, skip ahead to Setting Up the Maven Repository on
page 36.
z Otherwise, go to the section on Running Mule on page 46.
For example:
cd c:\mule\bin
populate_m2_repo.cmd c:\.m2\repository
This step is required to populate the Maven repository with the local Mule Enterprise JAR
files from the distribution. Note that when you add Mule Enterprise-only features to your
code, you must add the correct dependencies to your POM before building your project with
Maven. For more information, see Dependencies on the Using Maven page at
http://www.mulesoft.org/documentation/display/MULECDEV/Using+Maven#Us
ingMaven-Dependencies.
You have completed the Mule installation and setup. You can now skip the next section and
go to Setting Up Eclipse on page 38.
3 Click the link next to the release you want to download. Use the .zip links for installing
on Windows and the .tar.gz links for installing on Linux/UNIX. The latest releases are
at the top of the page.
4 On Linux/UNIX, if you prefer to download through a shell instead of a browser or need
to download to a remote computer without X-Windows, you can download the
distribution using your download tool. For example to download the Mule 2.0.1
snapshot using wget, you would enter the following command all on one line:
wget http://snapshots.dist.codehaus.org/mule/org/mule/distributions
/mule-full/2.0.1-SNAPSHOT/mule-full-2.0.1-SNAPSHOT.tar.gz
5 After the distribution is downloaded, extract its files into the MULE_HOME directory
you specified when setting up the environment variables (see page 33). For example, on
Linux/UNIX, you would switch to your MULE_HOME directory, and then enter a
command like this to extract the files:
tar -xvzf mule-full-2.0.1-SNAPSHOT.tar.gz
3 Create a directory for the secondary instance with the following subdirectories:
4 Copy the files from these subdirectories in the primary Mule instance to the
corresponding subdirectories in the secondary instance directory. For example, if your
primary Mule instance is in C:\Mule and your secondary instance is in C:\Mule2, you'd
copy C:\Mule\bin to C:\Mule2\bin, copy C:\Mule\conf to C:\Mule2\conf, and so on.
5 Create an environment variable called MULE_BASE that points to the secondary instance
directory, and create an environment variable called MULE_HOME that points to the location
of the primary Mule installation. Using the previous example, you would set MULE_BASE
to C:\Mule2 and set MULE_HOME to C:\Mule.
6 Add the MULE_BASE/bin directory to the system path so that the Mule startup script is
launched from MULE_BASE instead of MULE_HOME.
7 Repeat these steps for each user who will use a secondary Mule instance. Each secondary
instance must be in its own directory, and you must set the MULE_BASE and MULE_HOME
environment variables separately for each user.
When users run Mule, the files from their secondary instance (MULE_BASE directory) will be
loaded first, allowing users to put updated JARs in their MULE_BASE directory and test
different scenarios without affecting the primary instance.
Setting Up Eclipse
When you work with Mule, you can make configuration and development much easier by
using an IDE. This section describes how to set up Eclipse, an open-source IDE, to enable
easy configuration of Mule and development of new functionality. This section describes
using Eclipse 3.4 (Ganymede), which you can download from
http://www.eclipse.org/downloads/packages/ (download the Eclipse IDE for Java
EE Developers). It contains the following sections:
Prerequisites on page 39
Build the Hello Application on page 39
Generate the Eclipse Project on page 39
Configure Eclipse on page 39
Import the Eclipse Project on page 41
Configure the Eclipse Build Path on page 41
Create a Run Configuration and Run the Application on page 42
Prerequisites
Before you continue, be sure you have installed Mule and the prerequisites as described
earlier in this chapter. You must also have Internet access to build the example application
and generate the Eclipse project, as each of those steps downloads dependencies.
To build the example, navigate to the MULE_HOME\examples\hello directory, and then type
mvn at the command prompt.
mvn eclipse:eclipse
Configure Eclipse
You only need to configure Eclipse once. With subsequent projects, you can skip these steps.
1 Start Eclipse.
2 In the Workspace Launcher, specify the location of the examples directory under your
Mule home directory (such as C:\mule\examples), and click OK.
3 Click the Workbench icon on the right to display the workbench.
5 Expand Java in the navigation tree, click Compiler, and then change the compiler
compliance level to 1.5.
6 Click Installed JREs. If the JRE is not version 1.5, click Edit, click Directory and
navigate to your JDK1.5 directory, and then change the JRE name to jdk5. Click Finish,
and then click OK.
7 When prompted to rebuild, click No.
2 Expand General, click Existing Projects into Workspace, and then click Next.
3 In the Import dialog box, click Browse, navigate to the Mule examples directory again,
and click OK. The hello project should be listed and selected.
4 Click Finish.
The hello project is now listed in the Project Explorer on the left. You will notice some errors
at the bottom of the screen, which are caused by your build path needing to be configured.
1 In the Project Explorer, right-click the hello project and choose Build Path > Configure
Build from the popup menu.
2 In the Properties dialog box, click the Libraries tab, and then click Add Library.
4 Click User Libraries, and then in the Preferences dialog box, click New.
5 In the New User Library dialog box, enter MULE_LIB and click OK.
6 Click Add JARs, navigate to the \lib\mule directory under your Mule home directory,
select all the JARs, and click Open.
7 Click OK and then Finish.
8 Click Add Variable, click Configure Variables, and then in the Preferences dialog box,
click New.
9 In the New Variable Entry dialog box, create a variable called M2_REPO that points to your
Maven repository (such as C:\.m2\repository), which you created when you installed
Maven. Click OK.
10 In the Preferences dialog box, click OK, and this time when you're prompted to rebuild,
click Yes. Click OK in the open dialog boxes to close them and rebuild the project.
2 In the left window, double-click Java Application, and then change the name to hello
and specify org.mule.MuleServer for the main class.
3 Click the Arguments tab, and then enter -config conf\hello-config.xml (for
Windows) or -config conf/hello-config.xml (for Linux/UNIX) in the Program
Arguments box.
4 Click Apply and then Run.
The Hello application runs in the Console tab at the bottom of the window, prompting you
to enter your name. You can type your name and press Enter to see the application continue.
Congratulations! You have successfully built and run your first Mule example from within
Eclipse. You can now add services to the configuration, write POJOs as needed, debug your
code, and compile and run your examples all within the IDE.
If you want to import another example into Eclipse, repeat the instructions to generate an
Eclipse project for that example, import the project into the workspace, and then just run the
example by choosing Run > Run. You do not have to repeat the steps for configuring Eclipse.
Prerequisites
Before you install Mule IDE, ensure that you have installed the following software:
Eclipse 3.4 (Ganymede) or later (see Setting Up Eclipse on page 38).
Java 5 or later. You can download Java from
http://java.sun.com/javase/downloads/index_jdk5.jsp.
Mule 2.2 or later (see Installing Mule on page 30). Note that you do not have to
install and configure Maven or Ant if you are using Mule IDE, but you must install
Maven if you want to use the Maven archetypes to create transports and other projects.
You can ignore the information on that page about running Mule, as you will run Mule
from within Eclipse instead of at the command prompt.
You must also endorse the JDK with a proper JAXP (Java API for XML Processing)
implementation. To do this, download Apache Xerces
(http://xerces.apache.org/xerces2-j/) and Xalan
(http://xml.apache.org/xalan-j/) and drop the JARs into your JVMs
jre/lib/endorsed directory. If that directory does not yet exist, create it.
4 Click the Mule IDE check box and click Next, and after Eclipse processes for a moment,
click Next again.
5 Review the IDE license, select the option to accept the license, and then click Finish.
You are now ready to configure the Mule distribution as described in Configuring the
Mule Distribution on page 45.
7 If you are installing an update of Mule IDE, a screen appears saying that an update will be
performed instead. Click Next, read and accept the license agreement terms, and click
Finish. You should restart Eclipse before you continue.
You are now ready to configure the Mule distribution as described in the next section.
3 Specify the root directory where the Mule distribution is installed, and then click OK.
4 Click the distributions check box, and then click Apply. This distribution is now the
default Mule distribution. You can configure multiple Mule directories, but only one can
be the default.
You are now ready to start Eclipse and start using Mule IDE as described in Chapter
3, Tutorial and Chapter 4, Using Mule IDE.
Troubleshooting
If you have difficulty installing or using Mule IDE, verify the following:
You have the correct update site and have uninstalled any developer preview releases.
Does your workspace directory or project name have a space in it? Mule runs from the
workspace folder, and if it has a space in the name (like Documents and Settings), Mule
cannot locate the configuration file to start.
If you cannot successfully complete the installation steps, remove and recreate the update
site. To remove a site in Eclipse, choose Help > Software Updates, on the Available
Software tab click Manage Sites, select Mule IDE, and then click Remove. You can
now recreate the Mule IDE site following the steps above.
Have you updated the other libraries in your eclipse installation? Make sure all of your
existing standard Eclipse plug-ins are up to date.
Ensure you followed the documented steps to register the endorsed XML libraries and
have also previously installed Mule. You will need to configure the location of Mule the
first time you create a Mule project.
Running Mule
Now that you have installed and configured Mule, you are ready to get started! This section
describes how to run Mule. If you installed Eclipse, see Create a Run Configuration
and Run the Application on page 42 instead.
Note If you are using the 30-day trial version of Mule Enterprise, you will not be able to run
the trial version after the 30 days has expired unless you purchase a license. (This does not
affect the community release of Mule.) For information on purchasing Mule Enterprise, go
to http://www.mulesource.com/buynow/.
The simplest way to run Mule is to enter the following command at the command prompt:
where your-config.xml is the Mule configuration file you want to use. For a quick start, use
one of the configuration files in the Examples subdirectories to see how this works. For more
information on examples, see http://mule.mulesource.org/x/wAm7.
To get up and running quickly with developing a Mule application using an example
application, see Chapter 3, Tutorial.
If you are running the community release of Mule, the MuleSoft Public License is displayed
page by page when you first run Mule. To advance a page, press Enter. At the end of the
license display, type y to accept the license file and proceed with startup.
Basic Usage
When you look at how a message flows through Mule, you can see that there are three layers
in the architecture: the application layer, the integration layer, and the transport layer.
Service
Customer Data
Service Application
Component Layer
Integration
Layer
XML to
Java Object
Transformer
Message Message
Transport
Layer
Likewise, there are three general types of tasks you can perform to configure and customize
your Mule deployment:
Service component development: developing POJOs, services, or beans that contain the
business logic and will be used as service components in a Mule deployment.
Integration: developing routers, transformers, and filters, and configuring everything in
the Mule configuration file.
Extending Mule: developing new transports, connectors, and other modules used by
Mule.
This section provides a high-level overview of the steps you take to perform these tasks.
To assist development, you should use an IDE such as Eclipse. For a tutorial on setting up
Eclipse and creating a new service, see Chapter 3, Tutorial.
Following is more information on configuring routers, filters, and transformers for the
service.
Routers
Inbound routers specify how messages are routed to a service, and outbound routers specify
how messages are routed after the service has finished processing them. There are several
default routers that come with Mule that you can use, or you can create your own routers.
For more information, see: http://mule.mulesource.org/x/NAKV
Filters
Filters specify conditions that must be met for a message to be routed to a service. There are
several default filters that come with Mule that you can use, or you can create your own
filters. For more information, see: http://mule.mulesource.org/x/7AGV
Transformers
Transformers convert incoming payload data to the type required by the service component.
After the service has finished processing the message, they can also convert the message to a
different type as needed by the outbound transport. There are several default transformers
you can use, or create your own. For more information, see:
http://mule.mulesource.org/x/IgKV
Extend Mule
Mule provides transports for many different channels, including File, FTP, HTTP, JMS,
JDBC, Quartz, and many more. There are also community-created transports on MuleForge
(http://muleforge.org/). If you need to send messages on a channel other than those
provided, you can create a new transport. You can also create a custom connector for a
transport. A connector is the Java class in the transport that contains the actual logic for
sending and receiving messages on that channel. For more information, see:
http://mule.mulesource.org/x/zoDR
You can also use Maven to create new Mule projects (transports and other types of modules).
For more information, see: http://mule.mulesource.org/x/YgI
Where Do I Go Next?
This chapter has provided a brief overview of getting started with Mule. Following is
information about where to go next.
For a tutorial on running Mule in an IDE, walking through a configuration, and adding a
service to a Mule application, see Chapter 3, Tutorial.
For complete information on using Mule, go to the Mule User Guide at:
http://www.mulesoft.org/documentation/display/MULE2USER/Home
If you need assistance and are a Mule Enterprise customer, see the support page at:
http://www.mulesource.org/display/MULE/Support
If you are evaluating Mule and want to find out about subscription options, you can
submit a request for MuleSoft to contact you by going to
http://www.mulesource.com/buynow/, or call us at 877-MULE-OSS.
All Mule users can subscribe to the Mule mailing lists. You can find these lists at:
http://www.mulesource.org/display/MULE/Mailing+Lists
If you experience problems with the Mule software or documentation, please log an issue
in the MuleSoft issue-tracking system, located at:
http://www.mulesource.org/jira/browse/MULE
This chapter provides a tutorial for running an example, walking through its configuration,
and adding a service to an existing Mule application. This chapter contains the following
sections:
Lesson 1: Creating an Application Using Mule IDE on page 51
Lesson 2: Creating an Application Manually on page 54
Lesson 3: Modifying an Application on page 60
Lesson 4: Introduction to Message Routing on page 75
Lesson 5: Advanced Message Routing on page 80
2 Enter the name myHelloApp, ensuring that there is no space in the project name.
3 Click Add sample project content and select the Hello example.
4 Click Next, and then click the Libraries tab and verify that the Java 5 or later library is
installed and available on the build path.
5 Click Finish to have Mule IDE generate your project.
You will now see the myHelloApp project in the navigation pane on the left. You can expand
its folders to see the source code, configuration files, and more.
Now, lets create a new configuration file for this application using the System I/O (also
called STDIO) and VM transports.
Mule IDE creates the configuration file in the conf directory of the myHelloApp project. It
adds the namespaces for the STDIO and VM transports.
You can now add global elements below the namespace declarations, add services within a
<model> element, and add local routers, filters, endpoints, and transformers to the services.
Eclipse provides a fast and error-proof method for entering these elements. Simply click
somewhere between the opening and closing tags of an element and click Ctrl+space to see
the available elements. Double-click the element you want, and Eclipse enters the opening
and closing tags for that element. You can also hover over a tag to see a description of the
element and its supported attributes.
Now that you know how to set up a Mule project and configuration file, the next lesson
walks you through the configuration file in detail to help you understand the elements you
add. You can continue on with the next lesson from within the Mule IDE and just skip past
the first two steps, as you have already declared your XML namespaces.
Although the easiest way to create a Mule configuration file is to use the Mule IDE, this
lesson walks you through creating the file manually in any XML editor or IDE to help you
understand all the elements involved.
Next, in the <mule> element, declare the namespaces for the core Mule schema, XSI, Spring,
and the transports and modules you want to use. In this example, we'll use the STDIO and
VM transports. You then use the XSI namespace to declare the locations of the schemas. For
example:
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"
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
http://www.mulesource.org/schema/mule/vm/2.2
http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd">
Optionally, add the <description> element with a description of this configuration file. If
you are creating only one configuration file for your entire application, the description could
be about the entire application.
While there are several ways in Mule to configure a transport, the best practice is to use the
<connector> element to define a global connector configuration, which you can then
reference in multiple places. The <connector> element must be prefixed by the namespace
of its transport. For example, the following connector will be available to endpoints that use
the STDIO transport:
<stdio:connector name="SystemStreamConnector"
promptMessageCode="3"
resourceBundle="messages.hello-example-messages"
messageDelayTime="1000"/>
Because we have only one connector defined for the STDIO transport, this connector will be
used by default whenever we create an STDIO transport. If we defined multiple STDIO
connectors, you would use the connector-ref attribute on the endpoint to specify the one
you want to use.
To see which attributes you can set for a connector, go to the transports reference page by
clicking its name on the Available Transports page at:
http://www.mulesource.org/x/3oHR
Similarly, if you want to configure custom transformers that you can reference from multiple
places, add them to the configuration now. For example, the Hello World example uses
several transformers that format the message payload and convert it to the datatype expected
by each component:
<custom-transformer name="StdinToNameString"
class="org.mule.example.hello.StdinToNameString"/>
<custom-transformer name="NameStringToChatString"
class="org.mule.example.hello.NameStringToChatString"/>
<custom-transformer name="ChatStringToString"
class="org.mule.example.hello.ChatStringToString"/>
<custom-transformer name="ExceptionToString"
class="org.mule.example.hello.ExceptionToString"/>
You are now ready to add your services, which is where you specify your components that do
the actual work. Services are contained within models, so you add the <model> tag first:
<model name="helloSample">
...services will go here
Now, start configuring your services by adding <service> tags with a name attribute that
contains a unique name for the service. The Hello World example has four services, each of
which has an <inbound> section, a <component>, and an <outbound> section in that order.
For details on the elements you can configure in a service, see the Service Configuration
Reference page at http://www.mulesource.org/x/P5HR.
Lets add the inbound section for the GreeterUMO service first:
<service name="GreeterUMO">
<inbound>
<stdio:inbound-endpoint system="IN"
transformer-refs="StdinToNameString"/>
</inbound>
Notice that within the inbound section, weve specified the inbound endpoint. The inbound
endpoint defines which messages this service will handle by specifying the following:
The transport. In this case, its STDIO.
Where the message originates. In this case, its system.in because the user is typing the
information at the command prompt.
The transformer to use. Here we reference one of the global transformers we defined
earlier in the configuration.
If there is more than one connector configured for the transport, you specify the
connector to use. As mentioned earlier, we have only one STDIO connector, so we dont
have to specify it explicitly on the endpoint.
This inbound endpoint specifies that only messages that are received on system.in at the
command line will be received by this service, and they will be transformed by the
StdinToNameString transformer before they are passed to the component. There is no
inbound router specified, so all messages received on this endpoint will be processed by the
service.
The component is the next element to configure. The component can be a Java class, web
service, or anything that can perform logic on the messages. For information on creating a
component, see Developing Service Components at
http://www.mulesource.org/x/2IDR.
In this example, our component is a POJO, so you specify the class in the <component> tag:
<component class="org.mule.example.hello.Greeter"/>
By default, Mule automatically discovers the correct method in the Java class to execute (the
entry point) by matching the return type on the transformer (in this case, NameString) to the
methods in the component. For information on other ways of resolving the entry point, see
Entry Point at http://www.mulesource.org/x/2IDR.
Now we need to specify what the service will do after the component has finished with it. We
specify this in the outbound section. In this case, we want to use an outbound router to send
the message to one service if the message was processed successfully and to a different service
if the message had errors. To do this, we use filtering routers, each of which specifies a) the
outbound endpoint where the message will go next, and b) the criteria the message must
meet to be routed there. If a message does not meet the criteria of the first router, its checked
against the second routers criteria, and so on until theres a match.
<outbound>
<filtering-router>
<vm:outbound-endpoint path="chitchatter"/>
<payload-type-filter
expectedType="org.mule.example.hello.NameString"/>
</filtering-router>
<filtering-router>
<vm:outbound-endpoint path="userErrorHandler"/>
<payload-type-filter expectedType="java.lang.Exception"/>
</filtering-router>
</outbound>
In this case, if the message payload was transformed correctly into a NameString object, the
first router sends it to the chitchatter path using the VM transport. If the message was not
transformed correctly and the payload contains an exception, the message is routed to the
userErrorHandler path using the VM transport. When you configure the services that will
handle the message in each of these cases, you must ensure that they specify chitchatter or
userErrorHandler as the path on their inbound endpoints.
Mule provides support for error handling for unexpected errors. Exception strategies allow you
to handle messages when there is a system error:
In the Hello World example, user errors are routed to system.out and system errors are
routed to system.err. These error-handling services are defined below:
<!-- This error handler returns user error messages to caller. Errors could
also be routed elsewhere,
e.g. into an error file, send via email to a list, stored in a database,
etc. -->
<service name="UserErrorHandler">
<inbound>
<vm:inbound-endpoint path="userErrorHandler"
transformer-refs="ExceptionToString"/>
</inbound>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="OUT"/>
</pass-through-router>
</outbound>
</service>
<!-- Handle any unexpected errors. Errors could also be routed elsewhere,
e.g. into an error file, send via email to a list, stored in a database,
etc. -->
<service name="SystemErrorHandler">
<inbound>
<vm:inbound-endpoint path="systemErrorHandler"/>
</inbound>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="ERR"/>
</pass-through-router>
</outbound>
</service>
Notice that these services do not configure components, because they simply route the
messages using the pass-through router and do not need to perform any extra logic on the
messages.
There is one last service in the example: the ChitChatUMO service. This service transforms
the message, adds text to it, and writes it to system.out:
<service name="ChitChatUMO">
<inbound>
<vm:inbound-endpoint path="chitchatter"
transformer-refs="NameStringToChatString"/>
</inbound>
<component class="org.mule.example.hello.ChitChatter"/>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="OUT"
transformer-refs="ChatStringToString" />
</pass-through-router>
</outbound>
</service>
Lastly, end the file with the closing </model> and </mule> tags:
...
</model>
</mule>
To see the entire configuration file for this example, navigate to the examples/hello/conf
directory under your Mule home directory and open the hello-config.xml file. The
custom classes referenced in the configuration file are included with the example under the
examples/hello/src/main/java directory.
To run the application, the custom classes must be compiled and available on the Java
classpath when Mule starts. If you created your project in the Mule IDE, it handles this for
you, and you can execute your application by selecting the Mule configuration file you
created (my-hello-config.xml) and running it as a Mule Server.
The configuration uses the STDIO transport to receive a stock symbol from a user
(System.in), invokes the StockQuote service, transforms the result using the XSLT
transformer, and then uses the XmlToObject transformer to convert the result into a
StockQuote Java bean. The quote is then sent to the output console (System.out).
How it Works
This section walks through the configuration of the REST version of the Stock Quote
example, but the Web Service configuration is very similar. Because you've already walked
through the Hello example, this section will discuss the configuration without going into
step-by-step detail.
First, because the proxy settings are in an external properties file, we specify the file in the
Mule context:
<context:property-placeholder location="proxy.properties"/>
Next, we configure the HTTP connector with the properties whose values are defined in the
proxy.properties file:
<http:connector name="HttpConnector"
proxyHostname="${proxyHostname}"
proxyPassword="${proxyPassword}"
proxyPort="${proxyPort}"
proxyUsername="${proxyUsername}"/>
The next section is the configuration for the transformers. There are four transformers,
which will be chained together. Note that the XSLT transformer references the XSLT file in
the xsl subdirectory under the stockquote directory. The XSLT file can be anywhere on
your classpath.
<xm:xml-to-object-transformer name="XmlToObject"/>
<xml-entity-decoder-transformer name="XmlDecoder"/>
<xm:xslt-transformer name="Xslt" xsl-file="xsl/rest-stock.xsl"/>
<object-to-string-transformer name="ToString"/>
Next, we set up a model as a container for the one service in this example:
HTTPPostSample. This service receives messages sent to vm://stockquote and transforms
them using all four transformers before passing them to the component.
<model name="Sample-Rest">
<service name="HTTPPostSample">
<inbound>
<vm:inbound-endpoint path="stockquote"
responseTransformer-refs="ToString XmlDecoder Xslt
XmlToObject"/>
</inbound>
<http:rest-service-component
serviceUrl="http://www.webservicex.net/stockquote.asmx/GetQuote"
httpMethod="POST">
<http:payloadParameterName value="symbol"/>
</http:rest-service-component>
</service>
</model>
The component is the REST service component, which uses the REST service wrapper to
proxy a REST service to act like a local Mule component. The REST service wrapper has a
number of properties configured. The serviceUrl is the URL of the REST service to
invoke. The payloadParameterName is the name of the parameter to associate with the
message payload. In this case, we have only one parameter name, symbol. The httpMethod
can either be GET or POST.
<model name="Sample-SOAP">
<service name="serviceProxy">
<inbound>
<vm:inbound-endpoint path="stockquote"
responseTransformer-refs="ToString XmlDecoder Xslt
XmlToObject"/>
</inbound>
<outbound>
<outbound-pass-through-router>
<axis:outbound-endpoint
address="http://www.webservicex.net/stockquote.asmx?method=GetQuote"
responseTransformer-refs="XmlDecoder Xslt XmlToObject"
soapAction="[methodNamespace][method]">
<axis:soap-method
method="qname{GetQuote:http://www.webserviceX.NET/}">
<axis:soap-parameter parameter="symbol" type="string" mode="IN"/>
<axis:soap-parameter parameter="GetQuoteResult" type="string"
mode="OUT"/>
</axis:soap-method>
</axis:outbound-endpoint>
</outbound-pass-through-router>
</outbound>
</service>
</model>
Set Up Eclipse
To use the Stock Quote example in Eclipse, you take the following steps as described in
Setting Up Eclipse on page 38:
1 Build the Stock Quote example using the mvn command
4 Create a run configuration for the project (see the following illustration)
5 Ensure that the application runs successfully from the Console tab
These steps are described in detail in Setting Up Eclipse on page 38. Follow the
instructions replacing hello with stockquote, and set the run configuration program
arguments to:
-config "conf\stdio-config.xml,conf\stockquote-wsdl-config.xml"
For example:
You can create your own HTML page using the complete sample file getQuote.html on
page 67.
For example:
<service name="httpservice">
<inbound>
<inbound-endpoint address="http://localhost:8888/getQuote"
synchronous="true"/>
</inbound>
<outbound>
<pass-through-router>
<vm:outbound-endpoint path="stockquote" synchronous="true"/>
</pass-through-router>
</outbound>
</service>
Likewise, you must create a transformer that transforms the output of the serviceProxy
service back into an HTML string to send as a response to the HTTP request. The file
StockQuoteToHTMLString.java on page 72 contains sample code for this transformer.
<custom-transformer name="HttpRequestToStockSymbol"
class="org.mule.example.stockquote.HttpRequestToStockSymbol"/>
<custom-transformer name="StockQuoteToHTMLString"
class="org.mule.example.stockquote.StockQuoteToHTMLString"/>
Additionally, we need to set the content type to HTML, so we can define a simple
transformer right in the XML file that does this:
<message-properties-transformer name="SetHtmlContentType">
<add-message-property key="Content-Type" value="text/html"/>
</message-properties-transformer>
<inbound-endpoint address="http://localhost:8888/getQuote"
synchronous="true" transformer-refs="HttpRequestToStockSymbol"
responseTransformer-refs="StockQuoteToHTMLString SetHtmlContentType"/>
3 Copy and paste the HTML file you created (or downloaded) to the root folder of the
stockquote project.
2 Click the stockquote run configuration, and then click the Arguments tab.
The results of the Stock Quote web service appear on the page.
Congratulations! You have successfully added a new service and transformers to the Stock
Quote example and configured it to capture and display information on a web page instead
of the console. For more information on using Mule, including basic and advanced
configuration, working with transformers and filters, configuring transports, and more, see
the Mule User Guide at: http://mule.mulesource.org/x/VgKV
You can also use the Mule IDE, an Eclipse plug-in that provides additional functionality for
developing Mule applications in Eclipse. The Mule IDE is in beta and is available for
download on the MuleForge at: http://www.mulesource.org/display/IDE/Home
Example Files
This section contains the files used in this tutorial. You can copy and paste them from this
section, or download them using the links.
getQuote.html
You can download this file from:
http://www.mulesource.org/download/attachments/12257709/getQuote.html
<br />
<div id="wrapper">
<div id="header">
<div id="logo-floater">
<div class='center'>
<div class='squeeze'>
<div id='tabs-wrapper'
style='border: none; float: right; position: relative; padding-right:
25px; padding-top: 10px;'
class='clear-block'></div>
</div>
</div>
</div>
</div>
<!-- /header -->
<div id="center">
<div id="mycontent">
<form action="http://localhost:8888/getQuote" method="post"
name="myform" id="myform">
<div>Stock Symbol: <input name='symbol' /> <input type="submit"
value="Get Quotes" class="form-submit" />
<div>
</form>
<span class="clear"></span> <br />
<br />
<div id='footer' style='text-align: center;'>
<div>Powered By <b><a
href="http://www.mulesoft.com">MuleSoft</a></b></div>
</div>
</div>
</div>
<!-- /.left-corner, /.right-corner, /#squeeze, /#center --></div>
<!-- /container --></div>
<!-- /layout -->
</body>
</html>
stockquote-http-config.xml
You can download this file from:
http://www.mulesource.org/download/attachments/12257709/stockquote-http
-config.xml
<mule xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-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/http/2.2
http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd
http://www.mulesource.org/schema/mule/vm/2.2
http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd
http://www.mulesource.org/schema/mule/stdio/2.2
http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
http://www.mulesource.org/schema/mule/xml/2.2
http://www.mulesource.org/schema/mule/xml/2.2/mule-xml.xsd">
<description>
The StockQuote HTTP example listens for http requests and Uses the VM
transport to call the stockquote proxy service and returns results to the
enduser as a html page.
</description>
<custom-transformer name="HttpRequestToStockSymbol"
class="org.mule.example.stockquote.HttpRequestToStockSymbol"/>
<custom-transformer name="StockQuoteToHTMLString"
class="org.mule.example.stockquote.StockQuoteToHTMLString"/>
<message-properties-transformer name="SetHtmlContentType">
<add-message-property key="Content-Type" value="text/html"/>
</message-properties-transformer>
<model name="Sample-HTTP">
<!-- This component can proxy external web service calls over Jms, tcp, ssl
or any other transport. For this example we use Vm. -->
<service name="httpservice">
<inbound>
<inbound-endpoint address="http://localhost:8888/getQuote"
synchronous="true" transformer-refs="HttpRequestToStockSymbol"
responseTransformer-refs="StockQuoteToHTMLString SetHtmlContentType"/>
</inbound>
<outbound>
<pass-through-router>
<vm:outbound-endpoint path="stockquote" synchronous="true" />
</pass-through-router>
</outbound>
</service>
</model>
</mule>
HttpRequestToStockSymbol.java
You can download this file from:
http://www.mulesource.org/download/attachments/12257709/HttpRequestTo
StockSymbol.java.
package org.mule.example.stockquote;
import org.mule.transformer.AbstractTransformer;
import org.mule.util.IOUtils;
import org.mule.api.transformer.TransformerException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/*
* (non-Javadoc)
*
* @see
* org.mule.transformers.AbstractTransformer#doTransform(java.lang.Object)
*/
public Object doTransform(Object src, String encoding)
throws TransformerException {
String srcAsString;
if (src instanceof byte[]) {
if (encoding != null) {
try {
srcAsString = new String((byte[]) src, encoding);
} catch (UnsupportedEncodingException ex) {
srcAsString = new String((byte[]) src);
}
} else {
srcAsString = new String((byte[]) src);
}
} else if (src instanceof InputStream)
{
InputStream input = (InputStream) src;
try
{
srcAsString = IOUtils.toString(input);
}
finally
{
IOUtils.closeQuietly(input);
}
}else {
srcAsString = src.toString();
}
if (nextParameterValuePos == -1
|| nextParameterValuePos < nameParameterPos) {
nextParameterValuePos = requestQuery.length();
}
nameValue = requestQuery.substring(nameParameterPos
+ name.length() + 1, nextParameterValuePos);
}
if (nameValue != null && nameValue.length() > 0) {
try {
nameValue = URLDecoder.decode(nameValue, "UTF-8");
} catch (UnsupportedEncodingException uee) {
System.err.println("USER ERROR: " + uee.getMessage());
}
}
}
if (nameValue == null) {
nameValue = "";
}
return nameValue;
}
}
StockQuoteToHTMLString.java
You can download this file from:
http://www.mulesource.org/download/attachments/12257709/StockQuoteToH
TMLString.java
package org.mule.example.stockquote;
import java.util.ArrayList;
import org.mule.RequestContext;
import org.mule.transformer.AbstractTransformer;
import org.mule.api.transformer.TransformerException;
this.registerSourceType(org.mule.example.stockquote.StockQuote.class);
this.registerSourceType(String.class);
this.setReturnClass(String.class);
/*
* (non-Javadoc)
*
* @see
org.mule.transformers.AbstractTransformer#doTransform(java.lang.Object)
*/
public Object doTransform(Object src, String encoding) throws
TransformerException
{
ArrayList list;
//RequestContext.getEventContext().getMessage().setProperty("Content-Ty
pe", "text/html");
//StockQuote quote;
System.out.println("StockQuote Instance of: '" +
src.getClass().getName() + "'");
System.out.println("StockQuote: " + src);
Overview
Message routers control how messages are routed among the services in your Mule
application. Following is a description of the key concepts:
Inbound routers control how a service handles incoming messages, such as selectively
consuming only those messages that meet specific criteria or grouping messages together
that share a group ID before forwarding them on.
Outbound routers control how a message is dispatched after the service has processed it,
such as sending it to a list of recipients or splitting up the message and sending the parts
to different endpoints.
Asynchronous reply routers are used in request/response scenarios where message traffic
is triggered by a request and the traffic needs to be consolidated before a response is given.
The classic example of this is where a request is made and tasks are executed in parallel.
Each task must finish executing and the results processed before a response can be sent
back.
Catch-all strategies are invoked if no routing path can be found for the current message.
An inbound or outbound endpoint can be associated with a catch-all strategy so that any
orphaned messages can be caught and routed to a common location.
Filters provide the logic used to invoke a particular router. Filters can be combined using
the logic filters AndFilter, OrFilter, and NotFilter. Not all routers need to use filters, but
all routers support them.
Asynchronous
If you simply want to put a message on a SEDA queue after processing it, and no response to
the caller is required, you can use the asynchronous message style.
For example:
<model name="Asynchronous_Message_Pattern">
<service name="AsynchronousService">
<inbound>
<jms:inbound-endpoint queue="test.in" synchronous="false"/>
</inbound>
<outbound>
<pass-through-router>
<jms:outbound-endpoint queue="test.out">
<pass-through-router>
</outbound>
</service>
</model>
Request-Response
In simple scenarios that require a response, a service receives a request on a synchronous
inbound endpoint, processes the request, and then sends it back to the caller as a reply. For
example, if a user enters a value in an HTML form, and you want to transform that value
and display the results in the same page, you can simply configure a synchronous inbound
endpoint on the service that does the transformation. This scenario does not use an
outbound router. This is the request-response message style.
For example:
<model name="Request-Response_Message_Pattern">
<service name="SynchronousService">
<inbound>
<http:inbound-endpoint host="localhost" port="8080"
path="/mule/services" synchronous="true"/>
</inbound>
</service>
</model>
Synchronous
If you need to pass the message to a second service for additional processing, you would
configure an outbound router on the first service to pass the message to the second service.
After the second service processes the message, the first service sends it back to the caller as a
reply. Note that setting the synchronous inbound endpoint on the first service means that the
message is treated synchronously throughout all subsequent services, so you do not need to
set the synchronous flag on the second service. This is the synchronous message style.
For example:
<model name="Synchronous_Message_Pattern">
<service name="SynchronousService">
<inbound>
<jms:inbound-endpoint queue="test.in" synchronous="true"/>
</inbound>
<outbound>
<chaining-router>
<jms:outbound-endpoint queue="test.out"/>
</chaining-router>
</outbound>
</service>
<service>
<inbound>
<jms:inbound-endpoint queue="test.out"/>
</inbound>
</service>
</model>
Asynchronous Request-Response
In the most complex scenario, you can enable request-response messaging and allow the
back-end process to be forked to invoke other services, returning a reply asynchronously
based on the results of multiple service invocations. You can set the inbound endpoint's
synchronous flag to false, since the response will be handled by the asynchronous reply
router, unless you also want to send a response to the caller. This is the asynchronous
request-response message style.
<model name="Async_Request-Response_Message_Pattern">
<service name="AsyncRequestResponseService">
<inbound>
<http:inbound-endpoint host="localhost" port="8080"
path="/mule/services" synchronous="false"/>
</inbound>
<async-reply timeout="5000">
<collection-async-reply-router/>
<jms:inbound-endpoint queue="reply.queue"/>
</async-reply>
<outbound>
<multicasting-router>
<reply-to address="jms://reply.queue"/>
<jms:outbound-endpoint queue="service1" synchronous="false"/>
<jms:outbound-endpoint queue="service2" synchronous="false"/>
</multicasting-router>
</outbound>
</service>
</model>
Summary
This lesson described the different message styles you can use. For complete information, see
the appendix on Mule messaging styles in the Mule Configuration Guide.
Now that you understand which message styles to use for routing in different scenarios,
Lesson Five describes several routers you can use for achieving finer control over message
routing.
Filtering Messages
You can control which messages a service handles by using filters. The Selective Consumer
Router works on inbound endpoints to control which messages that service will process. The
Filtering Router works on outbound endpoints to control which messages the service sends
along to the next endpoint. You can use a combination of these approaches to control the
message flow.
For example, if you only want to process messages that don't have errors, you can use a
selective consumer to ensure that only those with the result code success are processed. You
can then use a Catch-all Strategy to forward all other messages to another endpoint for error
handling:
<inbound>
<selective-consumer-router>
<mulexml:jxpath-filter expression="msg/header/resultcode = 'success'"/>
</selective-consumer-router>
<forwarding-catch-all-strategy>
<jms:endpoint topic="error.topic"/>
</forwarding-catch-all-strategy>
</inbound>
If you want the service to process all messages but then want to specify criteria to determine
where the message is sent next, you can use filtering outbound routers. In the following
example, messages that contain an exception are sent to the system administrators email
address, messages whose payload contains a specific string are sent to the string queue, and all
other messages are picked up by the forwarding catch-all router and sent to an error queue:
<outbound>
<forwarding-catch-all-strategy>
<jms:outbound-endpoint queue="error.queue"/>
</forwarding-catch-all-strategy>
<filtering-router>
<smtp:outbound-endpoint to="ross@muleumo.org"/>
<payload-type-filter expectedType="java.lang.Exception"/>
</filtering-router>
<filtering-router>
<jms:outbound-endpoint queue="string.queue"/>
<and-filter>
<payload-type-filter expectedType="java.lang.String"/>
<regex-filter pattern="the quick brown (.*)"/>
</and-filter>
</filtering-router>
</outbound>
Similar routers are the forwarding router, which allows you to process some messages and
selectively forward others, and the wiretap router, which allows you to process all messages
and send them on as normal but also send a copy to another endpoint. For more
information, see the section on inbound routers in the Mule Configuration Guide.
<chaining-router>
</chaining-router>
You can also use the chaining router to perform protocol bridging to a single outbound
endpoint. Unlike the pass-through router, the chaining router always returns a response. For
example:
<service name="HttpProxyService">
<inbound>
<!-- WSDL URL: http://localhost:8888/stockquote.asmx?wsdl -->
<inbound-endpoint address="http://localhost:8888" synchronous="true"/>
</inbound>
<outbound>
<chaining-router>
<outbound-endpoint
address="http://www.webservicex.net#\[header:http.request\]"
synchronous="true"/>
</chaining-router>
</outbound>
</service>
Splitting Messages
A message splitter can be used to break down an outgoing message into parts and dispatch
those parts over different endpoints configured on the router. For example, in an
order-processing application, you might want to send different parts of the message to
different services for processing. You could do this using one of the following routers:
List Message Splitter: accepts a list of objects that will be routed to different endpoints. For
example:
<outbound>
<list-message-splitter-router">
<jms:outbound-endpoint queue="order.queue">
<payload-type-filter expectedType="com.foo.Order"/>
</jms:outbound-endpoint>
<jms:outbound-endpoint queue="item.queue">
<payload-type-filter expectedType="com.foo.Item"/>
</jms:outbound-endpoint>
</list-message-splitter-router>
</outbound>
Filtering XML Message Splitter: similar to the List Message Splitter but operates on XML
documents. For example:
<outbound>
<mulexml:filter-based-splitter splitExpression="root/nodes"
validateSchema="true"
externalSchemaLocation="/com/example/TheSchema.xsd">
<vm:outbound-endpoint path="order">
<payload-type-filter expectedType="com.foo.Order"/>
</vm:outbound-endpoint>
<vm:outbound-endpoint path="item">
<payload-type-filter expectedType="com.foo.Item"/>
</vm:outbound-endpoint>
</mulexml:filter-based-splitter>
</outbound>
Expression Splitter Router: similar to the List Message Splitter but splits the message based
on an expression that returns one or more message parts. For example:
<outbound>
<expression-splitter-router evaluator="xpath"
expression="/mule:mule/mule:model/mule:service"
disableRoundRobin="true" failIfNoMatch="false">
<outbound-endpoint ref="service1">
<expression-filter evaluator="xpath" expression="/mule:service/@name =
'service splitter'"/>
</outbound-endpoint>
<outbound-endpoint ref="service2">
<expression-filter evaluator="xpath" expression="/mule:service/@name =
'round robin deterministic'"/>
</outbound-endpoint>
</expression-splitter-router>
</outbound>
You could also split a message into parts to improve performance. The Round Robin
Message Splitter splits the message into parts and sends them to endpoints in a round-robin
approach. The Message Chunking Router splits a single message into a number of
fixed-length messages that will all be routed to the same endpoint.
After splitting messages, you use the Message Chunking Aggregator to aggregate the
message parts back together again. The aggregator uses the correlation ID, which is set by the
outbound router, to identify which parts belong to the same message.
<inbound>
<message-chunking-aggregator-router>
<expression-message-info-mapping
correlationIdExpression="#[header:correlation]"/>
<payload-type-filter expectedType="org.foo.some.Object"/>
</message-chunking-aggregator-router>
</inbound>
<inbound>
<idempotent-receiver-router idExpression="#[message:id]-#[header:label]">
<simple-text-file-store directory="./idempotent"/>
</idempotent-receiver-router>
</inbound>
Summary
This lesson provided a sampling of some of the routers you can use to control how messages
are processed and routed. For complete information on message routers, see the chapter on
using message routers in the Mule Configuration Guide.
To see additional examples, such as the Stock Quote Example, which illustrates how to add a
proxy service, and the Bookstore Example, which illustrates using CXF, see the Examples
page at http://www.mulesource.org/x/wAm7. The Mule Cookbook
(http://www.mulesource.org/x/dgi7) provides additional code snippets and examples
that users and Mule developers have submitted.
For more information on all topics related to configuring and using Mule, see the Mule
Configuration Guide.
This chapter describes how to use Mule IDE. If you have not already downloaded, installed,
and configured Mule IDE, see Installing and Configuring Mule IDE on page 43.
z To use the default Mule distribution you configured, leave Use default Mule
distribution selected.
z If you want to specify a non-default Mule distribution, select if from the drop-down
list.
z If you want to use a new Mule distribution, click Configure Default..., add it to the
Mule Distributions list, and then select it from the list.
4 If you want your project to include the source and configuration from one of the Mule
example applications, click Add sample project content and select the example you
want to use. Note that not all of the examples that ship with Mule are supported.
5 Click Next, and then click the Libraries tab and verify that the Java 5 or later library is
installed and available on the build path.
6 Click Finish to have Mule IDE generate your project.
The project is added to the Package Explorer pane. The Mule libraries from the distribution
you selected are contained in the project. If you selected an example, the source and
configuration from that example are also in the project.
Warning Make sure you use a unique name. If you specify the name of an existing file, the
new file you are creating will overwrite the existing file.
4 Select each of the Mule modules or transports you want to include in your configuration.
Mule IDE will prepopulate the namespace declarations based on your selections.
Note that the Mule core namespace will be populated by default and does not need to be
selected. If you want to include a custom module or transport or one from MuleForge,
simply add its JAR file to the \lib\user sub-directory under the Mule home directory.
As long as the JAR includes a Spring-based schema file, Mule IDE will include it in the
list.
5 Click Finish.
Mule IDE creates the configuration file in the conf directory of the project you selected. The
namespaces are populated based on the transports and modules you selected and the
distribution version of your project.
4 Specify the project that contains the Mule configuration files you want to test.
5 Click Add and select one or more Mule configuration files in the project.
6 If you want to use a different Mule distribution for the configuration, select Use a
project specific Mule distribution and select the distribution to use.
7 Click the Arguments tab, and then enter any additional arguments or properties you need
to pass to the JVM using -M-DPropertyName=PropertyValue just as you would if you
were passing parameters in at the command line.
8 Click Apply.
You can now click Run to launch the Mule server and test this configuration immediately, or
run this configuration at a later time.
If a launch configuration exists that contains the selected Mule configuration file, it is used to
launch a Mule server. Otherwise, a new run configuration is created automatically and the
server is started. If multiple run configurations already exist that contain the selected Mule
configuration file, you are prompted to choose which one to use.
If your application requires multiple configuration files, you must create the run
configuration manually as described on page 90.
If you want to use a new version of Mule, we recommend that instead of switching the Mule
distribution for your existing project, you should create a new project using the new Mule
distribution. If you have created custom modules or transports, you must copy them from
the previous Mule distribution to the \lib\user sub-directory in the new distribution.
Likewise, you should carefully read the migration page for the new version and follow the
instructions for migrating your configuration and Java files as needed for the new version,
including specifying the new schema version number in the namespace declarations if you
are upgrading to a new major point release (e.g., 2.1 to 2.2).
/bin Shell and batch scripts for controlling Mule from the command
line
/conf Configuration files
/docs API documentation (Javadoc) for Mule and its sub-projects
/examples Example applications you can run and try building yourself
/lib/boot Libraries used by the Java Service Wrapper to boot the server
/lib/endorsed Endorsed Java libraries used by Mule
/lib/mule Mule libraries
/lib/opt Third-party libraries
/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.
/licences License information for all libraries shipped with Mule
/logs Log file output when running in background mode
/sbin Internal scripts (not to be run by the user)
/src The source code for all Mule modules. You can import this into
your IDE
LICENSE.txt License agreement for Mule
README.txt or The Getting Started document
README.pdf
Mule products include the following third-party software as part of the source code,
examples, or as dependencies. The license type for each third-party software product is
indicated in parentheses.
Some components of Mule Enterprise may also contain other software that is commercially
licensed. For more information, contact MuleSoft.
Third-party Software
Software License
Acegi Apache 2.0
Antlr BSD Style
AOP Alliance Public Domain
Apache Axis Apache 2.0
Apache Axis Jaxrpc Apache2.0
Apache Catalina Apache 2.0
Apache Cocoon Project Apache 2.0
Apache Commons Attributes Apache 2.0
Apache Commons Beanutils Apache 2.0
Apache Commons-cli Apache 1.1
Apache Commons Codec Apache 2.0
Apache Commons Collections Apache 2.0
Apache Commons DBUtils Apache 2.0
Apache Commons Discovery Apache 2.0
Apache Commons IO Apache 2.0
Following are the terms youll see as you work with Mule. Because of the dynamic
open-source history of Mule, there are sometimes multiple terms used to describe the same
thing. This glossary lists all terms but refers to the preferred term when there are synonyms.
agent
A service such as the Mule JMX agent that is used by or associated with Mule but is not a
Mule-managed service component. An agent is registered with the Mule Manager and
has the same lifecycle as the Mule instance, so you can initialize and destroy resources when
the Mule instance starts or stops.
channel
A logical pathway on which messages are sent on a messaging framework.
component
See service component
configuration builder
A class that knows how to parse a given configuration file. The default configuration builder
is the org.mule.config.MuleXmlConfigurationBuilder class that knows how to parse a
Mule XML configuration file.
connector
The heart of a transport that maintains the configuration and state for the transport.
endpoint
A configuration entity specifying how and where a message should be routed. The endpoint
is configured in an inbound or outbound router and specifies where the message should be
sent or from where it should be received, using which transport (and optionally which
connector in that transport), and which filters should be applied before routing the message.
Endpoints can also be defined globally instead of in a specific router,.
event
See message
filter
Specifies logic for determining which messages are routed to a component. You can set filters
on an inbound router to filter which messages that service component can receive, or you
can set filters on an outbound router to indicate how you want to route messages after they
have been processed by the service component.
Galaxy
See Mule Service Registry
HQ
See Mule Management Console
inbound router
A Java class that you configure in the Mule configuration file to determine how a service
component will receive messages. The inbound router includes an endpoint that indicates
where the messages will come from.
interceptor
A Java class that is used to intercept message flow into a service component. An
interceptor can be used to trigger or monitor events or interrupt the flow of the message.
management console
See Mule Management Console
message
A packet of data that can be handled and sent between applications on a specific channel.
Data is always wrapped in a message before it is transported by Mule. A message has a header,
which contains metadata about the message (such as the sender information), and the body,
which contains the actual data.
message receiver
A Java class used by a connector to read the incoming data, package it as a message, and
passes it to a service components inbound router. The message receiver can use a
transformer if necessary to convert the data.
message dispatcher
A Java class used by a connector to receive the messages and routing instructions from an
outbound router and send the message to the next service component.
Mule Enterprise
The enterprise version of Mule, available for 30-day trial download from
http://www.mulesource.com/download. Mule Enterprise includes full development
cycles, testing, technical support, maintenance releases and hot fixes, and management and
monitoring tools from MuleSoft. If you are deploying Mule in a mission-critical
environment, want to ensure that you always have a stable, high-quality release, and want
additional tools for managing and monitoring your deployment, you should purchase a
subscription of Mule Enterprise.
Mule Manager
Manages the Mule objects, including connectors, endpoints, and transformers. The Mule
Manager constructs these objects and provides them to the service components in the
Mule Model. Each Mule instance has one Mule Manager and one or more Mule Models.
Mule Model
A service container that hosts the service components and manages their runtime
behavior.
outbound router
A Java class that you configure in the Mule configuration file to determine how a service
component will dispatch messages. The outbound router can include an endpoint to
indicate where the messages should go next, or if no endpoint is configured, it returns the
completed message back to the sender.
POJO
An acronym for plain old Java object, a POJO is a simple Java object, not an enterprise
JavaBean. One advantage of Mule is that your service components can be simple POJOs,
which Mule then wraps and exposes as services.
provider
See transport
queue
See channel
router
A Java class that determines where and how messages are transported between applications.
See also inbound router and outbound router
SEDA
See Staged Event-driven Architecture (SEDA)
service component
A POJO, Spring bean, Java bean, or web service containing the business logic for processing
data in a specific way. Mule simply manages the service component, bundles it with
configuration settings and exposes it as a service, and ensures that the right information is
passed to and from it based on the settings you specified for the service in the Mule
configuration file. In early versions of Mule, service components were called Universal
Message Objects, and UMO is still part of the nomenclature in the Mule APIs today.
service registry
See Mule Service Registry
transformer
A Java class that transforms message payloads (data) to and from different types.
transport
A construct that handles and carries messages on a specific messaging protocol, such as
HTTP, moving the message from one service component to another and transforming
the data as needed along the way
transport provider
See transport
UMO
See service component
Wire Tap
A router that makes copies of messages and forwards them to another endpoint. It can either
forward a copy of all messages that it receives or it can be configured to use a filter and send a
sub-set of these messages only. This router will not prevent messages from being delivered to
service components. See also interceptor.
A C
ActiveMQ 29 catch-all strategies 75
adapters 12 chaining routers 15
administrator channels
what to read in this guide 7 about 11
aggregating messages 15 CIO
ANT_HOME environment variable 33 what to read in this guide 7
Apache CXF 29 client/server topology 21
application developer community release
what to read in this guide 7 about 31
application layer 47 installing 36
applications compression tools 31
creating manually 54 configuring endpoints 18
creating with Mule IDE 51 configuring Mule
modifying 60 tutorial 54
architect configuring routers 18
what to read in this guide 7 CXF 29
architecture
about 12
asynchronous message style 76 D
asynchronous reply routers 75 data 15
asynchronous request-response message logical flow in Mule 18
style 78 processing 13
audience for this guide 6 debugging applications 93
decision makers
what to read in this guide 7
B destinations
basic usage 47 see endpoints
building Mule 31 developer
business analyst what to read in this guide 7
what to read in this guide 7 developer release 31
business logic director of Software Architecture
in the Mule architecture 13 what to read in this guide 7
dispatching messages 15
distributed topology 22
L
G learning to use Mule 51
GZip 31 load-balancing
distributing Mule for 22
logical data flow in Mule 18
H
hub-and-spoke topology 21
M
mainframe applications 21
I Maven 33
IBM WebSphere MQ 21 MAVEN_HOME environment variable 33
implementing Mule 21 message routing 75
T
technical support 8
testing applications 89
TIBCO Rendezvous 21
topologies 21
transformers
about 15
transport layer 47
transports
about 15
configuring endpoints for 17
tutorial 51
typographic conventions 8
U
uniform resource indicators (URI)
in endpoints 17
URIs
in endpoints 17
V
versions
switching 93
W
web services
creating service components from 14
WinZip 31
X
Xalan, JDK
endorsing 44