Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client C API Programmer's Guide | Transaction Semantics | Using Transaction Processing | Beginning a Transaction
 
Beginning a Transaction
To begin a transaction, first instantiate a new BrokerTxClient object to create a transactional client. Then, use the awBeginTransaction function to begin the transaction. The following example illustrates the use of the awNewBrokerTxClient and awTxBeginTransaction functions to create and begin a transaction:
/* Create a transactional client */
err = awNewBrokerTxClient(broker_host,broker_name,"Client
1D","default","ClientTest1",NULL,&txclient);
if (!verifyNoError(__FILE__,"awNewBrokerTxClient",__LINE__,err)) {
return 0;
}
printf("Created broker transactional client.\n");
/* Start a transaction */
err = awTxBeginTransaction(txclient,"1",&unique_tx_id);
if (!verifyNoError(__FILE__,"awNewBrokerTxContext",__LINE__,err)) {
return 0;
}
printf("Unique transaction id in the broker:%d\n",unique_tx_id.low);
printf("Unique transaction id in the broker:%d\n",unique_tx_id.high);
A unique Broker ID will be generated and returned as part of the new transaction object. This unique transaction ID can be obtained by calling the awGetTxId function, as illustrated in the following example:
err = awGetTxId(txclient, &tx_id);
if (!verifyNoError(__FILE__,"awGetTxId",__LINE__,err)) {
return 0;
}
printf("Unique transaction id in the broker:%d\n",tx_id.low);
printf("Unique transaction id in the broker:%d\n",tx_id.high);