2 Replies Latest reply on Feb 14, 2008 11:35 AM by guidoscalise

    Listener for CMT commit/rollback

    koh

      I have a requirement where I need to know when a container managed transaction (or bean managed) commits the transaction. I was hoping there would be some kind of Interceptor of Listener system that I could hook into on the TransactionManager but there is nothing obvious that provides this. I've tried to use AOP but the jars in the lib folder do not appear to permit instrumentation.

      Any help is highly appreciated.

        • 1. Re: Listener for CMT commit/rollback
          guidoscalise

          If you only need some kind of callback to confirm transaction commitment, you could send a JMS Message (using a XA JMS Connector) to a topic subscribed by a Message Driven Bean.
          This will provide you an asynchronous callback, not coupled nor dependant on the original, commited transaction.

          Regards,
          Guido

          • 2. Re: Listener for CMT commit/rollback
            guidoscalise

            You can also enlist an object implementing XAResource in the running transaction using transactionManager.getTransaction().enlistResource(XAResource) then in the commit method you "do your magic".
            I think it's a risky alternative if you need to do any transactional/complex logic. In that case, the preferred method is the JMS/MDB one, as it ensures that the resulting action is triggered asynchronously and decoupled from the original transaction.
            It would be great to have some "enlightenment" on this issues from the JBossTM dev-team.

            Regards,
            Guido