![]() |
![]() |
e-docs > Tuxedo > Tutorials for Developing Tuxedo ATMI Applications > Tutorial for STOCKAPP, a Full COBOL Application |
Tutorials for Developing Tuxedo ATMI Applications
|
Tutorial for STOCKAPP, a Full COBOL Application
This topic includes the following sections:
What Is STOCKAPP?
STOCKAPP is a sample ATMI stocks application that is provided with the BEA Tuxedo system software. The application performs the following stock brokering functions: validates and updates a customer's account information, and executes buy and sell orders for stocks and/or funds.
This documentation leads you, step-by-step, through the procedure you must perform to develop the STOCKAPP application. Once you have "developed" STOCKAPP through this tutorial, you will be ready to start developing applications of your own.
The STOCKAPP tutorial is presented in three sections:
Note: This information is focused on system users with some experience in application development, administration, or programming. We assume some familiarity with the BEA Tuxedo system software. A development license is required to build BEA Tuxedo applications.
Familiarizing Yourself with STOCKAPP
This documentation provides a tour of the files, client, and services that make up the STOCKAPP application. Click on any of the following activities for more information about that part of the tour.
Learning About the STOCKAPP Files
The files that make up the STOCKAPP application are delivered in a directory called STOCKAPP, which is positioned as follows:
Exploring the Stock Application Files The STOCKAPP directory contains the following files:
The following table lists the files that make up STOCKAPP. The table lists the source files delivered with the BEA Tuxedo system software, files that are generated when the stock application is built, and a summary of the contents of each file.
See Also
Examining the STOCKAPP Clients
In the ATMI client-server architecture of the BEA Tuxedo system, there are two modes of communication:
System Client Programs
The following figure shows the hierarchy for STOCKAPP. The user selects one of the four service requests. The oval shapes in the illustration represent application services.
Figure 5-1 STOCKAPP Requests
Typed Buffers Typed buffers are an essential part of the BEA Tuxedo system. In the BEA Tuxedo system, a typed buffer is designed to hold a specific data type. Six types are defined: VIEW, STRING, CARRAY, X_OCTET, X_COMMON, and XML. Applications have the ability to define additional types. A Request/Response Client: BUY.cbl BUY is an example of a client program. It makes account inquiries that call on the service BUYSR. As an executable, it is invoked as follows: BUY.cbl Source Code Review the following sections of the BUY.cbl program. The indicated sections contain all of the places in BUY.cbl where the BEA Tuxedo ATMI functions are used. Similar to csimpl.cbl, BUY.cbl needs to call TPINITIALIZE to join the application; call TPCALL to make an RPC request to a service; and call TPTERM to leave an application. Note also that BUY.cbl is an example of a program that uses a VIEW typed record and a structure that is defined in the cust file. The source code for the structure can be found in the view description file, cust.V. Building Clients View description files, of which cust is an example, are processed by the view compiler, viewc(1). Run view(c) to compile the view: where viewc has three output files: a COBOL file (CUST.cbl), a binary view description file (cust.V), and a header file (cust.h). The client programs, BUY.cbl, FUNDPR.cbl, FUNDUP.cbl, and SELL.cbl, are processed by buildclient(1) to compile them and/or link edit them with the necessary BEA Tuxedo libraries. You can use any of these commands individually, if you choose, but rules for all these steps are included in STOCKAPP.mk. See Also
BUY
* Now register the client with the system
* Issue a TPCALL
* Clean upviewc-C-n
cust.v
Examining the STOCKAPP Servers
This topic provides the following information:
ATMI servers are executable processes that offer one or more services. In the BEA Tuxedo system, they continually accept requests (from processes acting as clients) and dispatch them to the appropriate services. Services are subroutines of COBOL language code written specifically for an application. It is the services accessing a resource manager that provide the functionality for which your BEA Tuxedo system transaction processing application is being developed. Service routines are one part of the application that must be written by the BEA Tuxedo system programmer (user-defined clients being another part).
All STOCKAPP services use functions provided in the Application-to-Transaction Monitor Interface (ATMI) for performing the following tasks:
STOCKAPP Services
There are four services in STOCKAPP. Each STOCKAPP service matches a COBOL function name in the source code of a server as shown in the following list:
Preparing STOCKAPP Files and Resources
This documentation leads you through the procedures you must complete to create the files and other resources you need to run STOCKAPP.
Click on each task for instructions on completing that task.
Step 1: How to Set Environment Variables
Environment variables required for STOCKAPP are defined in the STKVAR file. The file is large (approximately 100 lines) because it includes extensive comments.
TUXDIR: parameter null or not set
. ./STKVAR
Listing 5-1 STKVAR: Environment Variables for STOCKAPP
#ident "@(#)samples/atmi:STOCKAPP/STKVAR
#
# This file sets all the environment variables needed by the TUXEDO software
# to run the STOCKAPP
#
# This directory contains all the TUXEDO software
# System administrator must set this variable
#
TUXDIR=${TUXDIR:?}
#
# This directory contains all the user written code
#
# Contains the full path name of the directory that the application
# generator should place the files it creates
#
APPDIR=${HOME}/STOCKAPP
#
# Environment file to be used by tmloadcf
#
COBDIR=${COBDIR:?}
#
# This directory contains the cobol files needed
# for compiling and linking.
#
LD_LIBRARY_PATH=$COBDIR/coblib:${LD_LIBRARY_PATH}
#
# Add coblib to LD_LIBRARY_PATH
#
ENVFILE=${APPDIR}/ENVFILE
#
# List of field table files to be used by CBLVIEWC, tmloadcf, etc.
#
FIELDTBLS=fields,Usysflds
#
# List of directories to search to find field table files
#
FLDTBLDIR=${TUXDIR}/udataobj:${APPDIR}
#
# Set device for the transaction log; this should match the TLOGDEVICE
# parameter under this site's LMID in the *MACHINES section of the
# UBBCBSHM file
#
TLOGDEVICE=${APPDIR}/TLOG
#
# Device for the configuration file
#
UBBCBSHM=$APPDIR/UBBCBSHM
#
# Device for binary file that gives /T all its information
#
TUXCONFIG=${APPDIR}/TUXCONFIG
#
# Set the prefix of the file which is to contain the central user log;
# this should match the ULOGPFX parameter under this site's LMID in the
# *MACHINES section of the UBBCONFIG file
#
ULOGPFX=${APPDIR}/ULOG
#
# List of directories to search to find view files
#
VIEWDIR=${APPDIR}
#
# List of view files to be used by CBLVIEWC, tmloadcf, etc.
#
VIEWFILES=quote.V,cust.V
#
# Set the COBCPY
#
COBCPY=$TUXDIR/cobinclude
#
# Set the COBOPT
#
COBOPT="-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl"
#
# Set the CFLAGS
#
CFLAGS="-I$TUXDIR/include -I$TUXDIR/sysinclude"
#
# Export all variables just set
#
export TUXDIR APPDIR ENVFILE
export FIELDTBLS FLDTBLDIR TLOGDEVICE
export UBBCBSHM TUXCONFIG ULOGPFX LD_LIBRARY_PATH
export VIEWDIR VIEWFILES COBDIR COBCPY COBOPT CFLAGS
#
# Add TUXDIR/bin to PATH if not already there
#
a="\Qecho $PATH | grep ${TUXDIR}/bin\Q"
if [ x"$a" = x ]
then
PATH=${TUXDIR}/bin:${PATH}
export PATH
fi
#
# Add APPDIR to PATH if not already there
#
a="\Qecho $PATH | grep ${APPDIR}\Q"
if [ x"$a" = x ]
then
PATH=${PATH}:${APPDIR}
export PATH
fi
#
# Add COBDIR to PATH if not already there
#
a="\Qecho $PATH | grep ${COBDIR}\Q"
if [ x"$a" = x ]
then
PATH=${PATH}:${COBDIR}
export PATH
fi
Additional Requirements
PATH=/usr/5bin:$PATH;export PATH
Use /bin/sh rather than csh for your shell.
See Also
Step 2: Building Servers in STOCKAPP
buildserver is used to put together an executable ATMI server. Options identify the names of the output file, the input files provided by the application, and various libraries that permit you to run a BEA Tuxedo system application in a variety of ways.
buildserver with the -C option invokes the cobcc command. The environment variables ALTCC and ALTCFLAGS can be set to name an alternative compile command and to set flags for the compile and link edit phases. The key buildserver command-line options are illustrated in the examples that follow.
The buildserver command is used in STOCKAPP.mk to compile and build each server in the stock application. (Refer to buildserver(1) in the BEA Tuxedo Command Reference for complete details.)
How to Build the BUYSELL Server
The BUYSELL ATMI server is derived from files that contain the code for the BUYSR and SELLSR functions. The BUYSELL server is first compiled to a BUYSELL.o file before supplying it to the buildserver command so that any compile-time errors can be clearly identified and dealt with before this step.
buildserver -C -v -o BUYSELL -s SELLSR -f SELLSR.cbl -s BUYSR -f BUYSR.cbl
The explanation of the command-line options follows:
Servers Built in STOCKAPP.mk
The topics on creating the STOCKAPP servers are important to your understanding of how the buildserver command is specified. However, in actual practice you are apt to incorporate the build into a makefile; that is the way it is done in STOCKAPP.
See Also
Step 3: Editing the STOCKAPP.mk File
STOCKAPP includes a makefile that makes all scripts executable, converts the view description file to binary format, and does all the precompiles, compiles, and builds necessary to create the application servers. It can also be used to clean up when you want to make a fresh start.
As STOCKAPP.mk is delivered, there are a few fields you may want to edit, and some others that may benefit from some explanation.
How to Edit the TUXDIR Parameter
Go to the following comment in STOCKAPP.mk and to the TUXDIR parameter:
#
# Root directory of TUXEDO System. This file must either be edited to set
# this value correctly, or the correct value must be passed via "make -f
# STOCKAPP.mk TUXDIR=/correct/rootdir", or the build of STOCKAPP will fail.
#
TUXDIR=../..
You should set the TUXDIR parameter to the absolute pathname of the root directory of your BEA Tuxedo system installation.
How to Edit the APPDIR Parameter
You may want to give some thought to the setting of the APPDIR parameter. As STOCKAPP is delivered, APPDIR is set to the directory in which the STOCKAPP files are located, relative to TUXDIR. The following section of STOCKAPP.mk defines and describes the setting of APPDIR.
#
# Directory where the STOCKAPP application source and executables live.
# This file must either be edited to set this value correctly, or the
# correct value must be passed via "make -f STOCKAPP.mk
# APPDIR=/correct/appdir", or the build of STOCKAPP will fail.
#
APPDIR=$(TUXDIR)/samples/atmi/STOCKAPP
#
If you have copied the files to another directory, as suggested in the README file, you should set APPDIR to the name of the directory to which you copied the files. When you run the makefile, the application will be built in this directory.
How to Run the STOCKAPP.mk File
nohup make -f STOCKAPP.mk install &
See Also
Step 4: How to Edit the Configuration File
The STOCKAPP configuration file defines how an application runs on a set of machines. STOCKAPP is delivered with a configuration file in text format described in UBBCONFIG(5). UBBCBSHM, defines an application on a single computer.
Listing 5-2 UBBCBSHM Configuration File Fields to Be Replaced
#Copyright (c) 1992 Unix System Laboratories, Inc.
#All rights reserved
#Skeleton UBBCONFIG file for the TUXEDO COBOL Sample Application.
*RESOURCES
IPCKEY 5226164
DOMAINID STOCKAPP
001 UID <user id from id(1)>
002 GID <group id from id(1)>
MASTER SITE1
PERM 0660
MAXACCESSERS 20
MAXSERVERS 15
MAXSERVICES 30
MODEL SHM
LDBAL Y
MAXGTT 100
MAXBUFTYPE 16
MAXBUFSTYPE 32
SCANUNIT 10
SANITYSCAN 12
DBBLWAIT 6
BBLQUERY 180
BLOCKTIME 10
TAGENT "TAGENT"
#
*MACHINES
003 <SITE1's uname> LMID=SITE1
004 TUXDIR="<TUXDIR1>"
005 APPDIR="<APPDIR1>"
ENVFILE="<APPDIR1>/ENVFILE"
TUXCONFIG="<APPDIR1>/TUXCONFIG"
TUXOFFSET=0
006 TYPE="<machine type>"
ULOGPFX="<APPDIR>/ULOG"
MAXWSCLIENTS=5
#
*GROUPS
COBAPI LMID=SITE1 GRPNO=1
#
#
*SERVERS
FUNDUPSR SRVGRP=COBAPI SRVID=1 CONV=Y ENVFILE="<APPDIR1>/ENVFILE"
FUNDPRSR SRVGRP=COBAPI SRVID=2 ENVFILE="<APPDIR1>/ENVFILE"
BUYSELL SRVGRP=COBAPI SRVID=3 ENVFILE="<APPDIR1>/ENVFILE"
#
#
*SERVICES
SECURITY APP_PW
See Also
Step 5: Creating a Binary Configuration File
Before Creating the Binary Configuration File
Before creating the binary configuration file, you need to be in the directory in which your STOCKAPP files are located and you must set the environment variables. Complete the following tasks.
. ./STKVAR
How to Load the Configuration File
Once you have finished editing the configuration file, you must load it into a binary file on your MASTER machine. The name of the binary configuration file is TUXCONFIG; its path name is defined in the TUXCONFIG environment variable. The file should be created by a person with the effective user ID and group ID of the BEA Tuxedo system administrator, which should be the same as the UID and GID values in your configuration file. If this requirement is not met, you may have permission problems in running STOCKAPP.
tmloadcf UBBCBSHM
TUXCONFIG can be installed only on the MASTER machine; it is propagated to other machines by tmboot when the application is booted.
If you have specified SECURITY as an option for the configuration, tmloadcf prompts you to enter an application password. The password you select can be up to 30 characters long. Client processes joining the application are required to supply the password.
tmloadcf parses the text configuration file (UBBCONFIG) for syntax errors before it loads it, so if there are errors in the file, the job fails.
See Also
Running STOCKAPP
This documentation leads you through the procedures for booting STOCKAPP, testing it by running various client programs and transactions, and shutting it down when you have finished.
Click on each task for instructions on completing that task.
Step 1: How to Prepare to Boot
Listing 5-3 IPC Report
Ipc sizing (minimum /T values only)
Fixed Minimums Per Processor
SHMMIN: 1
SHMALL: 1
SEMMAP: SEMMNI
Variable Minimums Per Processor
SEMUME, A SHMMAX
SEMMNU, * *
Node SEMMNS SEMMSL SEMMSL SEMMNI MSGMNI MSGMAP SHMSEG
------ ------ ------ ------ ------ ------ ------ ------
machine 1 60 1 60 A + 1 10 20 76K
machine 2 63 5 63 A + 1 11 22 76K
where 1 <= A <= 8.
See Also
Step 2: How to Boot STOCKAPP
../STKVAR
tmboot
The following prompt is displayed:
Boot all admin and server processes? (y/n): y
When you enter y after the prompt, a running report, such as the following, is displayed on the screen:
Booting all admin and server processes in /usr/me/appdir/tuxconfig
Booting all admin processes
exec BBL -A:
process id=24223 Started.
The report continues until all servers in the configuration have been started. It ends by reporting the total number of servers started.
If you prefer, you can boot only a portion of the configuration. For example, to boot only administrative servers, include the -A option. If no options are specified, the entire application is booted.
In addition to reporting on the number of servers booted, tmboot also sends messages to the ULOG.
See Also
Step 3: How to Test STOCKAPP Services
../STKVAR
BUY
See Also
Step 4: How to Shut Down STOCKAPP
To bring down STOCKAPP, enter the tmshutdown(1) command with no arguments, from the MASTER machine, as follows.
tmshutdown
Running this command (or the shutdown command of tmadmin) causes the following results:
See Also
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |