Implementation of the ESB
Using the interfaces designed and discussed above, you can construct an implementation for a simple ESB. The rest of this article describes the classes required for a simple HTTP-based ESB. Building it involves using a servlet as the ESB implementation class.
|Figure 4. Control Flow: The diagram shows how control flows from an HTTP-based client to the ESB servlet and back.|
shows how control flows from an HTTP-based client to the ESB servlet and back.
As illustrated in Figure 4:
- A browser transmits an HTTP request to the ESB servlet.
- The ESB servlet dispatches the message contained in the request to the runtime engine.
- The runtime engine hands the message off to the mediator.
- The mediator performs any necessary augmentation, transformation, and security on the message.
- The mediator routes the message to the destination belonging to a ServiceProvider (in this case, an instance of the MuleEchoMessageService class).
If all goes well, the ESB propagates a success value back up the chain and a passes a success response back to the client.
Here are the primary classes for the HTTP-based ESB, along with links to listings showing the source code. You can download the source to the sample project to experiment with it on your machine.
Installing and Deploying the ESB Web Application
- HTTPESBEncapsulates the data and behavior for an HTTP request/response service bus. HTTPESB contains a RuntimeEngine instance that interacts between service requesters and service providers (see Listing 1).
- SimpleRuntimeEngineEncapsulates the data and behavior of the ESB and uses mediators to transform, augment, and secure messages and to route service interactions between service requesters and service providers (see Listing 2).
- MuleMessageManagerFactoryCreates/returns an instance of MuleMessageManager (see Listing 3).
- MuleMediatorEncapsulates the data and behavior for a Mule-based mediator (see Listing 4).
- MuleMessageClientEncapsulates the data and behavior for a Mule-based message transmitter and service registry (see Listing 5).
- MuleEchoMessageServiceEncapsulates the data and behavior for a Mule UMO that simply holds and echoes a message (see Listing 6).
To deploy an ESB Web application you must download and install a J2SE Development Kit (JDK), version 1.4 or greater, from Sun, download the latest version of Mule, download and install a servlet container, and create the necessary files and directories for the Web application. The following sections explain these steps.
Downloading and Installing a JDK
The following steps will walk you through downloading and installing a JDK:
Downloading and Installing Mule
- Download a version 1.4 or greater of the JDK from http://java.sun.com/j2se/.
- Unpack the downloaded archives to the directories of your choosing.
Follow these steps will to download and install Mule:
Downloading and Installing the Tomcat Servlet Container
- Download the latest version of the full Mule distribution and the Mini-Mule distribution from http://mule.codehaus.org/Download.
- Unpack the downloaded archives and/or install the JDK to the directories of your choosing.
To download and install a servlet container:
- Download a version 5.x or greater of the Tomcat servlet container from http://jakarta.apache.org/tomcat/index.html.
- Unpack the downloaded archives and/or install Tomcat to the directories of your choosing.