change abstract transaction

This commit is contained in:
leon.li 2016-08-31 12:09:24 +08:00
parent f30595a269
commit 9fc68e8dbe

View file

@ -71,21 +71,30 @@ public abstract class AbstractTransactionProcessor implements TransactionProcess
protected void runTransaction(Transaction transaction) throws Exception { protected void runTransaction(Transaction transaction) throws Exception {
try { try {
m_currentTransaction.set(transaction); startTransaction(transaction);
transaction.setStatus(Transaction.Status.RUNNNG);
m_transactionManager.saveTransaction(transaction);
transaction.setStatus(doTransaction(transaction)); transaction.setStatus(doTransaction(transaction));
} catch (Exception ex) { } catch (Exception ex) {
transaction.setStatus(Transaction.Status.FAILED); transaction.setStatus(Transaction.Status.FAILED);
throw ex; throw ex;
} finally {
endTransaction(transaction);
}
}
private void startTransaction(Transaction transaction) throws IOException {
m_currentTransaction.set(transaction);
transaction.setStatus(Transaction.Status.RUNNNG);
m_transactionManager.saveTransaction(transaction);
}
private void endTransaction(Transaction transaction) {
try {
m_transactionManager.saveTransaction(transaction);
} catch (IOException e) {
m_logger.error("[save transaction error]" + transaction.getTransactionID());
} finally { } finally {
m_currentTransaction.set(null); m_currentTransaction.set(null);
try {
m_transactionManager.saveTransaction(transaction);
} catch (IOException e) {
m_logger.error("[save transaction error]" + transaction.getTransactionID());
}
} }
} }