1 2 Previous Next 18 Replies Latest reply on Jan 27, 2013 8:03 AM by luiz_gustavo Go to original post
      • 15. Re: TimerService: Timer interval stops after retry

        It's OpenSource

        You might check my changes in AS7 (follow the git pull request in the Jira).

        In AS6 you can simply find the class from the stacktrace (CalendarTimerTask.java:80) and you might fix this bug

        • 16. Re: TimerService: Timer interval stops after retry

          I stepped up to AS7 and noticed that some of the services i need aren't yet implemented.

          So finally i fixed the problem this way:






          public class BusinessTimerService {


              private final static int MAX_THREAD_TIME = 180;

              private PingThread businessThread = new BusinessLogicThread();

              private Date startTimestamp;


              private static class BusinessLogicThread extends Thread {


                  public void run() {

                      // Business logic





              @Schedule(second="*/"+Constants.PING_DELAY, minute="*", hour="*", persistent=false)

              public void timeout() {

                  if(businessThread == null || !businessThread.isAlive()) {

                      startTimestamp= new Date();

                      businessThread = new BusinessLogicThread();


                  } else {

                      long executionTime = new Date().getTime() - startTimestamp.getTime();

                      if(executionTime > MAX_THREAD_TIME*1000) {

                          System.err.println("Exception: Thread execution time == "+executionTime+"ms. Timeout! Start a new thread!");

                          businessThread = null;








          After a 3-day-Stresstest i recommend this code-skeleton(and yes...i know....NULLing the thread after the user-defined timeout isn't the best way :-) )







          • 17. Re: TimerService: Timer interval stops after retry

            Hi Daniel,

            you use your fix with AS6, right?

            I think you know that this solution violate the EJB spec because the Thread handling is not allowed.

            So it should be just a workaround and must be well tested, as you already done, for the specific application/JBoss installation!


            Also there is now a full certified AS7.1 (hurray ) in the download area http://download.jboss.org/jbossas/7.1/jboss-as-7.1.0.Final/jboss-as-7.1.0.Final.zip available.

            You may find here all what you need to migrate.




            • 18. Re: TimerService: Timer interval stops after retry




              I had the same problem.

              In my case, the processing time is not known, just the timeout, so it is common the timeout occur before the processing finish.

              I could fix it with this simple workaround:






              public class SomeScheduledService implements SchedulableService{




                  private TimerService timerService;



                  private SessionContext context;


                  private static boolean canExecute = true;   





                  public void run(Timer timer){




                          try {


                              SomeScheduledService.canExecute = false;


                              // call important business services


                          } catch (Exception e) {


                              // do something useful here


                          } finally {


                              SomeScheduledService.canExecute = true;


                              // release resources       



                      } else{           

                          // sorry... I'm busy now... try again next timeout           






              I hope it can help.



              Best Regards,

              Luiz Gustavo S. de Souza

              1 2 Previous Next