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

gardon do-not-reply at jboss.com
Thu May 10 07:54:42 EDT 2007


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



More information about the jboss-user mailing list