Other constraints might require you to have an infrastructure that enables heterogeneous applications to integrate seamlessly without altering their design. An enterprise service bus (ESB) is one way of realizing such an enterprise integration architecture.
Although each enterprise will likely create its ESB in its own unique way, it is important to keep flexibility in mind when considering the definition of an ESB. There's no fixed approach to building one. The idea is to have a connectivity layer that optimizes interactions between service consumers and service providers, one that can respond to event-, message-, or service-oriented contexts.
This article discusses an approach for building an extensible Java-based ESB that supports the most common ESB functional requirements.
An ESB's common requirements are also its most commonly used features:
Figure 1 shows an ESB's main architectural components. It has three broad compartments:
Figure 1. Architectural components of ESB. Click on thumbnail to view full-sized image.
All of these ESB parts are glued together by an XML document that lists all the routes on which the ESB operates. The different transport handlers, transformers, and retry policies and their connection to different routes are all wired via this XML document.
The XML listing—ESBConfiguration.xml, which appears below—gives us some idea about an ESB's workings. The main elements of interest in ESBConfiguration.xml are the following:
Beans: This element contains zero or more Bean elements.
Bean: This element basically defines the way we create and configure a Bean class. It has the following attributes:
name: Unique name that can be used to refer to this bean.
className: Fully qualified name of the bean class.
Property elements as children. Each Property element has an attribute name that identifies it and a child element of type Value that holds the property value. These properties are actually the JavaBeans-style members of the class that can configure
the bean class.
RetryPolicies: This element contains zero or more RetryPolicy children.
RetryPolicy: This element defines the retry policy for a given route. It has an attribute name that can be used to refer to it. It has two child elements named MaxRetries and RetryInterval.
Route: The EsbConfiguration root element can contain zero or more child elements of this type. It basically represents a route for the ESB. It has the
following attributes:
name: Unique name that can be used to refer to this route.
retryPolicyRef: Reference to the retry policy. It should match the RetryPolicy element's name attribute.
transformerRef: Reference to a bean that represents the transformer. It should match the Bean element's name attribute.
Route element can have one or more child elements of type TransportHandlerRef. This child basically points to a bean that represents an appropriate transport handler that should be used for this route,
and the public method name of that bean that should be invoked to send the message. Optionally, the Route element can have one DeadLetterDestination child that points to another route representing a dead-letter destination.
A sample XML document, EsbConfiguration.xml, appears below:
<?xml version="1.0" encoding="UTF-8"?>
<EsbConfiguration xmlns="http://www.bss.org/esb/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Route name="creditService" retryPolicyRef="100-sec-retry" transformerRef="creditServiceTransform">
<TransportHandler beanName="creditJMSTransport"/>
<DeadLetterDestination routeName="DeadLetter"/>
<AuthConstraint principals="app-1"/>
</Route>
<Route name="taxCalculationService" retryPolicyRef="500-sec-retry" transformerRef="taxCalcServiceTransform">
<TransportHandler beanName="taxCalcWS"/>
<DeadLetterDestination routeName="DeadLetter"/>
<AuthConstraint principals="app-2"/>
</Route>
<Route name="RedeliveryRequest" retryPolicyRef="500-sec-retry">
<TransportHandler beanName="redeliveryRequestJMSTransport"/>
<DeadLetterDestination routeName="DeadLetter"/>
</Route>
<Route name="DeadLetter" retryPolicyRef="500-sec-retry">
<TransportHandler beanName="deadLetterJMSTransport"/>
</Route>
<Route name="Redelivery" retryPolicyRef="500-sec-retry">
<TransportHandler beanName="redeliveryJMSTransport"/>
<DeadLetterDestination routeName="DeadLetter"/>
</Route>
<Route name="Error" retryPolicyRef="500-sec-retry">
<TransportHandler beanName="errorJMSTransport"/>
</Route>
<Beans>
<!-- Transport handlers for the service components. -->
<Bean name="creditJMSTransport" className="org.bss.esb.transport.jms.JmsHandler">
<Property name="ConnectionFactory" type="java.lang.String">
<Value>qcf-1</Value>
</Property>
<Property name="Destination" type="java.lang.String">
<Value>myCreditQueue</Value>
</Property>
</Bean>
<Bean name="taxCalcWS" className="org.bss.esb.transport.webservice.WebServiceHandler">
<Property name="WsdlUrl" type="java.lang.String">
<Value>http://www.tax.com/calc</Value>
</Property>
</Bean>
<!-- Transformer beans for the service components -->
<Bean name="creditServiceTransform" className="org.bss.esb.transform.XSLTransform">
<Property name="XslUrl" type="java.lang.String">
<Value>file:///C:/temp/esb/transform/xsl/credit.xsl</Value>
</Property>
</Bean>
<Bean name="taxCalcServiceTransform" className="org.bss.esb.transform.CustomTransform">
<Property name="ConfigFileUrl" type="java.lang.String">
<Value>file:///C:/temp/esb/transform/custom/configManager.properties</Value>
</Property>
</Bean>
<!-- Transport handlers for the system queues -->
<Bean name="redeliveryJMSTransport" className="org.bss.esb.transport.jms.JmsHandler">
<Property name="ConnectionFactory" type="java.lang.String">
<Value>qcf-1</Value>
</Property>
<Property name="Destination" type="java.lang.String">
<Value>Redelivery.Queue</Value>
</Property>
</Bean>
<Bean name="deadLetterJMSTransport" className="org.bss.esb.transport.jms.JmsHandler">
<Property name="ConnectionFactory" type="java.lang.String">
<Value>qcf-1</Value>
</Property>
<Property name="Destination" type="java.lang.String">
<Value>System.DL.Queue</Value>
</Property>
</Bean>
<Bean name="errorJMSTransport" className="org.bss.esb.transport.jms.JmsHandler">
<Property name="ConnectionFactory" type="java.lang.String">
<Value>qcf-1</Value>
</Property>
<Property name="Destination" type="java.lang.String">
<Value>System.Error.Queue</Value>
</Property>
</Bean>
<Bean name="redeliveryRequestJMSTransport" className="org.bss.esb.transport.jms.EsbRedeliveryHandler">
<Property name="ConnectionFactory" type="java.lang.String">
<Value>qcf-1</Value>
</Property>
<Property name="Destination" type="java.lang.String">
<Value>Redelivery.Request.Topic</Value>
</Property>
</Bean>
</Beans>
<!-- Defines the retry policies that can be used by various route definitions. -->
<RetryPolicies>
<RetryPolicy name="100-sec-retry">
<MaxRetries>10</MaxRetries>
<RetryInterval>100</RetryInterval>
</RetryPolicy>
<RetryPolicy name="500-sec-retry">
<MaxRetries>10</MaxRetries>
<RetryInterval>500</RetryInterval>
</RetryPolicy>
</RetryPolicies>
</EsbConfiguration>
The ESBConfiguration.xml document dictates our ESB's behavior. The EsbRouter MDB loads this XML from a location specified in its deployment descriptor. The information it contains is then organized
into a datastructure depicted in Figure 2 below.
Archived Discussions (Read only)