Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java EE Timer Service, programmatic timers and application deployment

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?

like image 682
Matteo Avatar asked Mar 26 '26 03:03

Matteo


1 Answers

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?

like image 84
Vetle Avatar answered Mar 27 '26 23:03

Vetle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!