4 Replies Latest reply on Apr 18, 2008 1:13 AM by rotula

    Transaction timeout question

    rotula

      Hi,

      Some questions regarding JBoss-specific @TransactionTimeout annotation.

      Assuming I have one CMT EJB and one method marked as "RequiresNew":

      @Stateless
      public class SomeBean{
      
       @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
       @TransactionTimeout(value=10)
       private void myMethod(){
       ....
       call to a web-service
       ....
       }catch( SOAPFaultException sfe ){
       }
      }
      


      If by some reason the web-service - running on dot.net - didn't response, like lets say a breakpoint ;)
      the method should, in my opinion, timeout and cast a IllegalStateException which it doesn't happened.

      I know that timeouts are not always processed immediately thats why I've tried to change
      Transaction Reaper Timeout value without result.
      The only thing I saw in logg when timeout occurs is:

      WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id -53eff49c:9ef:4805b31a:7f invoked while multiple threads active within it.
      WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action -53eff49c:9ef:4805b31a:7f aborting with 1 threads active!
      


      Is this any way to interrupt the execution method? It seems that annotation
      didn't work in this case until some response come back from web-service.

      I am using JBoss 4.2.1GA and Oracle 10G DB.

      Thanks.





        • 1. Re: Transaction timeout question
          jhalliday

          > Is this any way to interrupt the execution method?

          The transaction system won't do that for you. You need to build a timeout into the web services call if you want such behavior.

          Transaction timeouts happen in a background thread. The timeout will occur even if your thread is blocked. It just won't be evident to your business logic until it resumes.

          • 2. Re: Transaction timeout question
            rotula

            According your answer:


            The timeout will occur even if your thread is blocked.


            this piece of code should run:
            @Stateless
            public class SomeBean{
            
             @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
             @TransactionTimeout(value=100)
             public void methodA(){
            
             methodB();
             }
            
             @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
             @TransactionTimeout(value=10)
             public void methodB(){
             Thread.sleep( 20000 ); // sleep for 20 sec.
             }
            }
            

            but it doesn't.
            methodB should timeout after 10 sec according TransactionTimeout parameter.

            So, can a timeout occur on methodA without wainting for methodB to resume?



            • 3. Re: Transaction timeout question
              adinn

              What Jonathan said was perfectly correct. The point you have failed to grasp was explained in the previous answer

              > > Is this any way to interrupt the execution method?

              > The transaction system won't do that for you.

              So, the container is doing what you were told it would do i.e. it is cancelling the transaction when the timeout is reached. It is not doing what you were told it would not do i.e. it is not interrupting your blocked thread.

              When your thread wakes up and tries to perform some activity in the transaction it will discover that the TX is no longer active. If you want to wake the thread up earlier then arrange for that to happen by some other means.

              • 4. Re: Transaction timeout question
                rotula

                Thank you both for your answers!

                Unfortunate I messed up my transaction example with another blocked thread.
                Forget it! What I really intend to simulate was a long process. Did it change the problem now?

                I mean, we run on same thread, we process a long job, didn't the transaction system
                timeout from methodB - which is marked as "RequiresNew" - and continue with remaining part of methodA instead?

                Again, imho, a business method - belongs to a CMP bean -running on a new transaction context with a
                fixed allocated space of time should interrupt his execution after reaching timeout. Or?