public BaseTransaction doPrepare(TransactionUID id, Integer xaFlags,
TransactionState ts, int pktType,
boolean onephasePrepare, TransactionWork txnWork) throws BrokerException {
BaseTransaction baseTransaction = null;
boolean persist = true;
if (Globals.isNewTxnLogEnabled()) {
// don't persist transaction state as we are logging it instead
persist=false;
if (txnWork == null) {
// prepare has been called directly from an end client
// We need to construct the transactional work
List plist = translist.retrieveSentMessages(id);
HashMap cmap = translist.retrieveConsumedMessages(id);
HashMap sToCmap = translist.retrieveStoredConsumerUIDs(id);
txnWork = getTransactionWork2(plist, cmap, sToCmap);
}
}
boolean prepared = false;
int s = ts.nextState(pktType, xaFlags);
try {
TransactionState nextState = new TransactionState(ts);
nextState.setState(s);
baseTransaction = doRemotePrepare(id, ts, nextState, txnWork);
if(baseTransaction==null)
{
// work not logged yet, so this must be a local broker transaction
// (there are no remote acknowledgements)
// The end client must have called prepare
if(Globals.isNewTxnLogEnabled())
{
baseTransaction= new LocalTransaction();
baseTransaction.setTransactionWork(txnWork);
baseTransaction.setTransactionState(nextState);
baseTransaction.getTransactionDetails().setTid(id);
baseTransaction.getTransactionDetails().setXid(ts.getXid());
baseTransaction.getTransactionDetails().setState(TransactionState.PREPARED);
logTxn(baseTransaction);
}
}
translist.updateState(id, s, onephasePrepare, persist);