8 Replies Latest reply on Jun 12, 2007 11:18 AM by rlj

    Altering the transaction timeout

    pmuir

      Hi

      I'm trying to import a large amount of data (using JDBC) and I hit the TransactionTimeout (as defined in jta-service.xml). I know I can alter the timeout in jta-service.xml, but I would really prefer to just alter it for the import method, not the whole application.

      Is this possible?

      TIA

      Pete

      Environment:

      JBoss 4.0.5.GA (i.e. HEM & HAN 3.2.0.CR2, Hibernate 3.2.0.GA), HSQL

      JBoss Seam (though I don't think this matters ;) )

        • 1. Re: Altering the transaction timeout

          Yes, in your session bean, you need to annotate your long running method as follows:

          @org.jboss.annotation.ejb.TransactionTimeout(3000)
          public void doSomethingThatTakesAges() {

          ...

          }

          James

          • 2. Re: Altering the transaction timeout
            pmuir

            Thanks for the reply James and sorry for the delay in replying - my forum subscriptions went wrong for a bit ;)

            I'll try this out on Monday.

            • 3. Re: Altering the transaction timeout
              toni

              I have tried this on my session bean, but I still run into a TransactionTimeout exception. I used the following my stateful session bean:

              @org.jboss.annotation.ejb.TransactionTimeout(10000000)
              


              Changing the timeout in jta-service.xml on the other hand works. I'm using seam 1.1 - could it be that this is only supported in higher versions of seam?

              • 4. Re: Altering the transaction timeout
                wolfc

                Transaction timeout only works on the method where the transaction is actually started. Either make sure you put the annotation there or add transaction attribute REQUIRES_NEW on your method.

                • 5. Re: Altering the transaction timeout
                  hbarca

                  Toni, did the annotation work for you?
                  It doesn't work for me...
                  I'm using JBoss 4.0.4, can be this a reason why TransactionTimeout does not work on EJB bussines methods?

                  • 6. Re: Altering the transaction timeout
                    toni

                    Hi hbaraca,

                    if I place the @TransactionTiemout annotation on one of my action methods of my SFSB's, which get called, when user clicks on an action link, then the timeout is being ignored. So it does not work for me.

                    • 7. Re: Altering the transaction timeout
                      hbarca

                      Hi Toni,

                      Oh, my mistake, I put the annotation in the wrong place (at one level deeper in the call chain). Now it works to me, with a SLSB. You have to make sure you put the annotation in the bean implementation code, at the method starting the transaction. By default, a transaction starts when the first call to a session bean method is beeing made from the user code, if no other transaction annotations have been used.
                      Hope it will work for you too.

                      Horia

                      • 8. Re: Altering the transaction timeout
                        rlj

                        Hi There

                        I'm so glad to hear someone got this working.
                        Can anyone of you please see my thread here:
                        http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050135#4050135
                        .. and tell my what I'm doing wrong.

                        I'm using Struts and I'm not calling any other methods on that specific bean or any other bean (in the current request that is). So my call-chain is only one step deep.

                        As you can se at the code-example in my thread I've also tried to set the TransactionAttribute REQUIRES_NEW

                        The Bean-method get called from my StrutsActionServlet.

                        Regards

                        /RLJ