2 Replies Latest reply on Mar 12, 2010 11:34 AM by Jeff Mesnil

    XA & transacted in HornetQ RA

    Jeff Mesnil Master

      Hi,

       

      I have a test failure in the TCK related to Session.recover().

       

      The test fails with the stack trace:

       

      03-09-2010 09:36:59:  SVR-ERROR: javax.jms.IllegalStateException: Cannot recover a transacted session

        at org.hornetq.jms.client.HornetQSession.recover(HornetQSession.java:281)

        at org.hornetq.ra.HornetQRASession.recover(HornetQRASession.java:466)

       

       

      Looking at HornetQRASession.recover() code, there is a mismatch between the transacted value received
      from HornetQRAConnectionRequestInfo and the transacted state of the underlying HornetQSession.
      The HornetQRASession is not transacted whime the underlying HornetQSession is.
      After looking at the code, here is what I understand:
      - We create a HornetQRAConnectionRequestInfo cri object with transacted set to false in HornetQRASessionFactoryImpl.allocateConnection()
      - Right after that, we set the defaults on the cri object from the resource adapter properties; useXA will be set to true
      => we end up with cri attributes: transacted = false, useXA = true
      - later, in HornetQRAManagedConnection.setup(), we create the HornetQ JMS resources. Since useXA is true, the created HornetQSession
        will be set to XA *and* transacted!
      - finally, when the test calls, HornetQRASession.recover(), the check on cri.isTransacted() will return false, HornetQSession.recover() is called but the check in HornetQSession.recover() will throw a IllegalStateException since the session is transacted.
      Does that make sense?
      I am not sure how the RA should behave. I'll look at the spec, etc. but if you have any ideas, they're welcome
        • 1. Re: XA & transacted in HornetQ RA
          Andy Taylor Master

          +1, u are right.

           

          fyi useXA is whether we use an xa connection isTransacted is whether the session is enlisted with the tm via the endpoint

          • 2. Re: XA & transacted in HornetQ RA
            Jeff Mesnil Master

            ataylor wrote:

             

            +1, u are right.

             

            fyi useXA is whether we use an xa connection isTransacted is whether the session is enlisted with the tm via the endpoint

            I don't understand what you mean about isTransacted.

             

            In HornetQRAManagedConnection.setup(), both useXA and isTransacted are used to determine the type of session; either XA session or regular (transacted/non-transacted) JMS Session.

             

            My issue is that since the RA will default useXA to true, the RA will not create any regular JMS Sessions.

            I have test failing because of that. They use a non-transacted session and calls recover() which is not allowed on a XA session.

             

            Am I missing something obvious here? I am not that familiar with JCA but I don't understand how pieces fit together....

            Oh well, I'll read the spec this week-end. At worst, it'll help me caught up on lost sleep