} }

 Files   Prepare   Run   Troubleshooting   Related Topics 

 

About the Example

This example shows how to use JTA to perform distributed transactions using the two phase commit protocol across two XA resources: a JMS queue and a Pointbase database instance.

This example does the following:


 

Files Used in the Example

Directory Location:

MW_HOME/wlserver_10.3/samples/server/examples/jta/jmsjdbc/

(where MW_HOME is the directory containing your WebLogic Server installation)

File

Click source files to view code.

Description

application.xml The Java EE standard enterprise application deployment descriptor.
build.xml Ant build file that contains targets for building and running the example.
Client.java Class used to illustrate how to use JTA to perform distributed transactions
and two phase commit across two XA resources: JMS queue and
Pointbase database.
ReceiveInTxBean.java ReceiveInTxBean is a stateless session bean using bean-managed transaction. This EJBean illustrates distributed transactions and two phase commit across two XA resources: JMS queue and a Pointbase database. It begins a distributed transaction, receives messages from the JMS queue, updates the database, and then commits the distributed transaction.
weblogic-application.xml The WebLogic Server-specific enterprise application deployment descriptor.

 

Prepare the Example

 

Prerequisites

Before working with this example:

  1. Install WebLogic Server, including the examples.
  2. Start the Examples server.
  3. Set up your environment.

 

Configure WebLogic Server

  1. Bring up the Administration Console in your browser.
  2. Click to expand the Services > Messaging > JMS Modules in the left pane.
  3. Verify that the exampleQueue connection factory is deployed on the examplesServer as follows:
    1. Select the examples-jms node. The configuration information displays in one tab in the right pane.
    2. Select the Targets tab in the right pane and make sure that examplesServer is selected.
  4. Click the tree in the left pane to expand the Services -> JDBC nodes.
  5. Verify that the examples-demoXA JDBC Data Source is deployed on the examplesServer as follows:
    1. Select examples-demoXA by clicking on its entry in the right pane.
    2. Select the Targets tab in the right pane and make sure that examplesServer is selected.
    3. Select the Monitoring tab and make sure that the examples-demoXA is running on the examplesServer.

 

Build and Deploy the Example

  1. Set up your development shell as described in Setting up your environment.
  2. Change to the following directory: %SAMPLES_HOME%\server\examples\src\examples\jta\jmsjdbc, which contains an ant build script to build the example.
  3. Execute the following command:

    ant build

    This command compiles and stages the example.
  4. Execute the following command:

    ant deploy

    This command deploys the example on the wl_server domain of your WebLogic Server installation.
  5. This script builds the example and places the files in the correct locations:

    Running the build script builds the EJB in split development directory format where compiled and generated classes are placed in SAMPLES_HOME\server\examples\build\jtaJmsJdbcEar and non-compiled files remain within the source directory of the example. For more information on split development directory, see Developing WebLogic Server Applications.


 

Run the Example

  1. Complete the steps in the "Prepare the Example" section.
  2. Execute the following command from the shell where you set your environment:

      ant run

    This command runs the example.

  3. When prompted, enter messages into the client shell. After the last message, enter "quit".
  4. In the client shell, you should see something like the following:

    Enter message ("quit" to quit): hello
    JMS Message Sent: hello

    Enter message ("quit" to quit): bea
    JMS Message Sent: bea

    Enter message ("quit" to quit): quit
    JMS Message Sent: quit

    Data found in database:
    hello
    bea
  5. In the server shell, you should see something like the following:

    TRANSACTION BEGUN
    Message Received: hello
    Message Received: bea
    Message Received: quit
    TRANSACTION COMMITTED

 

Troubleshooting


 

Related Topics

(Internet connection required.)