1 Reply Latest reply on Nov 17, 2011 11:18 AM by hanseichelpilz

    How to use @AccessTimeout the right way?

    hanseichelpilz

      Hi,

       

      i'm currently wondering how to use the @AccessTimeout annotation the right way.

      In my case, i have a singleton bean with a @Timeout annotated method.

      I thought could control the execution duration of this method with the @AccessTimeout annotation. So when there is a timer run each 15 seconds i want to assure, that one call of my method triggered by the timer will abort after 14 seconds.

       

      Thats my timeout method.

       

          @AccessTimeout( value = 14000 )
          @Timeout
          public void doWork() throws NotSupportedException, Exception {
              doSomethingThatCanLastALongTime();  
          }
      

       

      And this is my ScheduleExpression producer:

       

          @Produces
          public ScheduleExpression produceSchedule() {
      
              return new ScheduleExpression().
                      hour( "*" ).
                      minute( "*" ).
                      second( "*/15" );
          }
      

       

      I would expect, that the method doWork() would throw an exception if the execution takes more than 14 seconds. But thats not the case.

      Even if i put a Thread.sleep(20000) in the method, no exception is thrown.

      I'm in doubt that the @AccessTimeout is the right annotation for my purpose