Sun GlassFish Message Queue 4.4 Developer's Guide for C Clients

Distributed Transaction Sample Programs

The distributed transaction sample programs show how to use the X/Open distributed transaction (XA) support of the Message Queue C-API with an X/Open distributed transaction processing system (in this case BEA Tuxedo:

The distributed transaction sample programs include the following files:

Table 1–5 Distributed Transaction Sample Program Files

Sample Program 



Implements Tuxedo services that send and receive messages using the Message Queue C-API 


Tuxedo client that uses the message producing service in jmsserver.c


Tuxedo client that uses the message receiving service in jmsserver.c


Implements a Tuxedo service that asynchronously consumes messages using the Message Queue C-API 


Tuxedo client that uses the asynchronous message consuming service in async_jmsserver.c

Table 1–4 lists the location of the sample programs for each installation method.

Table 1–6 Location of Distributed Transaction Sample Programs

Installation Method 


IPS image 


Solaris SVR4 packages 


Linux rpm packages 


The following procedures document how to set up Tuxedo as a distributed transaction manager, how to build the sample distributed transaction programs, and how to run the sample programs. The procedures are based on the synchronous message consumption samples and assume a Solaris operating system platform.

ProcedureTo Set Up Tuxedo as a Distributed Transaction Manager

  1. Install Tuxedo.

    See Tuxedo documentation for instructions.

  2. Set up the following environment variables:

    Environment Variable 



    Modify to include Message Queue C-API runtime library path and TUXDIR/lib path


    Tuxedo install root 


    modify to include $TUXDIR/bin and compiler path


    TUXCONFIG filename path


    Tuxedo transaction log filename path 


    Message Queue install root 


    Message Queue C-API runtime log file name 


    Set so that Message Queue C-API runtime log file name will be auto-appended with the Tuxedo server process id 

  3. Build the Tuxedo transaction monitor server (TMS).

    1. Add the following entry to the $TUXDIR/udataobj/RM file:

      # SUN_MQ:sun_mq_xa_switch:-lmqcrt

    2. Build the TMS executable using buildtms:

      # buildtms -o $TUXDIR/bin/<exe-name> -r SUN_MQ

  4. Configure the Tuxedo servers.

    # tmloadcf config-file

    where config-file is the Tuxedo UBBCONFIG file.

ProcedureTo Build the Distributed Transaction Sample Programs

  1. Build the server side of the sample application (jmsserver.c).

    # cc -I$IMQ_HOME/include -I$TUXDIR/include -g -c jmsserver.c

    # buildserver -v -t -r SUN_MQ -s SENDMESSAGES,RECVMESSAGES -o jmsserver -f jmsserver.o -f -lmqcrt

  2. Build the client side of the sample application (jmsclient_sender.c and jmsclient_receiver.c).

    # cc -I$TUXDIR/include -c jmsclient_sender.c # buildclient -o jmsclient_sender -f jmsclient_sender.o

    # cc -I$TUXDIR/include -c jmsclient_receiver.c # buildclient -o jmsclient_receiver -f jmsclient_receiver.o

ProcedureTo Run the Distributed Transaction Sample Programs

  1. Start a Message Queue broker.

    # imqbrokerd -tty

  2. Start the Tuxedo servers.

    # tmboot

  3. Run the client-side applications.

    # jmsclient_sender

    # jmsclient_receiver

  4. Confirm the messages are produced to and consumed from the applicable destination.

    # imqcmd list dst -u admin

    # imqcmd querry dst -t q -n xatestqueue -u admin