Contents

Using Fiorano XA with the Oc4j Transaction Manager is explained in this section with the help of an example. In this example, a session bean is used with oc4j transaction manager and the oracle 9i application server. The bean client invokes the transact() method of the bean being executed in the oc4j application server.

The work done in this distributed transaction includes:

  • Messages are pushed on a Queue residing on the FioranoMQ server.
  • Messages are inserted into a table in the Cloudscape database.
  • The tasks above are performed in the same distributed transaction.
  • The transaction manager manages the transaction and ensures that both the processes are completed successfully.
  • Clicking the link and unzipping the file TestBean.zip. This zip file contains all the class files of the samples discussed in this guide.

To run the above bean sample with the Orion application server, follow the instructions given below:

For more information on how to configure FioranoMQ with the cloudscape database, please refer to Chapter 6: Configuring Message Store.

  1. Install the oracle application server:
  2. Install JDeveloper or the oc4j Application server.
  3. Configure the Cloudscape database. Configure the orion application server
  4. Replace server.xml in %JDEVELOPER%\j2ee\home\config directory with %UNZIP_DIR%\server.xml. If the server.xml file has applications deployed, add the tag:

5. Copy the cloudscape libraries, cloudscape.jar and cloudview40.jar in %JDEVELOPER%\j2ee\home\lib directory.

6. Copy classes12.zip in %JDEVELOPER%\j2ee\home\lib and %JDEVELOPER%\j2ee\home directory.

7. Add the files <Fiorano_install_dir>\fmq\lib\client\all fmq-client.jar to the oc4j.jar file, found in %JDEVELOPER%\j2ee\home directory.

On a Windows platform, this is usually equivalent to \Program Files\Fiorano\FMQ. Here the JDEVELOPER variable represents the base directory of the Orion Application server.

8. Extract the Bean Sample. Unzip the file fmq.zip, found in %UNZIP_DIR% where the file TestBean.zip in the /demo directory of OC4J_HOME directory is to be unzipped as well. This creates a folder fmq in /demo dir.

9. Deploy the Bean Sample. Restart OC4J using java -jar oc4j.jar. OC4J deploys the new application called FioranoMQ Samples and the bean TestJmsXa with it. The following output is observed if the bean is deployed successfully:

Auto-deploying FMQ samples (Assembly had been updated)...Auto-deploying test (Class 'TestJmsXaRemote' had been updated)... done. 

10. Run the Bean Sample. Run the EJB client using run-client TestJmsXaClient. (This client can be found in jdeveloper\j2ee\home\demo\fmq\test.) Ensure that theoc4j.jar, jass.jar and ejb.jar files are in the classpath before running the client.

Examine the details of the bean as well as its client to see how the distributed transaction involving the transaction manager work.

  1. Lookup of the Home Interface and invoking methods of EJB.

The reference to the home interface of the deployed bean can be accessed through the JNDI lookup calls. The lookup of the bean returns the home interface of the deployed bean. A remote interface is created from the home interface.

The various methods of the bean can be invoked through its remote interface. The transact method, which performs all the steps required for running the distributed transaction in the test bean, can be invoked using:

2. Transaction Reference

In implementating the transact method, reference to the transaction object can be obtained through the bean context. This transaction object is used to define the transaction boundaries.


3. Enlisting a Transaction

Resources should be enlisted within the transaction to inform the transaction about their participation. Reference to the resources can be acquired through the application server or directly from the resource provider. Please check the section To run as Standalone Application to obtain the XA resource from the resource provider.


4. Begin Transaction

Begin the transaction after enlisting the participating resources. All the work done after starting the transaction is associated with the transaction. One example of such work could be publishing a message on a queue.


5. Delisting Transaction

After performing the task in the transaction, the resources should be removed from the transaction. Delisting the resources informs the transaction that any work performed after delisting should not be made part of the transaction.

The parameter, XAResource.SUCCESS indicates that the transaction has ended successfully. If an exception occurs while a task is being performed, the application can remove the resource with XAResource.FAIL.

6. Committing Transaction

Committing a transaction commits the work performed by all the participating resources. The transaction is committed by a two-phase commit protocol:

Adaptavist ThemeBuilder EngineAtlassian Confluence