6.3.1.2 Example: Sending Asynchronous Requests
The following example shows a series of asynchronous calls that
make up the total bank balance query. Because the banking
application data is distributed among several database sites, an
SQL query needs to be executed against each one. The application
performs these queries by selecting one branch identifier per
database site, and calling the ABAL
or
TBAL
service for each site. The branch identifier is
not used in the actual SQL query, but it enables the Oracle Tuxedo
system to route each request to the proper site. In the following
code, the for
loop invokes tpacall()
once
for each site.
Listing Sending Asynchronous Requests
audv->balance = 0.0;
(void)strcpy(audv->ermsg, "");
for (i=0; i<NSITE; i++) {
/* Prepare aud structure */
audv->b_id = sitelist[i]; /* routing done on this field */
/* Do tpacall */
if ((cd[i]=tpacall(sname, (char *)audv, sizeof(struct aud), 0))
== -1) {
(void)fprintf (stderr,
"%s: %s service request failed for site rep %ld\n",
pgmname, sname, sitelist[i]);
tpfree((char *)audv);
return(-1);
}
}
Parent topic: Sending an Asynchronous Request