Mule is an ESB messaging platform based on a staged event-driven architecture (SEDA). (See http://www.eecs.harvard.edu/~mdw/proj/seda/
for a complete discussion of SEDA.) Mule can send and receive messages using three processing models: asynchronous, synchronous, and request/response.
Mule provides a container that manages message-capable services known as Universal Message Objects (UMOs). UMOs can be plain old Java objects (POJOs).
UMOs are made available to other UMOs and applications via message endpoints that allow messages to be routed across a wide array of protocols and technologies such as JMS, SMTP, JDBC, TCP, HTTP, file, intra-VM, etc.
Here are the principal ESB Mule components:
- Mule ManagerThe Mule Manager is the primary component for each instance of a Mule server and is used to manage all Mule objects (connectors, endpoints, transformers, etc.) for each Mule server instance.
- Mule ModelThe Mule Model is the container in which user-supplied components are managed and executed. It controls message flow to and from user-supplied components and manages threading, lifecycle, and pooling of the components.
- UMOsUniversal Message Objects (UMOs) are user-supplied POJOs that can receive and send Mule messages. Mule handles all routing and transformation of events to and from UMOs based on the configuration of the components and/or Java reflection.
- EndpointsEndpoints define URI-based communication channels between two or more components, services, or applications. An endpoint can be configured with message filters, security interceptors, and transaction information. Some examples of endpoints are:
|Figure 2. Mule Components and Objects: The diagram illustrates the relationships and interactions between Mule components and objects.|
- TransformersTransformers transform message payloads from one format to another.
The diagram in Figure 2
illustrates the relationships and interactions of the Mule components and objects.
Configuring a Mule Manager Instance
You must configure each Mule Manager instance with specific properties before using it. To configure a Mule Manager instance from a Java application, you can use one of Mule's configuration builders. For example, to configure a Mule Manager instance from two XML files, you can use the MuleXmlConfigurationBuilder class as follows:
MuleXmlConfigurationBuilder builder =
UMOManager manager =
To configure a Mule Manager instance in a simple fashion with a global endpoint for intra-VM messages, you can use the QuickConfigurationBuilder class in a manner similar to the following:
Sending a Message with Mule
QuickConfigurationBuilder builder = new
To interact with the Mule server from an application you use the Mule client as shown in the following examples:
// create a Mule client
MuleClient client = new MuleClient();
// send a JMS message synchronously
Map payloadProps = null;
UMOMessage message client.send("jms://message.queue",
// receive a pop3 message
long timeout = 3000;
UMOMessage message = client.receive("pop3://mymail.com", timeout);
// asynchronously dispatch an inter-VM message
client.dispatch("vm://mypackage.myobject", "The data", payloadProps);