Preparing Transactions For Commit
Before you commit the transactions, prepare the transactions for a two-phase commit. Use the preparemethod to prepare a transaction, or use the prepareAll method to prepare a given list of transactions. If prepare fails, those transactions can only be aborted. The prepared transactions can be recovered by calling recover. Calling prepare or prepareAll methods is optional. You can directly commit or abort transactions without preparing them.
. . .
// prepare transaction
try {
long i = bc.beginTransaction("tx3");
System.out.println("Transaction id : " +i);
BrokerEvent ev1 = new BrokerEvent(bc, eventtypename);
bc.publish(ev1);
bc.prepare("tx3");
} catch (BrokerException ex) {
System.out.println ("Error on prepare" +ex);
return;
}
} . . .