Skip to main content

Architecting on demand solutions, Part 13: Integrate BPEL with Enterprise Service Bus in WebSphere Application Server V6

Christina Lau (clau@ca.ibm.com), STSM, Software Group, IBM, Software Group
Christina Lau is a Senior Technical Staff Member at IBM. Christina is an architect on the On Demand Development team focusing on the next generation technologies for the On Demand Operating Environment. You can reach Christina at clau@ca.ibm.com.
Colin Yu (coliny@ca.ibm.com), Technical Development Manager, IBM, Software Group
Colin Yu is a technical software development manager at IBM. Colin is on the Service Oriented Asset Repository Development team focusing on reusable asset repository and SOA asset development. You can reach Colin at coliny@ca.ibm.com.

Summary:  This article, which extends Part 11 in the "Architecting on demand solutions series," shows how you can integrate Business Process Execution Language (BPEL)-based business processes with service providers using the Enterprise Service Bus (ESB) capabilities in IBM WebSphere® Application Server V6. You see an example that shows how the flexibility of the service-oriented architecture allows existing services, such as credit checks, to be consumed into a new application.

View more content in this series

Date:  04 Oct 2005
Level:  Intermediate
Activity:  936 views
Comments:  

Introduction

Building on Part 11 in the series, this article helps you use BPEL and the ESB together to implement a service-oriented architecture (SOA). In Part 2, WebSphere Business Integration Message Broker implemented the ESB patterns for the customer enrollment application. A new messaging engine written in Java™ was added to the WebSphere Application Server V6, and it provides support for queuing, routing, transformation, and standards. The messaging engine consists of three main components: the service integration bus, a list of destinations, and mediations. Previous articles (see Resources) explain these concepts in detail.


Revisiting the personal loan scenario

In Part 3, we used BPEL to implement the odFinance personal loan business process. The doCreditCheck activity performs a credit check on the client to ensure they have a good credit history with other financial institutions. The credit-checking services can be provided by multiple providers, and odFinance doesn't care which provider is used. Next we use the ESB to route the request to the different providers in a round-robin fashion. Figure 1 shows the interaction between the personal loan business process, the ESB, and the credit-check providers.


Figure 1. Use the ESB to virtualize services
Using ESB to virtualize services

Configuring V5 default messaging in WebSphere Application Server V6

The Service Integration Bus (SIB) in WebSphere Application Server V6 supports Java Message Service (JMS) clients running on WebSphere Application Server V5 to communicate with the SIB using the V5 default messaging JMS provider. This provider wraps the V6 JMS resources as V5 JMS resources to support the interoperability of V5 JMS clients. To configure V6 to interoperate with V5 JMS clients, do the following steps:

  1. Configure the SIB in WebSphere Application Server V6.
  2. Create a WebSphere MQ client link.
  3. Create JMS resources for V5 JMS clients.
  4. Create an SIB base queue and alias queue.

Configure the SIB in WebSphere Application Server V6

Previous articles in this series describe how to create an SIB, so we won't repeat the details here. For the purpose of the sample, create a bus with the name V5toV6Bus, add a new bus member to the local server, and configure the messaging engine.

Create a WebSphere MQ client link

The WebSphere MQ client link enables WebSphere Application Server V5 J2EE applications to use messaging resources of the Application Server V5 default messaging provider that are backed by destinations on the SIB.

Each WebSphere MQ client link presents itself as a queue manager and transforms between the WebSphere MQ client protocols used by V5 JMS applications and the Application Server V6 protocols used by messaging engines.

To create a WebSphere MQ Client link:

  1. From the Messaging Engine Configuration panel, select WebSphere MQ client links, as shown in Figure 2.
  2. Create a new WebSphere MQ Client Link and specify the properties:

    Name: Enter MyMQClientLink
    MQ Channel Name: Use the default WAS.JMS.SVRCONN
    Queue Manager Name: Use the default in the form of WAS_node_name_server_name

  3. Default queue manager: Select this checkbox so you can use the MQ client link as the default queue manager when an application cannot find a queue manager it specifies to communicate with.

Figure 2. Defining WebSphere MQ client links
Defining WebSphere MQ client links

Creating JMS resources for V5 clients

To create the JMS resources for V5 JMS applications, use WebSphere Application Server V6 administrative console to create a V5 default messaging provider, as follows.

  1. Select Resources > JMS Providers > V5 default messaging from the navigation bar, as shown in Figure 3.
  2. Select WebSphere queue connection factories to create a QueueConnectionFactory. Use jms/QCF as the JNDI name.
  3. Select WebSphere queue destinations to create a queue. Use Q1 as the queue name and jms/Q1 as the JNDI name. Unlike the V6 JMS resource, which is explicitly mapped to an SIB base queue, the queue name of the V5 JMS resource is used to map to an SIB base queue implicitly. For example, a queue named Q1 is mapped to an SIB queue named WQ_Q1. The WQ_ prefix is added by the WebSphere MQ classes for JMS. So, if you send a message to a JMS queue with a name Q1, the message will be routed to an SIB base queue named WQ_Q1.

Figure 3. Select V5 default message to create JMS resources for V5 clients
Select V5 default message to create JMS resources for V5 clients

Create an SIB base queue and alias queue

After you've defined a V5 JMS queue (Q1) for the V5 default messaging JMS provider, you also need to define a concrete queue named WQ_Q1 in the SIB messaging engine. The recommended way to support both V6 and V5 JMS clients is to create a base SIB queue named Q1. Next create an alias queue named WQ_Q1 that points to the target base Q1 queue.

The messages eventually arrive at Q1 when the WebSphere MQ client link routes the message to WQ_Q1, because the V6 JMS client does not impose the WQ_ prefix. If you define an alias queue, regardless of whether the clients are from V5 or V6, the messages will eventually arrive at Q1.

To create the SIB base queue:

  1. Select the V5toV6Bus bus.
  2. Select Queue as the destination type.
  3. Enter Q1 as the identifier. Select the bus member and complete the creation of the queue.

To create the alias queue:

  1. Select the V5toV6Bus bus.
  2. Select Alias as the destination type.
  3. Enter WQ_Q1 as the identifier, and enter Q1 as the target identifier. Select V5toV6Bus as the target bus and complete the creation of the alias queue.

Figure 4 shows the result destinations on the V5toV6Bus.


Figure 4. Create queue and alias
Create queue and alias

Creating a simple BPEL to send a JMS message

Using WebSphere Studio Application Developer Integration Edition (Application Developer) V5.1.1, create a simplified loan process (shown in Figure 5), with a credit-check activity that sends a JMS message to the JMS queue (Q1). The Web Services Description Language (WSDL) of the credit-check service is shown in Listing 1.


Figure 5. Simplified loan process BPEL
Simplified loan process BPEL

Listing 1. WSDL for credit-check service
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="JMSService"
  targetNamespace="http://jms.demo.ibm.com/JMSService"
  xmlns="http://schemas.xmlsoap.org/wsdl/"
  xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
  xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/"
  xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms/"
xmlns:tns="http://jms.demo.ibm.com/JMSService"   
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <message name="SimpleMessage">
      <part name="ssn" type="xsd:string"/>
  </message>
  <portType name="SendMessagePortType">
      <operation name="send">
          <input message="tns:SimpleMessage"/>
      </operation>
  </portType>
  <binding name="JMSBinding" type="tns:SendMessagePortType">
      <jms:binding type="TextMessage"/>
      <format:typeMapping encoding="XML">
          <format:typeMap formatType="java.lang.String" typeName="xsd:string"/>
      </format:typeMapping>
      <operation name="send">
          <jms:operation/>
          <input>
            <jms:input parts="ssn"/>
            <jms:propertyValue name="WSDLBinding" type="xsd:string"
            value="http://jms.demo.ibm.com/JMSService:JMSBinding"/>
            <jms:propertyValue name="WSDLOperation"
               type="xsd:string" value="send"/>
          </input>
      </operation>
  </binding>
  <service name="JMSService">
      <port binding="tns:JMSBinding" name="JMSPort">
         <jms:address destinationStyle="queue"
            initialContextFactory="com.ibm.websphere.naming.WsnInitialContextFactory"
            jndiConnectionFactoryName="jms/QCF"
            jndiDestinationName="jms/Q1" jndiProviderURL="iiop://hostname:2809/">
           <jms:propertyValue name="JMSTimeToLive" type="xsd:long" value="0"/>
           <jms:propertyValue name="JMSExpiration" type="xsd:long" value="0"/>
         </jms:address>
      </port>
  </service>
</definitions>

The <jms:address> section needs to be customized to your environment:

  • The JNDI name of the queue connection factory and queue.
  • The JNDI provider URL. WebSphere Application Server V6 uses 2809 as the default port number.
  • The JMS propertyValue elements for message expiration. Without these two elements, the JMS message will have a default value specified by Web Service Invocation Framework (WSIF). If the value is 0, the message will never expire.

Unit testing

After generating the deploy code for the loan process, we can unit test the process with the Process Web client shipped with Application Developer, as shown in Figure 6.


Figure 6. Sending a message to the queue using the Process Web client
Sending a message to the queue using the Process Web client

Next, verify that the message has arrived in the SIB base queue Q1. From the Application Server V6 administrative console:

  1. Select Buses from the navigation bar.
  2. Select the bus you defined.
  3. Select Destinations.
  4. Select Q1 from the list.
  5. Select Queue points from the Message points section.
  6. Select the Q1 queue point identifier from the list.
  7. Select the Runtime tab.
  8. Select the Messages link from the Additional Properties section.

You will find the message sent from BPEL. Select the identifier link. Next, select Message Body from the Additional Properties section. You should see the content of the message that matches your input from the Process Web client, as shown in Figure 7.


Figure 7. Examine the message
Examine the message

Adding a routing mediation

The next step is to bring a routing mediator into the picture. In this simple scenario, we add two SIB base queues, Q2 and Q3, for the two service providers to listen to. The message coming to Q1 will be routed to Q2 or Q3 in a round-robin pattern.

Instead of developing and deploying the routing mediation from scratch, you can take advantage of the WebSphere Platform Message Patterns described in Part 11. You can develop a class (for example, SimpleRoutingMediation), add it to your Unified Modeling Language (UML) model, and mark it up with the <<Mediation>> keyword. Then you can use the patterns to help you deploy and configure your new mediations. The implementation code for this new mediation is shown in Listing 2.

Alternatively, you can also configure and deploy the mediation following the documentation in IBM Rational® Application Developer.


Listing 2. SimpleRoutingMediation implementation
public class SimpleRoutingMediation implements MediationHandler {

  /* (non-Javadoc)
   * @see com.ibm.websphere.sib.mediation.handler.MediationHandler#
      handle(javax.xml.rpc.handler.MessageContext)
    */
	
  public static final String remoteDestination1Name="Q2";
  public static final String remoteDestination2Name="Q3";
	
  private static String routingDestination=remoteDestination1Name;
	
  public boolean handle(MessageContext context) throws MessageContextException {
		
   SIMessageContext mediationContext = (SIMessageContext) context;
   SIMessage message = mediationContext.getSIMessage();
		
   SIMediationSession mediationSession = mediationContext.getSession();
		
    // Create a forward routing path which will be set on the cloned message
    Vector forwardRoutingPath = new Vector();
		
   SIDestinationAddressFactory destFactory = SIDestinationAddressFactory.getInstance();
		
   SIDestinationAddress dest;
		
   if (routingDestination.equals(remoteDestination1Name)){
	 dest = destFactory.createSIDestinationAddress(remoteDestination1Name,true);
	 routingDestination = remoteDestination2Name;
	}
	else{
	 dest = destFactory.createSIDestinationAddress(remoteDestination2Name,true);
	 routingDestination = remoteDestination1Name;
	}
	forwardRoutingPath.add(dest);
	message.setForwardRoutingPath(forwardRoutingPath);
		
	return true;
}
}


Adding message-driven beans to receive the messages

Finally, you need to enable the two credit-check providers to receive messages from the queues. You can also use the Message Facade Pattern described in Part 11 to assist you. The Message Facade Pattern allows the credit-check services to be invoked asynchronously by implementing a message-driven bean.


Summary

In this article, you learned how to integrate BPEL-based business processes deployed on WebSphere Business Integration Server Foundation V5 with service providers deployed elsewhere using the ESB capabilities in WebSphere Application Server V6.0. Using a simple loan example, we demonstrated the flexibility of a service-oriented architecture. This type of architecture allows existing services, such as credit checks, to be consumed into a new application, even though each is running on a completely different system.



Downloads

DescriptionNameSizeDownload method
mediation project interchange codei-odoebp13code1.zip6 KB HTTP | Download Director
BPEL project interchange codei-odoebp13code2.zip21 KB HTTP | Download Director

Information about download methods


Resources

About the authors

Christina Lau

Christina Lau is a Senior Technical Staff Member at IBM. Christina is an architect on the On Demand Development team focusing on the next generation technologies for the On Demand Operating Environment. You can reach Christina at clau@ca.ibm.com.

Colin Yu

Colin Yu is a technical software development manager at IBM. Colin is on the Service Oriented Asset Repository Development team focusing on reusable asset repository and SOA asset development. You can reach Colin at coliny@ca.ibm.com.

Comments



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Sample IT projects, WebSphere, Architecture
ArticleID=94626
ArticleTitle=Architecting on demand solutions, Part 13: Integrate BPEL with Enterprise Service Bus in WebSphere Application Server V6
publish-date=10042005
author1-email=clau@ca.ibm.com
author1-email-cc=
author2-email=coliny@ca.ibm.com
author2-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).