Chapter 6 Integrating With WebLogic Server 9.2 : Modifying this Example to Use Container Managed Transactions and XA

Modifying this Example to Use Container Managed Transactions and XA
This section describes how to modify the above example to support container-managed transactions. In this modified example, TIBCO Enterprise Message Service server participates in a distributed transaction started by WebLogic server.
Create a JMS Connection Factory That Supports XA
To create the JMS Connection factory that supports XA, perform the following:
1.
Start the TIBCO Enterprise Message Service administration tool by selecting Start > Programs > TIBCO EMS 5.1 > Start EMS Administration Tool from the Windows Start menu.
2.
 
   > connect
   > create factory XATopicConnectionFactory xatopic
Modifying the MDB to Use Transactions
To modify the example MDB to use transactions, you must update the ForeignJmsProvider and MessageDriven annotation tags in the MessageTraderBean.java file, which is located in:
C:\bea\weblogic92\samples\server\examples\src\examples\ejb\ejb20\message
Follow these steps to modify the example MDB:
1.
For the ForeignJmsProvider tag, make these changes:
a.
Change the providerUrl property to tibjmsnaming://localhost:7222.
b.
Change the connectionFactoryJndiName property to XATopicConnectionFactory.
2.
For the MessageDriven tag, make these changes:
a.
Change the defaultTransaction property to MessageDriven.DefaultTransaction.NOT_SUPPORTED.
b.
Change the transactionType property to MessageDriven.MessageDrivenTransactionType.BEAN.
After competing the modifications, the foreignJmsProvider and MessageDriven tags should look like this:
@ForeignJmsProvider(providerUrl="tibjmsnaming://localhost:7222",
       initialContextFactory="com.tibco.tibjms.naming.TibjmsInitialContextFactory",
       connectionFactoryJndiName="XATopicConnectionFactory")
 
@MessageDriven(maxBeansInFreePool = "200",
          destinationType = "javax.jms.Topic",
          initialBeansInFreePool = "20",
          transTimeoutSeconds = "0",
          defaultTransaction = MessageDriven.DefaultTransaction.REQUIRED,
          transactionType=MessageDriven.MessageDrivenTransactionType.CONTAINER,
          durable = Constants.Bool.FALSE,
          ejbName = "messageDriven",
          destinationJndiName = "TIBCO.quotes")
Modify the Example Client Program to Use Transactions
The modifications necessary for the example client program are similar to those that were necessary for MDB:
1.
In Client.java, change the string SSLTopicConnectionFactory to XATopicConnectionFactory.
2.
In Client.java, change the port number from 7243 to 7222 in the URL.
3.
In build.xml, change the port number from 7243 to 7222 for the URL.
Rebuilding and Redeploying the Example MDB
Restart the WebLogic Server Examples Server as described Rebuilding and Redeploying the Example MDB, so that it picks up the changes to the environment.
Running the Example MDB Client with Transactions
Create a new command prompt window and run the examples setup script, setExamplesEnv.cmd, so that the changes to the environment are picked up.
From the example MDB source directory, enter the command:
> ant run
You should see the same messages sent by the client and received by the MDB in the WebLogic server window.