Skip to main content

Architecting on demand solutions, Part 11: Build ESB connectivity with Rational Software Architecture (RSA) WebSphere Platform Messaging Patterns

Christina Lau (clau@ca.ibm.com), Senior Technical Staff Member, IBM Canada Ltd.
Christina Lau
Christina Lau is a Senior Technical Staff Member at IBM. Christina is an architect on the On Demand Development team focusing on next-generation technologies for the IBM On Demand Operating Environment.
Murray Beaton (beatonm@ca.ibm.com), Advisory Software Developer, IBM Canada Ltd.
Murray Beaton
Murray Beaton is an Advisory Software Developer for the On Demand Software Development team. Murray's previous role was Technical Team Lead with WebSphere Studio Application Developer.
James Abbott (jrabbott@us.ibm.com), Advisory Software Developer, IBM Corporation
James Abbott
James Abbott is an Advisory Software Developer for the On Demand Software Development team. His major focus is on patterns and transforms for model-driven development. During his career, he has worked on a series of model-based application development tools for IBM Rational Software and other companies.

Summary:  Why go through the hassle of figuring out how to integrate and connect J2EE components to add Enterprise Service Bus (ESB) connectivity when someone else has done the work for you? And wants to share it with you! IBM Rational® Software Architect (RSA) now supports IBM WebSphere® Platform Messaging Patterns that help you rapidly and easily generate the Enterprise JavaBeans (EJB) and Java™ artifacts and a JACL script for configuring the service integration bus in WebSphere Application Server V6.0. Discover how to use these patterns to build ESB connectivity and to use a model-driven approach to develop service-oriented architecture (SOA) solutions.

Date:  02 Aug 2005
Level:  Introductory
Activity:  2530 views

Introduction

This article extends Part 8 of the series, where you learned to use Enterprise Patterns to quickly build Java 2 Platform, Enterprise Edition (J2EE) applications using Rational Software Architect (RSA). In this article, you use the newly released WebSphere Platform Messaging Patterns to connect and integrate J2EE components. The results are simple examples of an ESB, an essential component in an SOA solution.

This article builds on the information in Part 8 and shows you how WebSphere Platform Messaging Patterns can help you rapidly configure connectivity on WebSphere Application Server (Application Server) 6.0. You also learn how to add mediation capabilities using the mediation patterns that are provided.


Overview of Rational Software Architect WebSphere Platform Messaging Patterns

The WebSphere Platform Messaging Patterns are packaged as a reusable asset that can be imported and installed into Rational Software Architect. This asset extends the Enterprise Patterns asset by adding support for WebSphere Platform Messaging. In this asset four application patterns generate EJB components and Java artifacts, and two topology patterns generate JACL script for configuring the service integration bus in Application Server 6.0.

The application patterns are:

Message Delegate
Used to create a client to send a message over JMS. Similar to the Business Delegate in the Enterprise Patterns, it is implemented as a plain old Java object (POJO). The pattern generates the code into the Application Client project and also automatically updates the application client deployment descriptor.
Message Logger Mediation
Logging of a message for audit purpose is a common mediation pattern. The Message Logger Mediation pattern leverages Service Data Object (SDO) to log the incoming message to a database table for future retrieval or audit.
XSLT Mediation
Transformation of the message from one format to another is also a common mediation pattern. The XSLT Mediation pattern enables users to transform the input message from one format to another using the XSLT stylesheet that is specified in the pattern parameter.
Mediation List Handler
Used to configure a list of mediations into a mediation handler list that can be invoked in sequence. A mediation handler list is a simple pipeline of mediations. This pattern updates the EJB deployment descriptors.

The topology patterns are:

Service Integration Bus
Configures the service integration bus on Application Server 6.0 to use a queue destination and to optionally associate mediation with the queue.
JMS Connection
Configures a Java Message Service (JMS) connection with Java Naming and Directory Interface (JNDI) names for the connection factory, queue, and activation spec for connecting to the physical queue. These parameters are used by the Message Delegate pattern to make a JMS connection.

Install WebSphere Platform Messaging Patterns

WebSphere Platform Messaging Patterns require Rational Software Architect 6.0.0.1 or 6.0.1. Installing this asset requires connecting to the RAS repository using the Rational XDE Repository Connection wizard, as shown in Part 8. Import the WebSphere Pattern Messaging Patterns asset using the Asset Explorer Import menu, as shown in Figure 1.


Figure 1. Importing WebSphere Platforms Messaging Patterns asset
Importing WPMPatterns .ras

After you restart Rational Software Architect, the WebSphere Platform Messaging Patterns appear in the Pattern Explorer, as show in Figure 2.


Figure 2. WebSphere Platform Messaging Patterns in Pattern Explorer
Pattern Explorer

Relationship to Enterprise Patterns and ODFinance scenario

In Part 8 we used the Enterprise Patterns to create the Session Façade, Business Delegate, and the Message Façade code. Together they provide the function on the service provider side, as shown in Figure 3.

In this article, we'll extend what we built by generating a JMS client to send a message using the Message Delegate pattern. And we show you how to configure WebSphere Platform Messaging using the topology patterns. We'll then add the logging and XSLT transformation mediations to the bus using the mediation patterns that are included in the new asset.


Figure 3. Adding WebSphere Platform Messaging to the ODFinance scenario
Senario Architecture

Before you begin:

  1. Import the Finance.ear file from the download provided in Part 8. Figure 4 shows the J2EE perspective after the EAR is imported. The AccountingMessageFacadeBean implements the onMessage() method that takes the input message and invokes the business delegate to update the customer information in the database.
  2. Create a new Unified Modeling Language (UML) model, for example ESBDemo. Drag and drop the Service Integration Bus pattern into the model. The Service Integration Bus pattern takes two parameters:
    • The first is a UML component with a <<Bus>> keyword to represent the bus.
    • The second is a UML component with a <<Queue>> keyword to represent a queue destination.

Figure 4. J2EE perspective after importing Finance.ear
Project Explorer

In Part 8, the user had to manually configure the Service Integration Bus using the Application Server 6.0 admin console. Using the WebSphere Platform Messaging Topology patterns, you can visually construct a deployment model and generate the underlying JACL scripts.

In this example, we create a bus named FinanceBus and a queue named FinanceQueue. In the FinanceBus component, specify the server name server1 and the node name wwwa-jabbottNode02. These UML components are shown in Figure 5.


Figure 5. Service Integration Bus Pattern
SIB Pattern Diagram

The next step is to use the JMS Connection pattern to create a JMS connection component that encapsulates the JMS connection parameters.

  1. Drag and drop the JMS Connection pattern into the model.
  2. Bind the FinanceQueue component to the Queue parameter. Review Part 8 of the series to get the JNDI names for the JMS resources (for example, connection factory is jms/FinanceCF).
  3. Create a new UML component FinanceJMSConnection to encapsulate these parameters.

The completed pattern is shown in Figure 6.


Figure 6. JMS Connection Pattern
JMS Connection Pattern Diagram

Run UML to JACL transform to generate the JACL script

The new UML to JACL transform is included in this asset. You can use the transform to generate a JACL script for the UML deployment model. Select Transform > Run Transformation > UML to JACL to invoke the transform, as shown in Figure 7. This generates a FinanceBus.jacl file in the FinanceEJB project under the ejbModule directory.


Figure 7. UML to JACL transformation
Run Transformation

In a command line, invoke the wsadmin command (in the Application Server 6.0 bin directory) with the FinanceBus.jacl to create the bus and queue configuration:

wsadmin.bat –f e:\FinanceEJB\ejbModule\FinanceBus.jacl

Figure 8 shows the messages that display on the Console tab after the JACL script is run.


Figure 8. Messages display on server console
Script output in Console

Apply the Message Delegate pattern

Now that you've configured the Service Integration Bus, it's time to create the service requester that will send a message using the JMS connection.

In the model, create a new UML package, service.requester, to contain the client artifacts. Drag and drop the Message Delegate pattern. The first parameter represents the POJO class that will contain the send message implementation. The second parameter takes a JMS UML component. Bind the FinanceJMSConnection component we created earlier into this parameter. Figure 9 shows the completed pattern instance.


Figure 9. Message Delegate pattern
Message Delegate Pattern Diagram

Run UML to Java Transform to generate the client code

Create a new Application Client project called MessageRequester to contain the client code. Invoke the UML to Java Transform from the service.requester package and select MessageRequester Application Client Project, as shown in Figure 10. This generates the MessageDelegate implementation in this project under the service.requester package, as well as updates the application client deployment descriptor with the appropriate WebSphere bindings for the resource references.


Figure 10. UML to Java transformation
Run Transformation for UML to Java

To send a message, you can select Run and create a new Application Server 6.0 application client configuration. Select the appropriate EAR and application client module. Select Run to run the application client. The WebSphere 6.0 Application Client console should now show the invocation of the MessageDelegate, as shown in Figure 11a. The AccountingMessageFacadeMDB then receives the message text with the customer information, as shown in Figure 11b.


Figure 11a. Service requester – application client sends a request message
Console output of MessageRequester

Figure 11b. Service provider – AccountingMessageFacade MDB receives the message
Console output of Application Server

Apply the Mediation Patterns

Mediations allow you to manipulate a message as it traverses the bus. The Message Logger Mediation pattern logs a copy of the message to a database table. The XSLT Mediation pattern transforms the incoming message using the specified XSLT stylesheet. We can use the Mediation List Handler pattern to compose these two mediations into a single mediation handler list so they can be executed sequentially. In this section you will add mediations to the message being sent between the service requester and the service provider described earlier.

  1. In the model, create a new UML package called mediations.
  2. Drag and drop the Message Logger Mediation pattern. Generate a new class, MessageLoggerMediation for the logging mediation, and specify the JNDI name for the database.
  3. Drag and drop the XSLT Mediation pattern. Generate a new class, XSLTMediation for the XSLT mediation, and specify the URI for the XSL stylesheet.
  4. Drag and drop the Mediation List Handler pattern. Specify the name of the mediation list handler as MyMediationList. Drag and drop the two mediations marked with the <<Mediation>> keyword into the second parameter.

Any class marked with the <<Mediation>> keyword can be added to the mediation list. Hence, you can implement your own mediation logic in the Java class that gets generated by the transform. Figure 12 shows the model after the three mediation patterns are applied.


Figure 12. Composing Mediations with patterns
Mediation Diagram

Run UML to EJB Transform to generate the Mediation EJBs

Now let's generate the code for the mediations into the FinanceEJB project. Invoke the UML to EJB Transform from the mediations package and select the FinanceEJB project. This generates a new package (mediations) that contains the MessageLoggerMediation and the XSLTMediation class. It also updates the Mediation handlers in the EJB deployment descriptor.


Add the mediation to the message queue

You need to add the mediation handler list MyMediationList to the FinanceQueue before the logging and transformation can happen. To add the mediation handler, simply update the topology diagram in Figure 5 by creating an association to the <<Mediation>> MyMediationList, as shown in Figure 13.

Now run the UML to JACL transform again to generate a new JACL script. Notice that a new section is added to create the mediation and to mediate the queue. Run those sections in the JACL to update the Application Server 6.0 configuration.


Figure 13. Adding mediation to the FinanceQueue
Mediation and Queue Diagram

Configure JNDI name for the Logging database

Make sure you set up the JDBC providers for logging table. The JNDI name must match the one specified in the MessageLoggerMediation, and the LOGMESSAGE table must be created in the database. (See the readme file in the code download for more detailed instructions.)


Summary

In this article, you learned how the recently released Rational Software Architect WebSphere Platform Messaging Patterns can help you rapidly build an ESB application on WebSphere Application Server 6.0. You also discovered how to compose a larger J2EE application using these new WebSphere Platform Messaging patterns together with the previous Enterprise Patterns such as Message Façade, Business Delegate, and Session Façade. As more and more reusable patterns are captured in Rational Software Architect, more of the best practices can be automatically generated, reducing the development time and improving overall quality.



Download

DescriptionNameSizeDownload method
Finance sample built with WPMPatternsi-odoebp11code.zip1970KB HTTP

Information about download methods


Resources

Learn

Get products and technologies

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 next-generation technologies for the IBM On Demand Operating Environment.

Murray Beaton

Murray Beaton is an Advisory Software Developer for the On Demand Software Development team. Murray's previous role was Technical Team Lead with WebSphere Studio Application Developer.

James Abbott

James Abbott is an Advisory Software Developer for the On Demand Software Development team. His major focus is on patterns and transforms for model-driven development. During his career, he has worked on a series of model-based application development tools for IBM Rational Software and other companies.

Comments (Undergoing maintenance)



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, Architecture
ArticleID=91016
ArticleTitle=Architecting on demand solutions, Part 11: Build ESB connectivity with Rational Software Architecture (RSA) WebSphere Platform Messaging Patterns
publish-date=08022005
author1-email=clau@ca.ibm.com
author1-email-cc=clau@ca.ibm.com
author2-email=beatonm@ca.ibm.com
author2-email-cc=beatonm@ca.ibm.com
author3-email=jrabbott@us.ibm.com
author3-email-cc=jrabbott@us.ibm.com

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).