4 Replies Latest reply on Jun 7, 2005 5:10 AM by muthukumaran_m

    XA Transactions

    muthukumaran_m

      Actually I developed a sample application that uses XA transaction. In the sample a session bean first publishes two messages to a topic using XAConnectionFactory, latter it updates the DB using a entity bean. The entity bean also looks-up the connection from the XA datasource.

      To test my sample application, I tried to throw exception in between publishing the message and the DB update. So now according to the XA transaction, both the things should fail. Now the application is working fine if I deploy the session bean as bean managed transaction (i.e with transaction-type to Bean).

      But the same sample application is not working when I deploy the session bean as container managed transaction (i.e with transaction-type to container)

      By working fine I mean to say that the message published does not reach the destination, once the exception is thrown.

      Can any one please help me in the regard.

      Also it will be greatfull if any one can point me to a working example using XA Transaction.

      Thank you

        • 1. Re: XA Transactions
          schrouf

          Do you call <session bean context>.setRollbackOnly() within your sample session bean in case of an Exception ? Make sure you do so, because there is not automatic transaction rollback by the container itself.

          Regards
          Ulf

          • 2. Re: XA Transactions
            muthukumaran_m

            ThanX a lot man. The thing really is working. Actually I am very much clear regarding XA Transaction, but regarding it's implementation in JBoss i am not that much sure. I got documents and bit of codes from various places and developed the sample that i was talking about. If can help me out in finding a clean document that explains the concept of XA transaction with respect to JBoss.

            • 3. Re: XA Transactions
              schrouf

              There is no XA transaction concept with respect to JBoss :-) XA in general simply uses a 2-Phase-Commit (2PC) protocol for multi-resource all or nothing transactions.

              A central transaction manager (in jboss case a simple in-JVM transaction manager) first issues a prepare call on all affected resources (databases, JMS resource) enlisted in that transaction. Whitin the prepare call all resources try to do most of the internal - possibly failing - work for a transaction e.g. data writing to disk, but simply not 'activating' these changes yet.

              If all resources can successfully prepare the transaction, the transaction manager issues the actual commit command to all resources in a second commit call to all resource.

              If only one resource cannot prepare the transaction, the transaction manager issuess a rollback command to all already prepared resources.

              That's it.

              Regards
              Ulf

              • 4. Re: XA Transactions
                muthukumaran_m

                ThanX.... that was a neat explanation. But, still as an experienced guy if u can suggest some good docs & samples?. that will be great. Not specifically to XA, but J2EE on Jboss as a whole, with practical approach.