3 Replies Latest reply on Jun 20, 2006 12:23 PM by Elias Ross

    Bug? Transaction timeout....

    Joey Moawad Newbie

      I have a message driven bean which is processing a transaction which cam sometimes run for hours. The main goal I am trying to acheive is to increase the transaction timeout from the default 300 seconds (5 mins) to somehere in hours. The code below demonstrates the number of things I have tried to acheive this, but I have been unsuccessful in every attempt. I am starting to think there may be a bug in one of the transaction annotations. Please help...thanks!

      - 1. Tried setting the context from setMessageDrivenContext which is called by the container. I then got the user transaction and tried to set that timeout to > 5 mins but that did not affect the 5 min default trans. timeout. (Please see commented code)

      - 2. Tried setting the @TransactionTimeout annotation to a value > 500 but that seems to do nothing...bug?

      - 3. Any other suggestions?

      @TransactionManagement(TransactionManagementType.BEAN)
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      @TransactionTimeout(value=800)
      public class MDBDataLoadTask implements MessageListener,MessageDrivenBean {
      private MessageDrivenContext ctx;

      public void onMessage(Message msg)
      {
      /*
      UserTransaction aUT = ctx.getUserTransaction();
      aUT.begin();
      aUT.setTransactionTimeout(360);
      */

      try
      {
      //Perform a task that will take about this long to run
      Thread.sleep(365000);
      //aUT.commit();
      }
      catch (Exception e)
      {
      /*try{
      aUT.setRollbackOnly();}
      catch(SystemException se){System.out.println(se.toString());}*/
      }
      }

      @Resource
      public void setMessageDrivenContext(MessageDrivenContext ctx) { this.ctx = ctx; }

      public void ejbRemove() {ctx=null;}
      }

        • 1. Re: Bug? Transaction timeout....
          jaikiran pai Master

           

          UserTransaction aUT = ctx.getUserTransaction();
          aUT.begin();
          aUT.setTransactionTimeout(360);


          Change the above to:

          UserTransaction aUT = ctx.getUserTransaction();
           aUT.setTransactionTimeout(360);
          
           aUT.begin();


          i.e. set the transaction timeout before beginning the transaction.





          • 2. Re: Bug? Transaction timeout....
            jaikiran pai Master

            Also, if you are expecting any exception to be thrown on a transaction timeout, then it wont happen. No exception is thrown, the transaction state will set to MARKED_FOR_ROLLBACK. Later on, if any operations are done using this transaction, only then will a exception be thrown.

            You might want to verify whether the transaction timeout is working or not by checking the server logs, where you will see a WARN message from TransactionImpl saying that the transaction has timedout.

            • 3. Re: Bug? Transaction timeout....
              Elias Ross Master


              I wonder if

               <mbean code="org.jboss.tm.TransactionManagerService"
               name="jboss:service=TransactionManager"
               xmbean-dd="resource:xmdesc/TransactionManagerService-xmbean.xml">
               <attribute name="TransactionTimeout">3000</attribute>
              


              in your conf/jboss-service.xml needs to be changed to