Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [EJB/JBoss] - Re: TimerService and Timer

scott.stark@jboss.org

2007-05-10


i have found the problem. it was related with persistence of the timers. when a timer is created, it is stored (using DefaultDS) and reloaded at each jboss start. my solution is to cancel all the bean related timers befoare i create a new one:


|  public void createTimer() {
|    // Get TimerService
|    TimerService ts = sessionContext.getTimerService();
|    
|    // Cancel previous timers
|    for (Object o : ts.getTimers()) {
|      ((Timer)o).cancel();
|    }
|    
|    // Create new timer
|    Timer t = ts.createTimer(new Date(System.currentTimeMillis()
|        + INTERVAL_DURATION), INTERVAL_DURATION, "ots");
|    logger.debug("timer created");
|    logger.debug("total timers: " + ts.getTimers().size());
|  }
|

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044654#4044654

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044654
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.