![]() |
![]() |
|
|
Examining the bankapp Clients
What Is the bankclt.c File
The bankclt file contains the client program that requests BEA Tuxedo services from the bankapp application. This client program is text-based and provides the following options:
Each of these options, except Exit Application, calls a subroutine that performs the following tasks:
Services Called by Function
1The number in parentheses is the FML occurrence number for that field.
The do_tpcall() function (that begins on line 447 in bankclt.c ) follows:
do_tpcall() in bankclt.c
/*
* This function does the tpcall to Tuxedo.
*/
static int
do_tpcall(char *service)
{
long len;
char *server_status;
/* Begin a Global transaction */
if (tpbegin(30, 0) == -1) {
(void)fprintf(stderr, "ERROR: tpbegin failed (%s)\n",
tpstrerror(tperrno));
return(-1);
}
/* Request the service with the user data */
if (tpcall(service, (char *)fbfr, 0, (char **)&fbfr, &len,
0) == -1) {
if(tperrno== TPESVCFAIL && fbfr != NULL &&
(server_status=Ffind(fbfr,STATLIN,0,0)) != 0) {
/* Server returned failure */
(void)fprintf(stderr, "%s returns failure
(%s)\n",
service,server_status);
}
else {
(void)fprintf(stderr,
"ERROR: %s failed (%s)\n", service,
tpstrerror(tperrno));
}
/* Abort the transaction */
(void) tpabort(0);
return(-1);
}
/* Commit the transaction */
if(tpcommit(0) < 0) {
(void)fprintf(stderr, "ERROR: tpcommit failed
(%s)\n",
tpstrerror(tperrno));
return(-1);
}
return(0);
}
The do_tpcall() function performs the following tasks:
Note: The unsolfcn() function is invoked if there is an unsolicited message to the client. It only supports STRING buffer types and prints the message.
bankapp uses the BEA Tuxedo program ud(1), which allows fielded buffers to be read from standard input and sent to a service. In the sample application, ud is used by both the populate and driver programs:
A Request/Response Client: audit.c
audit is a request/response client program that makes branch-wide or bank-wide balance inquiries, using the services: ABAL, TBAL, ABAL_BID, and TBAL_BID. You can invoke it in two ways:
The source code for audit contains two major parts: main() and a subroutine called sum_bal(). BEA Tuxedo ATMI functions are used in both parts. The program uses a VIEW typed buffer and a structure that is defined in the aud.h header file. The source code for the structure can be found in the view description file, aud.v.
The following pseudo-code shows the algorithm for the program.
audit Pseudo-code
main()
{
Parse command-line options with getopt();
Join application with tpinit();
Begin global transaction with tpbegin();
If (branch_ID specified) {
Allocate buffer for service requests with tpalloc();
Place branch_ID into the aud structure;
Do tpcall() to "ABAL_BID" or "TBAL_BID";
Print balance for branch_ID;
Free buffer with tpfree();
}
else /* branch_ID not specified */
call subroutine sum_bal();
Commit global transaction with tpcommit();
Leave application with tpterm();
}
sum_bal()
}
Allocate buffer for service requests with tpalloc();
For (each of several representative branch_ID's,
one for each site)
Do tpacall() to "ABAL" or "TBAL";
For (each representative branch_ID) {
Do tpgetrply() wtith TPGETANY flag set
to retrieve replies;
Add balance to total;
Print total balance;
}
Free buffer with tpfree();
}
Following is a summary of the two main parts of the audit source code.
In the programs main():
In the subroutine sum_bal:
A Conversational Client: auditcon.c
auditcon is a conversational version of the audit program. The source code for auditcon uses the ATMI functions for conversational communication: tpconnect() to establish the connection between the client and service, tpsend() to send a message, and tprecv() to receive a message.
The following pseudo-code shows the algorithm for the program.
auditcon Pseudo-code
main()
{
Join the application
Begin a transaction
Open a connection to conversational service AUDITC
Do until user says to quit: {
Query user for input
Send service request
Receive response
Print response on user's terminal
Prompt for further input
}
Commit transaction
Leave the application
}
A Client that Monitors Events: bankmgr.c
bankmgr is included with bankapp as an example of a client that is designed to run constantly. It subscribes to application-defined events of special interest, such as the opening of a new account or a withdrawal above $10,000. (The bankmgr.c client is more fully described in the README2 file of bankapp and in the bankmgr.c code itself.)
See Also
![]() |
![]() |
![]() |
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|