mirror of
https://github.com/dianping/camel.git
synced 2024-11-10 09:13:26 +08:00
change abstract transaction
This commit is contained in:
parent
f30595a269
commit
9fc68e8dbe
1 changed files with 17 additions and 8 deletions
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue