public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception {
// the transaction may have already been started.
if( xid.isXATransaction() ) {
Transaction transaction = (Transaction)xaTransactions.get(xid);
if( transaction != null )
return;
transaction = new XATransaction(transactionStore, (XATransactionId)xid, this);
xaTransactions.put(xid, transaction);
} else {
Map transactionMap = context.getTransactions();
Transaction transaction = (Transaction)transactionMap.get(xid);
if( transaction != null )
throw new JMSException("Transaction '"+xid+"' has already been started.");
transaction = new LocalTransaction(transactionStore, (LocalTransactionId)xid, context);
transactionMap.put(xid, transaction);