6 Replies Latest reply on Dec 15, 2008 5:14 AM by mmusgrov

    transaction question

    mohitanchlia

      Jboss 4.2. I have a question about 2 phase commit: Here is the scenario:

      1. Our app starts a user transaction in a servlet
      2. In that transaction it accesses Stateless Bean that inserts something in DB. I think this leads to prorogation of transaction, if I am not wrong.
      3. After successful call to that bean it inserts a message in queue (remember everything is still in same transaction).

      So my question is, would both DB and JMS provider be part of same transaction and follow 2 phase commit protocol? So if DB fails or the route fails does it also ask for rollback from other resource? I am wondering how that works.

      Our DB is non-XA and JMS provider is XA. Jboss internally uses last resource gambit.

        • 1. Re: transaction question
          jhalliday

          > 2. In that transaction it accesses Stateless Bean that inserts something in DB. I think this leads to prorogation of transaction, if I am not wrong.

          It depends on the bean location and transaction attribute.

          > my question is, would both DB and JMS provider be part of same transaction and follow 2 phase commit protocol?

          Maybe.

          > So if DB fails or the route fails does it also ask for rollback from other resource? I am wondering how that works.

          Get a good book on transactions. Or read the JBossTS documentation.

          > Our DB is non-XA and JMS provider is XA. Jboss internally uses last resource gambit.

          Get a real database too.

          • 2. Re: transaction question
            mohitanchlia

             

            "jhalliday" wrote:
            > 2. In that transaction it accesses Stateless Bean that inserts something in DB. I think this leads to prorogation of transaction, if I am not wrong.

            It depends on the bean location and transaction attribute.

            > my question is, would both DB and JMS provider be part of same transaction and follow 2 phase commit protocol?

            Maybe.

            > So if DB fails or the route fails does it also ask for rollback from other resource? I am wondering how that works.

            Get a good book on transactions. Or read the JBossTS documentation.

            > Our DB is non-XA and JMS provider is XA. Jboss internally uses last resource gambit.

            Get a real database too.


            Thanks for such a helpful response. My questions were specifically surrounding around user transactions in servlet. I've looked at JbossTS doc but that doesn't clearly tell me about what happens when user transaction in a servlet accesses bean that updates DB in the same transaction.

            BTW: We use oracle but have found issues with XA implementation of Oracle.

            • 3. Re: transaction question
              mohitanchlia

              So I came accross http://www.jboss.org/community/docs/DOC-10503 which tells me that transaction is propogated accross Transaction Manager. Based on what I read here is my understanding, please correct me if I am wrong.

              1. Servlet start JTA User transaction in Jboss 4.2, say box A. This involves DB resource and JMS resource.
              2. Servlet then invokes remote Stateless Bean that also runs in Jboss 4.2 App server, say box B.
              3. So transaction is propogated from Box A to Box B and Transaction manager (Parent coordinator) on Box A coordinates the transaction directly with Transaction Manager of Box B.
              4. If Box B's transaction manager indicates that transaction needs to be rolled back then it's communicated to Box A.
              5. Box A will then rollback the transaction and not commit the message on JMS queue.

              If my understanding is correct then how doesn Box B's TM communicate the rollback? Is it by throwin exception?

              • 4. Re: transaction question
                marklittle

                Please take the time and effort to read through the JBossTS documentation that is shipped with every release. There's a lot of it, but it will answer all of your questions.

                • 5. Re: transaction question
                  mohitanchlia

                  I went through the material but still doesn't answer my above questions. I looked at JbossTS doc for 4.2. Could someone point me to correct source. I looked at everything in the doc except using OTS with external app.

                  • 6. Re: transaction question
                    mmusgrov

                    Your questions are really about how JTS works. The best place to look are the specifications: JTS http://java.sun.com/javaee/technologies/jts/index.jsp is the java mapping of the OTS http://www.omg.org/technology/documents/formal/transaction_service.htm.