The Fundamentals of Mule Configuration
Mule, the open source messaging framework for enterprise integration, requires significant configuration using XML files. This article provides an introduction to Mule configuration. First, it covers the basics of Mule you will need to understand.
Author's Note: Many of the links to further Mule documentation require a mulesource.org account.
What Is Mule?Mule is a transport-agnostic, Java-based messaging framework that allows disparate applications to connect without having to call each other directly. Mule supports multiple threading/messaging models (staged event-driven architecture, or SEDA, is the default), input and output to various transports (email, files, databases, etc.), and web services through protocols such as SOAP (see Figure 1).
Click here for larger image
Figure 1: Mule Support for Various Protocols
Mule does not dictate a single standard message format. It allows transformations to be specified only when they are required to interoperate with different services. The Mule Enterprise Edition supports multiple commercial messaging systems as well, including TIBCO Rendezvous and IBM WebSphere MQ.
Leveraging the three layers of its architecture: application, integration, and transport, Mule implements an enterprise service bus (ESB) and provides a platform for a service oriented architecture (SOA). The layered approach promotes reusability (see Figure 2).
Click here for larger image
Figure 2: Layered Approach to Promote Reusability
Installing MuleMulesource.org provides two releases of Mule:
- Enterprise (licensed and supported as a commercial product trial available here)
- Community (a less-featured, open-source version)
A "Getting Started Guide" for Mule is available here. For Eclipse development, the easiest way to begin is to set the classpath to include all .jar files in the ./lib/mule and ./lib/opt directories of the distribution.
Running MuleMule can be embedded in a Java application, application server, or as a web application. To run Mule, you must specify a configuration file, which describes Mule settings. You can start a Mule Server in various ways:
- At the command prompt:
mule [-config ]
- From a script:
org.mule.MuleServer -config mule-config.xml //create a new server and configure it with two configuration files MuleServer server = new MuleServer("mule-config1.xml,mule-config2.xml"); //Start the server. The boolean argument determines if the server should start //in a new thread or use the current thread server.start(true);
- By specifying a fully qualified class name of the configuration builder (If this is not specified, Mule uses the default org.mule.config.builders.AutoConfigurationBuilder.):
org.mule.MuleServer -builder -config appContext.xml
- By assigning a specific server ID and interacting with the Mule environment:
AutoConfigurationBuilder configbuilder = new AutoConfigurationBuilder("C:/MuleConfDir/mule-config.xml"); DefaultMuleConfiguration muleConfig = new DefaultMuleConfiguration(); muleConfig.setId("MY_SERVER_ID_1"); MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder(); contextBuilder.setMuleConfiguration(muleConfig); MuleContext muleContext = new DefaultMuleContextFactory().createMuleContext(configbuilder, contextBuilder); muleContext.start();