Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Implementing an Enterprise Service Bus in Java : Page 2

Using the open source Mule project, you can build a highly customized Enterprise Service Bus (ESB) that meets your specific needs.


advertisement
Introducing Mule
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 Manager—The Mule Manager is the primary component for each instance of a Mule server and is used to manage all Mule objects (connectors, endpoints, transformers, etc.) for each Mule server instance.
  • Mule Model—The 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.
  • UMOs—Universal 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.
  • Endpoints—Endpoints 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:
    • pop3://user:password@mymail.com
    • jms://message.queue
    • http://localhost/mule
    • file:///tmp/messages/in
    •  
      Figure 2. Mule Components and Objects: The diagram illustrates the relationships and interactions between Mule components and objects.
    • vm://mypackage.myobject
    • axis:http://localhost/services/mypackage.myobject
  • Transformers—Transformers 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 = new MuleXmlConfigurationBuilder(); UMOManager manager = builder.configure("mule-main-config.xml, mule-components.xml);

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:

QuickConfigurationBuilder builder = new QuickConfigurationBuilder(); builder.createStartedManager(true, "vm://tmp/messages");

Sending a Message with Mule
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", "The data",payloadProps); // 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);



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap