Skip Navigation Links | |
Exit Print View | |
Oracle GlassFish Server Message Queue 4.5 Developer's Guide for C Clients |
Message Queue for the C Developer
Building and Running C Clients
Header Files and Shared Libraries
Working With the Sample C-Client Programs
Building the Basic C-Client Sample Programs
To Compile and Link on Solaris OS
To Compile and Link on Windows
Running the Basic C-Client Sample Programs
Distributed Transaction Sample Programs
To Set Up Tuxedo as a Distributed Transaction Manager
Client Application Deployment Considerations
This section describes the sample C-Client programs that are installed with Message Queue and explains how you should build them and run them.
Message Queue provides two sets of sample C-client programs: basic C-client programs and distributed transaction programs.
The sample C-client program files include the following:
Table 1-2 Basic C-Client Sample Program Files
|
These sample programs are located in IMQ_HOME/examples/C.
The following commands illustrate the process of building and linking the sample application Producer.c on the Solaris, Linux, AIX, and Windows platforms. The commands include the pre-processor definitions needed to support Message Queue C-API fixed-size integer types. For options used to support multithreading, please consult documentation for your compiler.
CC -compat=5 -mt -DSOLARIS -Iheader_path -o Producer \\ -Lruntime_path -lmqcrt Producer.c
where header_path and runtime_path are the paths to the Message Queue header file and runtime shared library appropriate to your processor architecture, as listed in Header Files and Shared Libraries.
For 64-bit support on either the SPARC or x86 processor architecture, you must also specify the -xarch compiler option:
SPARC: -xarch=v9
x86: -xarch=amd64
For example, to compile and link the example application Solaris SPARC 64–bit, you would use the following command:
CC -compat=5 -mt -xarch=v9 -DSOLARIS -I$IMQ_HOME/include -o Producer \\ -L$IMQ_HOME/lib/sparcv9 -lmqcrt Producer.c
g++ -DLINUX -D_REENTRANT -I$IMQ_HOME/include -o Producer \\ -L$IMQ_HOME/lib -lmqcrt Producer.c
xlC_r -qthreaded -DAIX -I$IMQ_HOME/include -o Producer \\ -blibsuff:so -l$IMQ_HOME/lib -imqcrt Producer.c
cl /c /MD -DWIN32 -I%IMQ_HOME%\include Producer.c link Producer.obj /NODEFAULTLIB msvcrt.lib \\ /LIBPATH:%IMQ_HOME%\lib mqcrt.lib
Before you run any sample programs, you should start the broker. You can display output describing the command-line options for each program by starting the program with the -help option.
For example, the following command, runs the program Producer. It specifies that the program should connect to the broker running on the host MyHost and port 8585, and that it should send a message to the destination My Topic :
Producer -h MyHost -p 8585 -d MyTopic
The directories that contain the sample programs also include a README file that explains how you should run their respective samples.
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: http://download.oracle.com/tuxedo/tux100/index.html.)
The distributed transaction sample programs include the following files:
Table 1-3 Distributed Transaction Sample Program Files
|
These sample programs are located in IMQ_HOME/examples/C/tuxedo.
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.
See Tuxedo documentation for instructions.
|
# SUN_MQ:sun_mq_xa_switch:-lmqcrt
# buildtms -o $TUXDIR/bin/<exe-name> -r SUN_MQ
# tmloadcf config-file
where config-file is the Tuxedo UBBCONFIG file.
# 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
# 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
# imqbrokerd -tty
# tmboot
# jmsclient_sender
# jmsclient_receiver
# imqcmd list dst -u admin
# imqcmd querry dst -t q -n xatestqueue -u admin