Hi,
I am new to
EJB and was reading about Timers for the first time last night.
"Mastering EJBs" says
TIMERS AND TRANSACTIONS
The creation of timers is supported within transactions.
Therefore, if an enterprise bean method that creates the timer is executed as
part of a transaction and if that transaction is rolled back, the timer creation is
rolled back too. Similarly, if an enterprise bean method cancels the timer by
calling cancel() on the Timer interface within a transaction and if that
transaction is rolled back, the container rolls back the timer cancellation as
well. The container restores the duration of the timer to the duration it would
have had, had it not been rolled back.
The timeout callback method can also be called within a transaction and
typically has transaction attributes of REQUIRES or REQUIRES_NEW. Hence, if
the transaction rolls back, the container will call the timeout callback method
again.
which I think answers your first question.
EJB in Action says
However, unlike stateless session beans and MDBs, timers are persistent and can survive a container crash or restart.
which I think answers your second question.
I am unclear however whether you have to explicitly persist the Timer handle or whether the Container is just resiliant in this respect.
A quick
test by writing a Timer would prove whether it worked for your Container - have you tried this?
Thanks,
MG
28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%