3 Replies Latest reply on Mar 20, 2006 7:01 AM by adrian.brock

    Converting work done in local jms transaction into xa transa

    timfox

      In the JBossMQ SpyXAResource, if start is called on the XAResource then any local work done in the session is "converted" into work done in the in the XA transaction, as if the work had actually been done after start had been called.

      I'm trying to understand why this is necessary, or indeed if it is legal.

      I'm guessing this might be something to do with message delivery to message listeners where we want the deliveried message to be in the context of the xa tx, but the user can't start work in the xa tx until the onMessage method is executed by which time it would be too late. Hence any work done is converted.

      Any ideas?

        • 1. Re: Converting work done in local jms transaction into xa tr

           

          "timfox" wrote:

          I'm guessing this might be something to do with message delivery to message listeners where we want the deliveried message to be in the context of the xa tx, but the user can't start work in the xa tx until the onMessage method is executed by which time it would be too late. Hence any work done is converted.


          Correct. It is for the ConnectionConsumer/ServerSessionPool.
          If it tried to start the JTA transaction first, the transaction would timeout
          waiting for a non-existant message.

          • 2. Re: Converting work done in local jms transaction into xa tr
            timfox

            Make sense.

            Also, if someone wasn't using ConnectonConsumer stuff, but was using an XAConnection to create an XASession directly, then consuming messages via a message listener in that session, they're also going to get this conversion behaviour:

            e.g

            
            public void onMessage(Message m)
            {
            
            
            //start causes delivery of the message to be converted into the tx
            xaResource.start(xid, XAResource.TMNOFLAGS);
            
            //do something
            
            xaResource.end(xid, XAResource.TMSUCCESS);
            xaResource.prepare(xid);
            xaResource.commit(xid, false);
            
            }
            
            


            I can't really see any problems in having this behaviour, but is it correct in this case?

            I guess if the spec is silent on this, it should be ok...

            • 3. Re: Converting work done in local jms transaction into xa tr

              I can't see any other way of making XA work with a message listener.
              Short of having a temporary message listener that doesn't receive
              for very long.