5 Replies Latest reply on Oct 29, 2012 8:47 AM by mmusgrov

    transaction propagation from client to the stateless session bean

    rohanemmanuel

      Capture.PNG

      hi,

      i was tryin the above scenario, can you please let me know the way to propagate the transaction from my client to the bean ..?

       

      Thanks

       

      at present i'm getting a different XID on the client side and on the jboss server log. and the rollback on the client side doesnt rollback the changes made

        • 1. Re: transaction propagation from client to the stateless session bean
          mmusgrov

          The example bundled with the article (https://community.jboss.org/wiki/TransactionPropagationWithJBoss) does what you are trying to do. In what ways does your example differ from the one in the article. Have you managed to get the one in the article working. We will need a bit more context/informaion to give you any useful feedback.

          • 2. Re: transaction propagation from client to the stateless session bean
            rohanemmanuel

            Thanks for the quick reply Michael,

             

            i'm using JTA not JTS,

            i do begin and commit in the clients as mentioned below

             

            public static void main(String[] args) throws ClassNotFoundException,  {

             

                                  IProject bean = doLookup();

             

                       javax.transaction.UserTransaction utTransaction;

                       utTransaction =  com.arjuna.ats.jta.UserTransaction.userTransaction();

             

             

             

                                utTransaction = (UserTransaction) tm.getTransaction();  

                      System.out.println("sending message to the queue");

                      try {

             

                                  utTransaction.begin();

            ..........

            ..................

             

             

            and in the bean i have transaction attribute as follows:

             

            @Stateless

            @TransactionManagement(TransactionManagementType.CONTAINER)

            @TransactionAttribute(TransactionAttributeType.REQUIRED)

             

             

            public class ProjectBean implements IProject {

             

            ..............

            .....

             

            i want the transaction to be propagated from the client to the bean .thats not happening at present.

             

            if you need anymore information, i'l be happy to provide..

            • 3. Re: transaction propagation from client to the stateless session bean
              mmusgrov

              If session beans E and  K are running in separate JBoss servers then you must use JTS to propagate the transaction. But if they are in the same server then JTA will be sufficient.

               

              Do you get the transaction from the same server on which the session beans are running? How does bean E lookup bean K?

               

              (In your pseudo code I see two different ways of obtaining a UserTransaction, which one are you actually using?).

               

              To test that the transaction propagates from the client to bean E can you temporarily change TransactionAttributeType.REQUIRED to TransactionAttributeType.MANDATORY so that we will immediatly see that the transaction wasn't propaged since the server hosting bean E will report an exception.when your client invokes the bean. Simillary, to test that transaction propagates from bean E to K can you mark the target method on bean K as MANDATORY too.

              • 4. Re: transaction propagation from client to the stateless session bean
                rohanemmanuel

                the beans E and K are running on the same server.

                 

                i'm using this:

                 

                utTransaction =  com.arjuna.ats.jta.UserTransaction.userTransaction();     is this the correct way?

                 

                the getTransaction was a commented line..forgot to remove it..

                 

                i had already tried using the MANDATORY attribute on the bean , it fails with an exception , hence i wanted to know how to propagate the transaction from client to bean.

                 

                but the transaction is being propagated to the second bean , if i explicitly throw an exception in one of the beans , everything is being rolled back.

                • 5. Re: transaction propagation from client to the stateless session bean
                  mmusgrov

                  utTransaction =  com.arjuna.ats.jta.UserTransaction.userTransaction();     is this the correct way?

                   

                  I would recommend that you follow what the article says (also don't forget that you need to be looking the section that applies to local JTA transactions as opposed to distributed JTS transactions). Perhaps I should create two articles one dedicated to JTA and the other to JTS, I will put it on my todo list.

                   

                  So, try it the way the article says and if it's still failing then please can you see if you can get the example attached to the article working since it should be doing exactly what you need.