1 Reply Latest reply on Oct 20, 2006 11:42 AM by cyberdoc

    TimerService problem Timeout called twice

    cyberdoc

      Hi,

      i'm using JBoss 4.0.4GA with EJB 3 RC9.

      I created a MBean that creates an timer in the start method:

      @Service
      @Management(CleanerServiceManagement.class)
      public class CleanerService implements CleanerServiceManagement {
       @Resource
       private TimerService timerService;
      
       private static final String CALL_CLEANER = "callCleaner";
       private Log log = LogFactory.getLog(this.getClass());
      
       public void create() throws Exception {
       //
       }
      
       public void destroy() {
       //
       }
      
       public void start() throws Exception {
       timerService.createTimer(System.currentTimeMillis()+16000, 8000, CALL_CLEANER);
       }
      
       public void stop() {
      
       }
      
       @Timeout
       public void timeout(Timer timer) {
       if (!(CALL_CLEANER.equals(timer.getInfo()))) {
       log.info("wrong timer");
       return;
       }
      
       log.info("***********************************");
       log.info("Timer called");
       log.info("***********************************");
       }
      }
      


      Now the timeout method is called every 8 seconds twice. What is wrong? Or what do i need to configure??


      Thanks for help!

      Michael

        • 1. Re: TimerService problem Timeout called twice
          cyberdoc

          Hi,

          I have bounded my problem. The problem is, that when i persist the Timer during shutdown, i'm not able to identify the Timer at startup.

          At startup i check all Timers of the TimerService (timerService.getTimers()), but i don't get any timer, so i create a new timer with my ID. When JBoss is finished with startup, a second Timer (the old one, which was persist before) will start too. After next restart i have three timer, and so on...

          How can i check, that the timer with my ID is already created or rather is loaded again?

          Thanks for Help.


          Michael