Reputation: 14940
I am using Java EE Timer Services programmatically to create persistent timers
@Resource
TimerService timerService;
...
timerService.createCalendarTimer( scheduleExpression, new TimerConfig( ..., true ) );
Timers work as expected and are persisted: I can stop and start the server and the timers are still there.
Now when I deploy a new version of the application the timers are lost. Is there a way to either:
keep the timers when an application is re-deployed on the same server
have a method called by the first start of my Java EE application after deployment so that I can re-create all the timers?
Upvotes: 3
Views: 764
Reputation: 3417
See this answer. In short; there's no automatic way to keep timers on redeploy, and you need to handle that yourself. Perhaps recreate them on application startup using @Startup
?
Upvotes: 2