TimerService timerService = ejbContext.getTimerService(); timerService.createTimer(someMilliseconds, "A test timer");The lifecycle for a Timer object is as follows:
1) Creation - One of the createTimer methods of the TimerService interface is invoked.
2) Saving - Timers are saved when their container is shut down, when their container crashes, or when their TimerHandle is manually retrieved and saved.
3) Restoring - Timers are restored and become active again when their container is restarted or when their TimerHandle is the getTimer method is invoked.
4) Destroying - Timers are cancelled when the time interval expires, the EJB container cancels the timer (such as when the Timer's EJB instance is removed), or when the cancel method of the Timer is called.
The timer service itself is created by an application server usually during startup. During a graceful shutdown of the application server, the timer service is destroyed which will result in all timers being destroyed and triggers being cancelled.
This was first published in October 2003