1 2 Previous Next 23 Replies Latest reply on Jul 12, 2007 10:30 AM by Brice Ruth

    End-to-end Transactions with WS-Tx

    Martin Steinle Newbie

      Hello,

      I tested the web services transactions implementation and it worked fine for me. But what I require is what is described with the term "end-to-end transactions". I saw the JIRA issue http://jira.jboss.com/jira/browse/JBTM-44 and that it will be done in version 4.6. I can't wait until this is done, so I must implement it myself.
      My idea was to implement a Durable2PCParticipant (of course), but I don't know how to access the "local" transaction (i.e. my database transaction).
      Can you give me a hint where to start? I thought that I require any interface where I can call prepare(), commit() and rollback() methods.

      I'd be very happy about any help.
      Regards,
      Martin

        • 1. Re: End-to-end Transactions with WS-Tx
          Kevin Conner Master

          You will need to create a JTA transaction and associate it with the current AT TxContext. This should be part of your Durable2PCParticipant implementation.

          When an invocation comes in using that TxContext you must wrap it with calls to the JTA transaction manager to resume/suspend the associated JTA transaction.

          You can then drive the JTA 2PC from the WS-TX 2PC calls to your participant.

          Kev

          • 2. Re: End-to-end Transactions with WS-Tx
            Mark Little Master

             

            "Kevin.Conner@jboss.com" wrote:
            You will need to create a JTA transaction and associate it with the current AT TxContext. This should be part of your Durable2PCParticipant implementation.


            It will need to be a subordinate JTA transaction though, otherwise you will not have access to prepare.

            • 3. Re: End-to-end Transactions with WS-Tx
              Martin Steinle Newbie

              Thanks a lot for the very fast replies!

              I have one more question: What is a subordinate JTA transaction, and how can I create it?

              Thanks again,
              Martin

              • 4. Re: End-to-end Transactions with WS-Tx
                Kevin Conner Master

                It is the implementation of the JTA Transaction which exposes the 2PC methods.

                com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple

                You just need to instantiate it and control it through the transaction manager.

                Kev

                • 5. Re: End-to-end Transactions with WS-Tx
                  Kevin Conner Master

                  I should add that you do not call the commit/rollback methods but rather the doPrepare/doCommit/doRollback methods.

                  Kev

                  • 6. Re: End-to-end Transactions with WS-Tx
                    Martin Steinle Newbie

                    Once again, thanks for the replies!

                    Now, the implementation seemed very simple to me, but I does not (yet) work. The problem is, that the new subordinate transaction I created is not known by JTA, i.e. javax.transaction.UserTransaction.getStatus() is Status.STATUS_NO_TRANSACTION.
                    I think perhaps I must register the created subordinate transaction with the JTA transaction manager, but again, I do not know how to do this, as I found no matching method of the TransactionManager.

                    Could you please help me once again?

                    Regards, Martin

                    • 7. Re: End-to-end Transactions with WS-Tx
                      Martin Steinle Newbie

                      Hello again,

                      since your last post I tried to understand your posts and integrate WS-Transactions with local jta transactions, but I failed.

                      Let me check if I understood your posts correctly:

                      com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple

                      You just need to instantiate it and control it through the transaction manager


                      What does instantiate mean? Call the constructor? That's what I did, but there still was no transaction accessible, e.g. by calling
                      ((javax.transaction.TransactionManager) new InitialContext().lookup("java:/TransactionManager")).getTransaction()


                      What does "control it through the transaction manager" mean? And which transaction manager is meant, the one controlling WS-AT or the "local" transaction manager?

                      And finally, do I understand the overall process correctly? IMO, a client creates a new WS-AT, calls some transaction-aware web services, and finally commits or rolls back the transaction.
                      The web services, when called, start a local transaction (a subordinate transaction?) and enlist a Durable2PCParticipant with the WS-AT which will delegate the prepare(), rollback() and commit() calls to the local transaction.

                      Regards, Martin

                      • 8. Re: End-to-end Transactions with WS-Tx
                        Kevin Conner Master

                         

                        "stone_42" wrote:
                        What does instantiate mean? Call the constructor?

                        Yes, that is correct.
                        "stone_42" wrote:
                        What does "control it through the transaction manager" mean?

                        You need to use the JTA transaction manager and resume/suspend the transaction around each method invocation.

                        "stone_42" wrote:
                        And finally, do I understand the overall process correctly? IMO, a client creates a new WS-AT, calls some transaction-aware web services, and finally commits or rolls back the transaction.
                        The web services, when called, start a local transaction (a subordinate transaction?) and enlist a Durable2PCParticipant with the WS-AT which will delegate the prepare(), rollback() and commit() calls to the local transaction.

                        That is the overall flow but it is the header handler which controls the server side and not the webservice. You need to modify the handler associated with the WS-TX headers so that it will do two things
                        Create a JTA transaction if one is not already associated with the WS-TX transaction
                        Resume the transaction before the webservice method is invoked and suspend it afterwards


                        • 9. Re: End-to-end Transactions with WS-Tx
                          Martin Steinle Newbie

                          Hello,

                          now I got it all, it is working. Thank you a lot for supporting me!

                          Testing my sample application, I found one additional thing:
                          If there is exactly one Durable2PCParticipant in the WS-AT transaction and it responds in prepare() with ReadOnly(), there is the following exception on the client side:

                          com.arjuna.wst.SystemException
                           at com.arjuna.wst.stub.CompletionStub.commit(CompletionStub.java:97)
                           at com.arjuna.mwlabs.wst.at.remote.UserTransactionImple.commitWithoutAck(UserTransactionImple.java:269)
                           at com.arjuna.mwlabs.wst.at.remote.UserTransactionImple.commit(UserTransactionImple.java:136)
                           ... 85 more


                          Is this an issue of your implementation?
                          Luckily, the workaround is simple, as I can return Prepared in all participants instead of Readonly.

                          Regards,
                          Martin

                          • 10. Re: End-to-end Transactions with WS-Tx
                            Kevin Conner Master

                             

                            "stone_42" wrote:
                            now I got it all, it is working. Thank you a lot for supporting me!

                            Well done, that's fantastic news.
                            "stone_42" wrote:
                            Is this an issue of your implementation?

                            This sounds as if it is a bug in our implementation. The exception is thrown if the completion stub does not receive a committed/aborted response. I'll log a jira task against this.
                            "stone_42" wrote:
                            Luckily, the workaround is simple, as I can return Prepared in all participants instead of Readonly.

                            The only down side of this is that your participant will have to process an additional commit message but functionally it is the same.

                            Kev

                            • 11. Re: End-to-end Transactions with WS-Tx
                              Kevin Conner Master

                              I have created the following JIRA issue to cover this.
                              http://jira.jboss.com/jira/browse/JBTM-195

                              • 12. Re: End-to-end Transactions with WS-Tx
                                Kevin Conner Master

                                Hiya Martin.

                                I have just had a look at this issue again and discoverd the problem. Unfortunately I did not manage to do this in time for the 4.2.3 release so it will have to wait for the next one.

                                You can pull in the update from svn in the meantime, revision 11159 contains the fix.

                                Apologies for the delay in fixing this one.

                                • 13. Re: End-to-end Transactions with WS-Tx
                                  Martin Steinle Newbie

                                  Hi Kevin,

                                  thanks for the information.
                                  Currently, our system is urnning nearly productive, so I even won't upgrade to 4.2.3; you know, never change a running system...

                                  Thanks again,
                                  Martin

                                  • 14. Re: End-to-end Transactions with WS-Tx
                                    Brice Ruth Novice

                                     

                                    "stone_42" wrote:

                                    now I got it all, it is working. Thank you a lot for supporting me!


                                    Could you post out on the wiki (http://jboss.org/wiki/Wiki.jsp?page=JBossTransactions) or here some more detailed information on what you did to setup your end-to-end transaction support? Get as detailed as you have time, if you please. We're getting set to do this as well, so the more info, the smoother the ride, I think.

                                    Please provide the versions of JBossTS and app server(s) that you're using as well.

                                    Thanks!

                                    1 2 Previous Next