/**
  * @throws IOException
  * @see org.apache.activemq.store.TransactionStore#prepare(TransactionId)
  */
 public void prepare(TransactionId txid) throws IOException {
   KahaTransactionInfo info = getTransactionInfo(txid);
   if (txid.isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions() == false) {
     theStore.store(new KahaPrepareCommand().setTransactionInfo(info), true, null, null);
   } else {
     Tx tx = inflightTransactions.remove(txid);
     if (tx != null) {
       theStore.store(new KahaPrepareCommand().setTransactionInfo(info), true, null, null);
     }
   }
 }
  public void commit(
      TransactionId txid, boolean wasPrepared, Runnable preCommit, Runnable postCommit)
      throws IOException {
    if (txid != null) {
      if (!txid.isXATransaction() && theStore.isConcurrentStoreAndDispatchTransactions()) {
        if (preCommit != null) {
          preCommit.run();
        }
        Tx tx = inflightTransactions.remove(txid);
        if (tx != null) {
          List<Future<Object>> results = tx.commit();
          boolean doneSomething = false;
          for (Future<Object> result : results) {
            try {
              result.get();
            } catch (InterruptedException e) {
              theStore.brokerService.handleIOException(new IOException(e.getMessage()));
            } catch (ExecutionException e) {
              theStore.brokerService.handleIOException(new IOException(e.getMessage()));
            } catch (CancellationException e) {
            }
            if (!result.isCancelled()) {
              doneSomething = true;
            }
          }
          if (postCommit != null) {
            postCommit.run();
          }
          if (doneSomething) {
            KahaTransactionInfo info = getTransactionInfo(txid);
            theStore.store(new KahaCommitCommand().setTransactionInfo(info), true, null, null);
          }
        } else {
          // The Tx will be null for failed over clients - lets run their post commits
          if (postCommit != null) {
            postCommit.run();
          }
        }

      } else {
        KahaTransactionInfo info = getTransactionInfo(txid);
        theStore.store(
            new KahaCommitCommand().setTransactionInfo(info), true, preCommit, postCommit);
        forgetRecoveredAcks(txid);
      }
    } else {
      LOG.error("Null transaction passed on commit");
    }
  }
 /**
  * @throws IOException
  * @see org.apache.activemq.store.TransactionStore#rollback(TransactionId)
  */
 public void rollback(TransactionId txid) throws IOException {
   if (txid.isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions() == false) {
     KahaTransactionInfo info = getTransactionInfo(txid);
     theStore.store(new KahaRollbackCommand().setTransactionInfo(info), false, null, null);
     forgetRecoveredAcks(txid);
   } else {
     inflightTransactions.remove(txid);
   }
 }