I have a usecase where I want to have a recurring service checking some db information and send out mails i nessesary. I started with a simple scheduled service that worked fine. Then I wanted to use Seam to send out my mails but I got problems with failed rendering because I was outside of the seam context in my scheduled service bean. So I switch to using seam asynchronous methods and timers.
I have a bootstrap action annotated with
and then a @Create annotated method to start the asynchronous action with a timer.
The boostrap action is application scoped and stores the timer instance for the duration of the application lifecycle. The timer is destroyed in the @destroy method. When the timer is created it is stored by the application server in the timer db table and removed when the server is stoped or my application undeployed.
Now to the problem :-)
Sometimes the timer is not removed from the db when the server is stopped. Then when I start the server again a new timer is created in my bootstrap action and now I have to timers running making my service run more often then I want.
How can I avoid this problem? Is this the wrong solution for my usecase or can I somehow check for exising timers when bootstrapinig or can I shedule my asynchronous methos in the same way that i schedule my service in a xml file or ... ?
Thankfull for all input!
Best regards Fredrik
The Seam async methods are backed by the EJB3 timer. This is a shortcoming in EJB3 timers really - you could ask this in the EJB3 forum as well (and lobby for a better timer)