5 Replies Latest reply on Sep 28, 2012 12:03 PM by kconner

    Commit in Actions

    mfluegge

      Hi everbody,

       

      first let me say that I am a Jboss newby, so please don't hit me if it turns out that the answer to my question is quite obvious

       

      I started working with an existing apllication that bases on Jboss ESB. I was asked to maintain an action that writes data to the database. With my humble Hibernate knolede I started the following approach:

       

      session = sessionFactory.getCurrentSession();

      session.beginTransaction();

       

      //modify data

       

      session.getTransaction().commit();

       

       

      While the Jboss is configured to use several threads (2 in my case) I was wondering that a second instance of the action could not read the data from the db, although a commit was already performed in the first thread. Debugging this I found out that the commit on the transaction does not write the data, but this is somehow postponed, thus saving my commits using locks did not work.

       

      Second, I tried to use the userTransaction which is bound to the context of the Jboss.

       

       

      UserTransaction tx = (UserTransaction) new InitialContext().lookup("UserTransaction");

       

       

      //modify data

       

      tx.commit();

       

       

      In this case to commit was performed immediatelly, but an exception was thrown which I could not really google down.

       

       

       

      18:10:04,480 ERROR [JmsServerSession] org.jboss.resource.adapter.jms.inflow.JmsServerSession@758c5f failed to commit/rollback

      java.lang.IllegalStateException: Wrong tx association: expected TransactionImple < ac, BasicAction: 7f000101:ac13:5061d60b:176e status: ActionStatus.COMMITTED > was null

      at org.jboss.resource.adapter.jms.inflow.JmsServerSession$XATransactionDemarcationStrategy.end(JmsServerSession.java:467)

      at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:248)

      at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)

      at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)

      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:761)

      at java.lang.Thread.run(Thread.java:662)

       

       

       

      Has anyone an idea why the commit in the first approach is postponed. May there is something wrong configured. Or is this completely wrong and I should always use the user transaction?

       

      I was browsing the net for hald a day and did not really find a solution. It would be great if someone has an idea or could point me to a documentation.

       

      We are using Jboss 4.x

       

       

      Thanks in advance

       

      Cheers,

       

      Martin

        • 1. Re: Commit in Actions
          tcunning

          Hi Martin,

           

          What version of Jboss Messaging are you using?

          • 2. Re: Commit in Actions
            mfluegge

            Hi Tom,

             

            thanks for your reply.

             

            We are using JBoss Messaging in version 1.4.0.SP3 and ESB  4.10 on JBoss 4.2.3 GA.

             

            Cheers,

             

            Martin

            • 3. Re: Commit in Actions
              tcunning

              I'd try upgrading the JBoss Messaging version.     I think you should be able to install 1.4.5 or 1.4.6 - it might be worth posting the stack and asking over on the jboss messaging forum what version you should use with AS 4.2.3.GA and whether this is something they've seen.

              • 4. Re: Commit in Actions
                mfluegge

                Hi Tom,

                 

                ok, I'll try to update to a newer version. Thanks for your help

                 

                Cheers,

                 

                Martin

                • 5. Re: Commit in Actions
                  kconner

                  One issue that you will have is that the pipeline has a transaction encompassing the delivery of the message.  The stacktrace shows that you are using JCA inflow and that the resource adapter has wrapped the execution within a transaction.

                   

                  This will explain both of the scenarios you are seeing, updates deferred until the end of the transaction and the conflict when you terminate the transaction early.