Wednesday, April 30, 2014

WebSphere ESB 6.2 SIB as Message Provider for WebLogic 12c Message Driven Bean (MDB) using SIB Resource Adapter with XA transaction support

In my previous post I described how to setup your environments to achieve Distributed (XA) Transaction support for JMS through the use of SIB Resource Adapter. It was specifically for WebSphere ESB 7.5 and WebLogic 12c. 

I have been busy today to achieve the same between WebSphere ESB 6.2 and WebLogic 12c. To my surprise if you deploy the Resource Adapter from WebSphere ESB 7.5 on WebLogic 12c and configure your MDB to connect to the WebSphere ESB 6.2 destination, it works and that too with XA support.

Monday, April 28, 2014

WebSphere SIB as Message Provider for WebLogic Message Driven Bean (MDB) using SIB Resource Adapter with XA transaction support

One of my customers wanted to subscribe to a topic on our WebSphere Application Server 7.0 SIB (Service Integration Bus). The customer wanted to use a Message Driven Bean (MDB - Message Driven Bean - EJB 3.0) deployed on Weblogic application server 12c as a message endpoint for the Topic on WAS SIB.

Client could have configured Foreign Server through WebLogic Console using SIB JMS client jar(s), but client wanted message guarantee with no loss. For this purpose MDB was configured to run as container managed bean. Resources from SIB must participate in a global (XA) transaction to support this requirement. 

As the SIB Resource Adapter (SIB RA) conforms JCA 1.5, we suggested to deploy the SIB RA on WebLogic and subscribe to the topic on WebSphere using Activation Specification. But due to lack of clear documentation client did not manage to achieve this. 

I decided to document how this can be achieved for people who might be in the same situation.

Following are the high level steps to configure and run a message driven bean on WebLogic server to which the WebSphere SIB resource adapter will dispatch messages from a message provider running on WebSphere Application Server Service Integration Bus (SIB)
  1. Create Topic to which client want to subscribe on WebSphere SIB. 
  2. Install SIB RA on WebLogic Application Server
  3. Develop MDB
  4. Create ejb-jar.xml
  5. Create weblogic-ejb-jar.xml
  6. Install MDB on WebLogic Application Server
  7. Validate if the subscription is created
As you have the overview of the steps required to achieve above mentioned setup, let's dig into the details.

  1. Create the Topic to which MDB wants to subscribe on WebSphere SIB
    • Note: You may skip this step, if you already have created the Topic
    • Create TopicSpace (eg: MyTopicSpace) from Service Integration => Buses > <Your Bus Name> => Destinations with default settings
    • Create the topic (eg: MyTopic) from Resources => JMS => Topics at appropriate scope in the default messaging provider and by using MyTopicSpace as the topic space of this topic
    • Select "Persistent" for the JMS delivery mode for MyTopicSpace

  2. Install SIB RA on WebLogic Application Server

    • Copy the SIB Resource Adapter (sibc.jmsra.rar) from WebSphere (<WAS_INSTALL>/runtimes directory) to WebLogic.
    • Install the SIB RA on WebLogic Application Server.
    • Make sure to give a JNDI Name (eg: jms/websphere_ra) to the SIB RA so that the MDB can bind with it in the later steps.
    • See the figure below for example. 
  3. Develop MDB
    • In the MDB class do not specify any elements for the annotation "@MessageDriven" and it should implement "javax.jms.MessageListener"
    • No need to specify configurations for "mappedName" or "activationConfig" as they will be configured using ejb-jar.xml
    • See the figure below for example
    • While caching any exception, set the message driven context for rollback.
    • See the figure below for example
  4. Create ejb-jar.xml
    • ejb-jar.xml is used to specify various settings during deployment of the MDB
    • "messaging-type" is configured as "javax.jms.MessageListener"
    • "transaction-type" is configured as "Container" for container managed MDB. Refer the link for details.
    • Various activation config properties are configured such as durableSubscriptionHome, targetType (= "ME" for XA support), targetSignificance (= "Required" for XA support), target (= <Name of the messaging engine hosting the Topic>), topicSpace (= <Name of the TopicSpace>), clientId (= <any string as client identifier>), subscriptionName (= <any string as subscription name), subscriptionDurability (= durable), destination (= <name of the Topic>), destinationType (= javax.jms.Topic), providerEndpoints (<hostname of websphere application server:<SIB_ENDPOINT_ADDRESS port>:BootstrapBasicMessaging), busName (= bus name)
    • "trans-attribute" for method "onMessage" is set as "Required" for container-managed transaction. Refer the link for details.
    • Sample ejb-jar.xml
  5. Create weblogic-ejb-jar.xml
    • Through this file one can bind MDB with the SIB RA
    • Binding is done using the element "resource-adapter-jndi-name"
    • Specify the JNDI name of the SIB RA as configured in step 2
    • Sample weblogic-ejb-jar.xml
  6. Install MDB on WebLogic Application Server
    • Install the EAR containing the MDB developed above
    • Start the application
  7. Validate if the subscription is created
    • After completing above steps, durable subscription should be created on SIB. 
    • To validate the subscription go to WebSphere admin console => Service Integration => Buses > <Your Bus Name> => Destinations => <Topic Space> => Publication points => <publication point> => Runtime => Subscriptions => <created Subscrition>

Above steps should help you configure and run a message driven bean on WebLogic server to which the WebSphere SIB resource adapter will dispatch messages from a message provider running on WebSphere Application Server Service Integration Bus (SIB). 

If an exception occurs, transaction will be rolled back and the message will be redelivered  upto maximum of "Maximum failed deliveries per message" retries which is one of the configuration of a topic space.  If all the retries result into rollback, message will be moved to exception destination of the topic.