[Top] [Prev] [Next] [Bottom]

1. Introduction and a Simple Application


About This Chapter

This chapter contains a tutorial that describes a simple one-client, one-server application called CSIMPAPP. An interactive form of this chapter is distributed with the BEA TUXEDO system software.

If you follow the ten steps of the tutorial you will:

Some Preliminaries

Before you can run this tutorial the BEA TUXEDO system software must be installed so that the files and commands referred to in this chapter are available.

If you are personally responsible for installing the BEA TUXEDO system software, consult the BEA TUXEDO Installation Guide for information about how to install the BEA TUXEDO system.

If the installation has already been done by someone else, you need to know the pathname of the root directory of the installed software. You also need to have read and execute permissions on the directories and files in the BEA TUXEDO system directory structure so you can copy CSIMPAPP files and execute BEA TUXEDO commands.

The CSIMPAPP Tutorial

CSIMPAPP is a very basic BEA TUXEDO system application. It has one client and one server. The server performs only one service; it accepts a string from the client and returns the same string in upper case.

The tutorial consists of ten steps (plus an eleventh step for shutdown) designed to introduce you to the BEA TUXEDO system by showing how an application is developed and by encouraging you to bring the application up and run it. Each of the steps includes one or more smaller steps.

Step 1: Copy the CSIMPAPP Files

  1. Make a directory for CSIMPAPP and cd to it:

    mkdir CSIMPDIR
    cd CSIMPDIR

    This is suggested so you will be able to see clearly the CSIMPAPP 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; not csh.

  2. Set and export environment variables

    TUXDIR=<pathname of the BEA TUXEDO System root directory>
    APPDIR=<pathname of your present working directory>
    TUXCONFIG=$APPDIR/TUXCONFIG
    COBDIR=<pathname of the COBOL compiler directory>
    COBCPY=$TUXDIR/cobinclude
    COBOPT="-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl"
    CFLAGS="-I$TUXDIR/include"
    PATH=$PATH:$TUXDIR/bin
    LD_LIBRARY_PATH=$COBDIR/coblib:${LD_LIBRARY_PATH}
    export TUXDIR APPDIR TUXCONFIG UBBCONFIG COBDIR COBCPY
    export COBOPT CFLAGS PATH LD_LIBRARY_PATH

    You need TUXDIR and PATH to be able to access files in the BEA TUXEDO system directory structure and to execute BEA TUXEDO system commands. On SunOS, /usr/5bin must be the first directory in your PATH. On AIX, LIBPATH must be set instead of LD_LIBRARY_PATH. On HPUX, SHLIB_PATH must be set instead of LD_LIBRARY_PATH. You need to set TUXCONFIG to be able to load the configuration file as shown in Step 7.

  3. Copy the CSIMPAPP files.

    cp $TUXDIR/apps/CSIMPAPP/* .

    Later on you will be editing some of the files and making them executable, so it is best to begin with a copy of the files rather than the originals delivered with the software.

  4. List the files.

    $ ls
    CSIMPCL.cbl
    CSIMPSRV.cbl
    README
    TPSVRINIT.cbl
    UBBCSIMPLE
    WUBBCSIMPLE
    envfile
    ws
    $

    The files that make up the application are:

Step 2: Examine the Client Program

Page through the client program source code:

$ more CSIMPCL.cbl

The output is shown in Listing 1-1.

Listing 1-1 Source code of CSIMPCL.cbl
1      IDENTIFICATION DIVISION.
2 PROGRAM-ID. CSIMPCL.
3 AUTHOR. TUXEDO DEVELOPMENT.
4 ENVIRONMENT DIVISION.
5 CONFIGURATION SECTION.
6 WORKING-STORAGE SECTION.
7 *****************************************************
8 * Tuxedo definitions
9 *****************************************************
10 01 TPTYPE-REC.
11 COPY TPTYPE.
12 *
13 01 TPSTATUS-REC.
14 COPY TPSTATUS.
15 *
16 01 TPSVCDEF-REC.
17 COPY TPSVCDEF.
18 *
19 01 TPINFDEF-REC VALUE LOW-VALUES.
20 COPY TPINFDEF.
21 *****************************************************
22 * Log messages definitions
23 *****************************************************
24 01 LOGMSG.
25 05 FILLER PIC X(8) VALUE "CSIMPCL:".
26 05 LOGMSG-TEXT PIC X(50).
27 01 LOGMSG-LEN PIC S9(9) COMP-5.
28 *
29 01 USER-DATA-REC PIC X(75).
30 01 SEND-STRING PIC X(100).
31 01 RECV-STRING PIC X(100).
32 *****************************************************
33 * Command line arguments
34 *****************************************************
35 LINKAGE SECTION.
36 01 CMD-LINE.
37 05 ARG-LENGTH PIC 9(4) COMP.
38 05 ARG.
39 10 ARGS PIC X OCCURS 0 TO 100 DEPENDING
40 ON ARG-LENGTH.
41 ******************************************************
42 * Start program with command line args
43 ******************************************************
44
45 PROCEDURE DIVISION USING CMD-LINE.
46 START-CSIMPCL.
47 MOVE LENGTH OF LOGMSG TO LOGMSG-LEN.
48 PERFORM CHECK-ARGS.
49 PERFORM DO-TPINIT.
50 MOVE ARG TO SEND-STRING.
51 PERFORM DO-TPCALL.
52 DISPLAY RECV-STRING.
53 PERFORM DO-TPTERM.
54 PERFORM EXIT-PROGRAM.
55
56 ******************************************************
57 * Check Arguments being passed
58 ******************************************************
59 CHECK-ARGS.
60 IF ARG-LENGTH = 0
61 DISPLAY "Usage: CSIMPCL string"
62 PERFORM EXIT-PROGRAM
63 END-IF.
64 IF ARG-LENGTH = 100
65 DISPLAY "Command Line Too Long"
66 PERFORM EXIT-PROGRAM
67 END-IF.
68
69 MOVE "Started" TO LOGMSG-TEXT.
70 PERFORM DO-USERLOG.
71
72 *****************************************************
73 * Now register the client with the system.
74 *****************************************************
75 DO-TPINIT.
76 MOVE SPACES TO USRNAME.
77 MOVE SPACES TO CLTNAME.
78 MOVE SPACES TO PASSWD.
79 MOVE SPACES TO GRPNAME.
80 MOVE ZERO TO DATALEN.
81 SET TPU-DIP TO TRUE.
82
83 CALL "TPINITIALIZE" USING TPINFDEF-REC
84 USER-DATA-REC
85 TPSTATUS-REC.
86
87 IF NOT TPOK
88 MOVE "TPINITIALIZE Failed" TO LOGMSG-TEXT
89 PERFORM DO-USERLOG
90 PERFORM EXIT-PROGRAM
91 END-IF.
92
93 *****************************************************
94 * Issue a TPCALL
95 *****************************************************
96 DO-TPCALL.
97 MOVE ARG-LENGTH TO LEN.
98 MOVE "STRING" TO REC-TYPE.
99 MOVE "CSIMPSRV" TO SERVICE-NAME.
100 SET TPBLOCK TO TRUE.
101 SET TPNOTRAN TO TRUE.
102 SET TPNOTIME TO TRUE.
103 SET TPSIGRSTRT TO TRUE.
104 SET TPCHANGE TO TRUE.
105
106 CALL "TPCALL" USING TPSVCDEF-REC
107 TPTYPE-REC
108 SEND-STRING
109 TPTYPE-REC
110 RECV-STRING
111 TPSTATUS-REC.
112
113 IF NOT TPOK
114 MOVE "TPCALL Failed" TO LOGMSG-TEXT
115

Here are the important things to see in this file:

lines 11, 14, 17, 20

COPY

Files needed whenever BEA TUXEDO ATMI calls are used

line 83

TPINITIALIZE

The ATMI call used by a client program to join an application.

line 106

TPCALL

Sends the message record to the service specified in SERVICE-NAME. TPCALL waits for a return message. STRING is one of the three basic BEA TUXEDO record types. The argument, LEN IN TPTYPE-REC, specifies the length of the record contained in USER-DATA-REC.

line 122

TPTERM

The ATMI call used to leave an application. A call to TPTERM is used to leave the application prior to performing a STOP RUN.

line 52

DISPLAY

This is the successful conclusion of the program. It prints out the message returned from the server.

References

The ATMI calls cited above are documented in the following pages in the BEA TUXEDO Reference Manual: TPINITIALIZE(3cbl), TPTERM(3cbl), TPCALL(3cbl), USERLOG(3cbl).

Step 3: Compile the Client

  1. Run buildclient to compile the client program:

    buildclient -C -o CSIMPCL -f CSIMPCL.cbl

    where the output file is CSIMPCL, and the input source file is CSIMPCL.cbl.

  2. Check the results:

    $ ls CSIMPCL*
    CSIMPCL CSIMPCL.cbl CSIMPCL.idy CSIMPCL.int CSIMPCL.o

    As can be seen, we now have an executable module called CSIMPCL.

References

buildclient is documented in buildclient(1) in the BEA TUXEDO Reference Manual.

Step 4: Examine the Server

  1. Page through the server program source code:

    $ pg CSIMPSRV.cbl

    Listing 1-2 Source code of CSIMPSRV.cbl
    1      IDENTIFICATION DIVISION.
    2 PROGRAM-ID. CSIMPSRV.
    3 AUTHOR. BEA TUXEDO DEVELOPMENT.
    4 ENVIRONMENT DIVISION.
    5 CONFIGURATION SECTION.
    6 WORKING-STORAGE SECTION.
    7 ******************************************************
    8 * Tuxedo definitions
    9 ******************************************************
    10 01 TPSVCRET-REC.
    11 COPY TPSVCRET.
    12 *
    13 01 TPTYPE-REC.
    14 COPY TPTYPE.
    15 *
    16 01 TPSTATUS-REC.
    17 COPY TPSTATUS.
    18 *
    19 01 TPSVCDEF-REC.
    20 COPY TPSVCDEF.
    21 ******************************************************
    22 * Log message definitions
    23 ******************************************************
    24 01 LOGMSG.
    25 05 FILLER PIC X(10) VALUE
    26 "CSIMPSRV :".
    27 05 LOGMSG-TEXT PIC X(50).
    28 01 LOGMSG-LEN PIC S9(9) COMP-5.
    29 ******************************************************
    31 * User defined data records
    32 ******************************************************
    33 01 RECV-STRING PIC X(100).
    34 01 SEND-STRING PIC X(100).
    35 *
    36 LINKAGE SECTION.
    37 *
    38 PROCEDURE DIVISION.
    39 *
    40 START-FUNDUPSR.
    41 MOVE LENGTH OF LOGMSG TO LOGMSG-LEN.
    42 MOVE "Started" TO LOGMSG-TEXT.
    43 PERFORM DO-USERLOG.
    44
    45 ******************************************************
    46 * Get the data that was sent by the client
    47 ******************************************************
    48 MOVE LENGTH OF RECV-STRING TO LEN.
    49 CALL "TPSVCSTART" USING TPSVCDEF-REC
    50 TPTYPE-REC
    51 RECV-STRING
    52 TPSTATUS-REC.
    53
    54 IF NOT TPOK
    55 MOVE "TPSVCSTART Failed" TO LOGMSG-TEXT
    56 PERFORM DO-USERLOG
    57 PERFORM EXIT-PROGRAM
    58 END-IF.
    59
    60 IF TPTRUNCATE
    61 MOVE "Data was truncated" TO LOGMSG-TEXT
    62 PERFORM DO-USERLOG
    63 PERFORM EXIT-PROGRAM
    64 END-IF.
    65
    66 INSPECT RECV-STRING CONVERTING
    67 "abcdefghijklmnopqrstuvwxyz" TO
    68 "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
    69 MOVE "Success" TO LOGMSG-TEXT.
    70 PERFORM DO-USERLOG.
    71 SET TPSUCCESS TO TRUE.
    72 COPY TPRETURN REPLACING
    73 DATA-REC BY RECV-STRING.
    74
    75 ******************************************************
    76 * Write out a log err messages
    77 ******************************************************
    78 DO-USERLOG.
    79 CALL "USERLOG" USING LOGMSG
    80 LOGMSG-LEN
    81 TPSTATUS-REC.
    82 ******************************************************
    83 * EXIT PROGRAM
    84 ******************************************************
    85 EXIT-PROGRAM.
    86 MOVE "Failed" TO LOGMSG-TEXT.
    87 PERFORM DO-USERLOG.
    88 SET TPFAIL TO TRUE.
    89 COPY TPRETURN REPLACING
    90 DATA-REC BY RECV-STRING.

    Here are the important things to see in this file:

    line 49

    TPSVCSTART

    This routine is used to receive the service's parameters and data. After a successful call, the RECV-STRING contains the data sent by the client.

    lines 66-68

    INSPECT statement

    Converts the input to uppercase.

    line 72

    COPY TPRETURN

    Returns the converted string to the client with TPSUCCESS set.

    line 79

    USERLOG

    This routine logs messages that are used by the BEA TUXEDO system and applications.

  2. Page through the server program source code:

    $ pg TPSVRINIT.cbl

    Listing 1-3 Source code of TPSVRINIT.cbl
    1   IDENTIFICATION DIVISION.
    2 PROGRAM-ID. TPSVRINIT.
    3 ENVIRONMENT DIVISION.
    4 CONFIGURATION SECTION.
    5 *
    6 DATA DIVISION.
    7 WORKING-STORAGE SECTION.
    8 *
    9 01 LOGMSG.
    10 05 FILLER PIC X(11) VALUE "TPSVRINIT :".
    11 05 LOGMSG-TEXT PIC X(50).
    12 01 LOGMSG-LEN PIC S9(9) COMP-5.
    13 *
    14 01 TPSTATUS-REC.
    15 COPY TPSTATUS.
    16 *********************************************************
    17 LINKAGE SECTION.
    18 01 CMD-LINE.
    19 05 ARGC PIC 9(4) COMP-5.
    20 05 ARG.
    21 10 ARGS PIC X OCCURS 0 TO 9999 DEPENDING ON ARGC.
    22 *
    23 01 SERVER-INIT-STATUS.
    24 COPY TPSTATUS.
    25 ***********************************************************
    26 PROCEDURE DIVISION USING CMD-LINE SERVER-INIT-STATUS.
    27 A-000.
    28 MOVE LENGTH OF LOGMSG TO LOGMSG-LEN.
    29 ***********************************************************
    30 * There are no command line parameters in this TPSVRINIT
    31 ***********************************************************
    32 IF ARG NOT EQUAL TO SPACES
    33 MOVE "TPSVRINIT failed" TO LOGMSG-TEXT
    34 CALL "USERLOG" USING LOGMSG
    35 LOGMSG-LEN
    36 TPSTATUS-REC
    37 ELSE
    38 MOVE "Welcome to the simple service" TO LOGMSG-TEXT
    39 CALL "USERLOG" USING LOGMSG
    40 LOGMSG-LEN
    41 TPSTATUS-REC
    42 END-IF.
    43 *
    44 SET TPOK IN SERVER-INIT-STATUS TO TRUE.
    45 *
    46 EXIT PROGRAM.

This subroutine is called during server initialization, before the server begins processing service requests. A default is provided by the BEA TUXEDO system that writes a message to USERLOG indicating that the server has been booted.

References

The ATMI calls and structure cited above are documented in the following pages in the BEA TUXEDO Reference Manual: TPSVCSTART(3cbl), TPSVRINIT(3cbl), TPRETURN(3cbl), USERLOG(3cbl).

Step 5: Build the Server

  1. Run buildserver to compile the server program:

    buildserver -C -o CSIMPSRV -f CSIMPSRV.cbl -f TPSVRINIT.cbl -s CSIMPSRV

    where the executable file to be created is named CSIMPSRV, and CSIMPSRV.cbl and TPSVRINIT.cbl are the input source files.

  2. Check the results:

    $ ls
    CSIMPCL CSIMPCL.int CSIMPSRV.cbl CSIMPSRV.o TPSVRINIT.int
    CSIMPCL.cbl CSIMPCL.o CSIMPSRV.idy TPSVRINIT.cbl TPSVRINIT.o
    CSIMPCL.idy CSIMPSRV CSIMPSRV.int TPSVRINIT.idy UBBCSIMPLE

    As can be seen, we now have an executable module called CSIMPSRV.

References

buildserver is documented in buildserver(1) in the BEA TUXEDO Reference Manual.

Step 6: Edit the Configuration File

  1. Edit the file:

    Listing 1-4 The CSIMPAPP configuration file
    #Skeleton UBBCONFIG file for the BEA TUXEDO COBOL Simple Application.
    #Replace the <bracketed> items with the appropriate values.
    *RESOURCES
    IPCKEY <Replace with a valid IPC Key>
    #Example:
    #IPCKEY 123456
    MASTER             simple
    MAXACCESSERS 5
    MAXSERVERS 5
    MAXSERVICES 10
    MODEL SHM
    LDBAL N
    *MACHINES
    DEFAULT:
    APPDIR="<Replace with the current pathname>"
    TUXCONFIG="<Replace with TUXCONFIG Pathname>"
    TUXDIR="<Root directory of BEA TUXEDO (not /)>"
    ENVFILE="<pathname of file of environment vars>"
    #Example:
    # APPDIR="/home/me/simpapp"
    # TUXCONFIG="/home/me/simpapp/TUXCONFIG"
    # TUXDIR="/usr/tuxedo"
    <Machine-name>     LMID=simple
    #Example:
    #usltux LMID=simple
    *GROUPS
    GROUP1
    LMID=simple GRPNO=1 OPENINFO=NONE
    *SERVERS
    DEFAULT:
    CLOPT="-A"
    CSIMPSRV           SRVGRP=GROUP1   SRVID=1
    *SERVICES
    CSIMPSRV

  2. Change values enclosed in angle brackets to your own local values:

    IPCKEY

    Use a value that will not conflict with any other users.

    TUXCONFIG

    Provide the full pathname of the binary tuxconfig file to be created in Step 7.

    TUXDIR

    Provide the full pathname of your BEA TUXEDO system root directory.

    APPDIR

    Provide the full pathname of the directory where you intend to boot the application; in this case, the current directory.

    ENVFILE

    Provide the full pathname for the environment file to be used by mc, viewc, tmloadcf, and so on.

    machine-name

    Provide the machine name as returned by uname -n.

  3. The pathnames for TUXCONFIG and TUXDIR must be identical to those you set and exported in Step 1 in "Step 1: Copy the CSIMPAPP Files." The strings must be the actual values; environment variables (such as $TUXCONFIG) are not acceptable. Do not forget to remove the angle brackets.

References

The configuration file is documented in ubbconfig(5) in the BEA TUXEDO Reference Manual.

Step 7: Load the Configuration File

  1. Run tmloadcf to load the configuration file:

    $ tmloadcf UBBCSIMPLE
    Initialize TUXCONFIG file: /usr/me/CSIMPDIR/TUXCONFIG [y, q] ? y
    $

  2. Check the results:

    $ ls
    CSIMPCL CSIMPCL.o CSIMPSRV.int TPSVRINIT.int
    CSIMPCL.cbl CSIMPSRV CSIMPSRV.o TPSVRINIT.o
    CSIMPCL.idy CSIMPSRV.cbl TPSVRINIT.cbl TUXCONFIG
    CSIMPCL.int CSIMPSRV.idy TPSVRINIT.idy UBBCSIMPLE

    We see that we now have a file called TUXCONFIG. The TUXCONFIG file is a new file system under the control of the BEA TUXEDO system.

References

tmloadcf is documented in tmloadcf(1) in the BEA TUXEDO Reference Manual.

Step 8: Boot the Application

Execute tmboot to bring up the application:

$ tmboot
Boot all admin and server processes? (y/n): y
Booting all admin and server processes in /usr/me/CSIMPDIR/TUXCONFIG
Booting all admin processes ...
exec BBL -A:
process id=24223 ... Started.
Booting server processes ...
exec CSIMPSRV -A :
process id=24257 ... Started.
2 processes started.
$

BBL is the administrative process that monitors the application shared memory structures. CSIMPSRV is our server that runs continuously awaiting requests.

References

tmboot is documented in tmboot(1) in the BEA TUXEDO Reference Manual.

Step 9: Enter a Request

Run the client program to submit a request:

$ CSIMPCL "hello world"
HELLO WORLD

We are successful!!!

Step 10: Using tmadmin

tmadmin is an interactive program that an administrator can use to check an application and make dynamic changes. It requires the TUXCONFIG variable to be set. We will show you just two of the many tmadmin commands.

  1. Enter the command:

    tmadmin

    You will see the following lines.

    tmadmin - Copyright (c) 1987 ATT; 1991 USL. All rights reserved.
    >

    The greater-than sign (>) is the tmadmin prompt.

  2. Enter the printserver(psr) command to display information about the servers:

    > psr
    a.out Name Queue Name Grp Name ID RqDone Load Done Current Service
    ---------- ---------- -------- -- ------ --------- ---------------
    BBL 531993 simple 0 0 0 (IDLE)
    CSIMPSRV 00001.00001 GROUP1 1 0 0 (IDLE)
    >

  3. Enter the printservice(psc) command to display information about the services:

    > psc
    Service Name Routine Name a.out Name Grp Name ID Machine # Done Status
    ------------ ------------ ---------- -------- -- ------- ---- -------
    ADJUNCTBB ADJUNCTBB BBL simple 0 simple - AVAIL
    ADJUNCTADMIN ADJUNCTADMIN BBL simple 0 simple - AVAIL
    CSIMPSRV CSIMPSRV CSIMPSRV GROUP1 1 simple - AVAIL
    >

  4. Leave tmadmin by entering a q at the prompt. You can boot and shut down the application from within tmadmin. We have done those functions with shell commands in Steps 8 and 11, respectively.

References

tmadmin is documented in tmadmin(1) in the BEA TUXEDO Reference Manual.

Step 11: Shut Down the Application

  1. Run tmshutdown to bring the application down:

    $ tmshutdown
    Shutdown all admin and server processes? (y/n): y
    Shutting down all admin and server processes in /usr/me/CSIMPDIR/TUXCONFIG
    Shutting down server processes ...
    Server Id = 1 Group Id = GROUP1 Machine = simple:  shutdown succeeded.
    Shutting down admin processes ...
    Server Id = 0 Group Id = simple Machine = simple:  shutdown succeeded.
    2 processes stopped.
    $

  2. Check the ULOG:

    $ cat ULOG*
    $
    140533.usltux!BBL.22964: LIBTUX_CAT:262: std main starting
    140540.usltux!CSIMPSRV.22965: COBAPI_CAT:1067: INFO: std main starting
    140542.usltux!CSIMPSRV.22965: TPSVRINIT :Welcome to the simple service
    140610.usltux!?proc.22966: CSIMPCL:Started
    140614.usltux!CSIMPSRV.22965: CSIMPSRV :Started
    140614.usltux!CSIMPSRV.22965: CSIMPSRV :Success
    140614.usltux!?proc.22966: switch to new log file
    /home/usr_nm/CSIMPDIR/ULOG.112592
    140614.usltux!?proc.22966: CSIMPCL:Ended

    Each line of the ULOG for this session contains something of interest. First let's look at the format of a ULOG line:

    time (hhmmss).machine_uname!process_name.process_id: log message

    Now let's look at an individual line:

    140542. Message from TPSVRINIT in CSIMPSRV

References

tmshutdown is documented in tmshutdown(1) in the BEA TUXEDO Reference Manual.

The USERLOG is documented in USERLOG(3cbl).

Summary

If you have reached this point, you have successfully brought up, run and brought down a BEA TUXEDO system application. You have seen what a client program and a server look like. You have edited a configuration file to refer to your own environment. You have invoked tmadmin to check on the activity of your application. In all the applications you may work on in the future the basic elements of client processes, server processes and a configuration file will be present, and you will have all of the BEA TUXEDO shell commands at your fingertips.

Good luck!



[Top] [Prev] [Next] [Bottom]