log.info("TestSpecExampleOne::test_specexampleone");
long dlen = 0;
long clen = 0; /* contains a character array named input and an */
int cd; /* integer named output. */
/* allocate typed buffers */
X_C_TYPE dptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "dc_buf", 0);
X_C_TYPE cptr = (X_C_TYPE) connection.tpalloc("X_C_TYPE", "dc_buf", 0);
/* populate typed buffers with input data */
dptr.setByteArray("input", "debit account 123 by 50".getBytes());
cptr.setByteArray("input", "credit account 456 by 50".getBytes());
// TODO tx_begin(); /* start global transaction */
/* issue asynchronous request to DEBIT, while it is processing... */
cd = connection.tpacall(RunServer.getServiceNameDEBIT(), dptr,
Connection.TPSIGRSTRT);
/* ...issue synchronous request to CREDIT */
Response response = connection.tpcall(RunServer.getServiceNameCREDIT(),
cptr, Connection.TPSIGRSTRT);
cptr = (X_C_TYPE) response.getBuffer();
clen = response.getBuffer().getLen();
/* retrieve DEBIT�s reply */
response = connection.tpgetrply(cd, Connection.TPSIGRSTRT);
dptr = (X_C_TYPE) response.getBuffer();
dlen = response.getBuffer().getLen();
if (dptr.getInt("output") == OK && cptr.getInt("output") == OK) {
// TODO tx_commit(); /* commit global transaction */
} else {
// TODO tx_rollback(); /* rollback global transaction */
}
}