how EJB3 CMT should handle different tx status flags
smarlow May 24, 2013 11:55 AMRelated to the how app thread should clear tx with status STATUS_ROLLEDBACK discussion, I would like feedback on a proposed EJB3 (CMT) container patch that handles ending the transaction differently for each tx status. This is in the EJB3 CMTTxInterceptor.endTransaction() that handles ending the tx that a CMT bean is using. Can you recommend how we should handle each different transaction status (if different then described):
Status.STATUS_ACTIVE - we still call tm.commit() as we did before the proposed patch.
Status.STATUS_MARKED_ROLLBACK - we still call tm.rollback() as we did before the proposed patch.
Status.STATUS_ROLLEDBACK - instead of calling tm.commit(), we now call tm.suspend to clear the tx from the thread.
Status.STATUS_NO_TRANSACTION - instead of calling tm.commit(), we now call tm.suspend to clear the tx from the thread. Previously, we called tm.commit() which would of generated a failure. I think that clearing the "no_transaction" tx from the thread is right but I'm not sure if seeing the status, could mean an invalid state. If this could mean an invalid state, then throwing an exception might be better then what I did (changed to not throw an exception).
Status.STATUS_COMMITTED - instead of calling tm.commit(), we now call tm.suspend to clear the tx from the thread. Previously, we called tm.commit() which would of generated a failure. This sounds like an invalid state to find the tx in (might also want to throw an exception for this case).
Status.STATUS_PREPARED - we now call tm.rollback() instead of tm.commit(). This sounds like an invalid state to find the tx in (might also want to throw an exception for this case).
Status.STATUS_PREPARING - we now call tm.rollback() instead of tm.commit(). This sounds like an invalid state to find the tx in (might also want to throw an exception for this case).
Status.STATUS_ROLLING_BACK - we now call tm.rollback() instead of tm.commit(). This sounds like an invalid state to find the tx in (might also want to throw an exception for this case).
Status.STATUS_UNKNOWN - we now call tm.rollback() instead of tm.commit().
Thanks,
Scott