Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Transaction Semantics | Using Broker Transaction Clients | Beginning a Transaction
Beginning a Transaction
To begin a transaction, first instantiate a new BrokerTransactionalClient object, then call the transactional client's beginTransaction method.
A unique Broker transaction ID that is specific to this newly opened transaction will be generated and returned as part of the new transaction object. This ID is unique to the specific Broker.
Note that this method can be null or can have an external transaction ID.
//unique Broker transaction ID
long tid;
//Create Transactional Client:
try {
BrokerTransactionalClient pub =
(broker_host, broker_name,pubid, client_group_p, "TxTest-Pub", null);
} catch (BrokerException ex)
System.out.println ("Failed to create pub client\n" + ex);
// Start a transaction to publish events
try {
tid = pub.beginTransaction(null);
} catch (BrokerException ex) {
System.out.println ("Error on starting transaction " +ex);
. . .