|
So I have been given the mandate to ensure that certain actions are preformed whenever a transaction rolls back.
Problem: I don't seem to have a way to TELL when there has been a rollback.
So I have a middleware solution that deals with several transactional components. My application is left with the unpleasant task of ensuring that when there is an error, some transactions roll back, while some other transactions occur (like a message to a JMS error queue).
So I tried using a UserTransaction to give me insight into the overall transaction, BUT the UserTransaction is more or less useless since I can setRollbackOnly, or I can actually preform a rollback BUT what I can't do is tell if setRollBackOnly has been set (Which you can for DB connections or even JMS Sessions -- just not UserTransactions), or if any of the other transactions have rolled back.
SO to get arround this I have had to make another object called "RollBackState" (an AtomicBoolean) and try like hell to ensure that every conceivable error condition that may cause a rollback also sets this variable so that in the unlikely event of a rollback I can preform all the other actions that need to occur.
How does one implement a more robust transaction? Do I need to write my own Transaction Manager and register it with the Application Server like a JMS or DB resource?
|