2 Replies Latest reply on Apr 6, 2017 12:37 PM by mmusgrov

    Narayana Commit Order

    greenbean

      We are looking to replace our current XA transaction manager.  However, the use of our current transaction manager that manages both JMS queues and database transactions requires the JMS message commit to occur last so data will be visible in the database when the message is consumed and processed.  Does Narayana support ordering commit of the XA resources, or having JMS commit last?

        • 1. Re: Narayana Commit Order
          tomjenkinson

          Narayana itself does support commit ordering. Simple ordering to put one of the XAR as the first to be processed can be done if the XAResource implements the interface jboss-transaction-spi/FirstResource.java at master · jbosstm/jboss-transaction-spi · GitHub  for example.


          jhalliday wrote an excellent article on this a few years back: Narayana team blog: Messaging/Database race conditions

          1 of 1 people found this helpful
          • 2. Re: Narayana Commit Order
            mmusgrov

            Tom's answer is the definitive one but just to add more detail:

             

            1. A non portable solution is to take advantage of a quirk of our implementation in which normal two phase aware resources are prepared/committed in the same order that they were enlisted (so enlist the database resource first). There would also be a risk if we change or make our implementation configurable.
            2. And an unsafe solution would be to make the database resource one-phase aware only and then take advantage of our Last Resource Commit Optimization (LRCO) which will commit it during the prepare phase. If it fails to commit the JMS resource will be told to abort. I say this approach is risky because LRCO is not transactionally safe. Note also that we do have a safe version of LRCO. called CMR, but it can only be used in more restrictive scenarios.