simpapp is a sample ATMI application that includes one client and one server. This application is distributed with the Oracle Tuxedo software. The server performs only one service: it accepts a lowercase alphabetic string from the client and returns the same string in uppercase.This topic is a tutorial that leads you, step-by-step, through the process of developing and running a sample Oracle Tuxedo ATMI application. Figure 2‑1 summarizes the process. Click on each task for instructions on completing that task.Figure 2‑1 simpapp Development ProcessBefore you can run this tutorial, the Oracle Tuxedo ATMI client and server software must be installed so that the files and commands referred to are available. If the installation has already been done by someone else, you need to know the pathname of the directory in which the software is installed (TUXDIR). You also need to have read and write permissions on the directories and files in the Oracle Tuxedo directory structure so you can copy simpapp files and execute Oracle Tuxedo commands.The instructions for the simpapp tutorial are based on a UNIX system platform. While specific platform instructions for the UNIX operating system environment remain largely the same, instructions for performing tasks (such as copying simpapp files or setting environment variables) on non-UNIX platforms (such as Windows 2003) may be different. For this reason, the examples used in the tutorial may or may not provide reliable procedures for your platform.After you complete this tutorial, you will be able to understand the tasks ATMI clients and servers can perform, edit a configuration file for your own environment, and invoke tmadmin to check on the activity of your application. You will understand the basic elements of all Oracle Tuxedo applications—client processes, server processes, and a configuration file—and you will know how to use Oracle Tuxedo system commands to manage your application.
1.
Note: This step is suggested so you can see the simpapp files you have at the start and the additional files you create along the way. Use the standard shell (/bin/sh) or the Korn shell; do not use csh.TUXDIR=pathname of the Oracle Tuxedo system root directory
TUXCONFIG=pathname of your present working directory/tuxconfig
PATH=$PATH:$TUXDIR/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TUXDIR/lib
export TUXDIR TUXCONFIG PATH LD_LIBRARY_PATHYou need TUXDIR and PATH to be able to access files in the Oracle Tuxedo system directory structure and to execute Oracle Tuxedo system commands. On Sun Solaris, /usr/5bin must be the first directory in your PATH. With AIX on the RS/6000, use LIBPATH instead of LD_LIBRARY_PATH. On HP-UX on the HP 9000, use SHLIB_PATH instead of LD_LIBRARY_PATH.You need to set TUXCONFIG to be able to load the configuration file, described in “Step 4: Editing and Loading the Configuration File” on page 2‑10.
3. Copy the simpapp files:
Note: Except for the README files, the other files are variations of simp*.* and ubb* files for non-UNIX system platforms. The README files provide explanations of the other files.
• simpcl.c—the source code for the client program.
• simpserv.c—the source code for the server program.
• ubbsimple—the text form of the configuration file for the application.Listing 2‑1 Source Code of simpcl.c
The ATMI function used to allocate a typed buffer. STRING is one of the five basic Oracle Tuxedo buffer types; NULL indicates there is no subtype argument. The remaining argument, sendlen + 1, specifies the length of the buffer plus 1 for the null character that ends the string. Sends the message buffer to the TOUPPER service specified in the first argument. Also includes the address of the return buffer. tpcall() waits for a return message. The ATMI function used to exit an application. A call to tpterm() is used to exit the application before exiting in response to an error condition (lines 36, 42, and 53). The final call to tpterm() (line 60) is issued after the message has been printed.
1. Run buildclient to compile the ATMI client program:
• buildclient(1) in Oracle Tuxedo Command ReferenceListing 2‑2 Source Code of simpserv.c/* #ident "@(#) apps/simpapp/simpserv.c $Revision: 1.1 $" */
1 #include <stdio.h>
2 #include <ctype.h>
3 #include <atmi.h> /* TUXEDO Header File */
4 #include <userlog.h> /* TUXEDO Header File */
5 /* tpsvrinit is executed when a server is booted, before it begins
processing requests. It is not necessary to have this function.
Also available is tpsvrdone (not used in this example), which is
called at server shutdown time.9 */
10 #if defined(__STDC__) || defined(__cplusplus)
12 tpsvrinit(int argc, char *argv[])
13 #else
14 tpsvrinit(argc, argv)
15 int argc;
16 char **argv;
17 #endif
18 {
19 /* Some compilers warn if argc and argv aren't used.
20 */
21 argc = argc;
22 argv = argv;
23 /* userlog writes to the central TUXEDO message log */
24 userlog("Welcome to the simple server");
25 return(0);
26 }
27 /* This function performs the actual service requested by the client.
Its argument is a structure containing, among other things, a pointer
to the data buffer, and the length of the data buffer.
30 */
31 #ifdef __cplusplus
32 extern "C"
33 #endif
34 void
35 #if defined(__STDC__) || defined(__cplusplus)
36 TOUPPER(TPSVCINFO *rqst)
37 #else
38 TOUPPER(rqst)
39 TPSVCINFO *rqst;
40 #endif
41 {
42 int i;
43
44 for(i = 0; i < rqst->len-1; i++)
45 rqst->data[i] = toupper(rqst->data[i]);
46 /* Return the transformed buffer to the requestor. */
47 tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
48 }
An Oracle Tuxedo server does not contain a main(). The main() is provided by the Oracle Tuxedo system when the server is built. This subroutine is called during server initialization, that is, before the server begins processing service requests. A default subroutine (provided by the Oracle Tuxedo system) writes a message to USERLOG indicating that the server has been booted. userlog(3c) is a log used by the Oracle Tuxedo system and can be used by applications. The declaration of a service (the only one offered by simpserv). The sole argument expected by the service is a pointer to a TPSVCINFO structure, which contains the data string to be converted to uppercase. Returns the converted string to the client with the TPSUCCESS flag set.
1. Run buildserver to compile the ATMI server program:The executable file to be created is named simpserv and simpserv.c is the input source file. The -s TOUPPER option specifies the service to be advertised when the server is booted.You now have an executable module called simpserv.
• buildserver(1) in Oracle Tuxedo Command Reference
1. Listing 2‑3 The simpapp Configuration File1$
2
3 #Skeleton UBBCONFIG file for the BEA Tuxedo Simple Application.
4 #Replace the <bracketed> items with the appropriate values.
5 RESOURCES
6 IPCKEY <Replace with valid IPC Key greater than 32,768>
7
8 #Example:
9
10 #IPCKEY 62345
11
12 MASTER simple
13 MAXACCESSERS 5
14 MAXSERVERS 5
15 MAXSERVICES 10
16 MODEL SHM
17 LDBAL N
18
19 *MACHINES
20
21 DEFAULT:
22
23 APPDIR="<Replace with the current pathname>"
24 TUXCONFIG="<Replace with TUXCONFIG Pathname>"
25 UXDIR="<Root directory of Tuxedo (not /)>"
26 #Example:
27 # APPDIR="/usr/me/simpdir"
28 # TUXCONFIG="/usr/me/simpdir/tuxconfig"
29 # TUXDIR="/usr/tuxedo"
30
31 <Machine-name> LMID=simple
32 #Example:
33 #tuxmach LMID=simple
34 *GROUPS
35 GROUP1
36 LMID=simple GRPNO=1 OPENINFO=NONE
37
38 *SERVERS
39 DEFAULT:
40 CLOPT="-A"
41 simpserv SRVGRP=GROUP1 SRVID=1
42 *SERVICES
43 TOUPPER
2. For each <string> (that is, for each string shown between angle brackets), substitute an appropriate value.
1. Run tmloadcf to load the configuration file:You now have a file called TUXCONFIG. The TUXCONFIG file is a new file under the control of the Oracle Tuxedo system.
• tmloadcf(1) in the Oracle Tuxedo Command Reference
• UBBCONFIG(5) in the File Formats, Data Descriptions, MIBs, and System Processes Reference
1. Execute tmboot to bring up the application:The BBL is the administrative process that monitors the shared memory structures in the application. simpserv is the simpapp server that runs continuously, awaiting requests.
• tmboot(1) in the Oracle Tuxedo Command Reference
• To execute your simpapp, have the client submit a request.As the administrator, you can use the tmadmin command interpreter to check an application and make dynamic changes. To run tmadmin, you must have the TUXCONFIG environment variable set.tmadmin can interpret and run over 50 commands. For a complete list, see tmadmin(1). The following uses two of the tmadmin commands.
Note: The greater-than sign (>) is the tmadmin prompt.
2. Enter the printserver(psr) command to display information about servers:
3. Enter the printservice(psc) command to display information about the services:
• tmadmin(1) in the Oracle Tuxedo Command Reference
1. Run tmshutdown to bring down the application:
2. Check the ULOG:
• tmshutdown(1) in the Oracle Tuxedo Command Reference
• userlog(3c) in the Oracle Tuxedo ATMI C Function Reference
•
•