I'm just about to use the new EJB3 TimerService (as part of Java EE 6), and as usual, I'm impressed by the brevity of JavaDoc :)
Do you know what is the effect of the persistent
property of the TimerConfig
object?
JavaDoc TimerConfig says: The persistent property determines whether the corresponding timer has a lifetime that spans the JVM in which it was created. It is optional and defaults to true.
Persistent Timer – To deal with a zero-window-size deadlock situation, TCP uses a persistence timer. When the sending TCP receives an acknowledgment with a window size of zero, it starts a persistence timer. When the persistence timer goes off, the sending TCP sends a special segment called a probe.
Nonpersistent programmatic timers are created by calling TimerConfig. setPersistent(false) and passing the TimerConfig object to one of the timer-creation methods.
Specifies the number of minutes that a session can remain idle before the server terminates it automatically. The default is 10 minutes. Session.
Timer Service is a mechanism by which scheduled application can be build. For example, salary slip generation on the 1st of every month. EJB 3.0 specification has specified @Timeout annotation, which helps in programming the EJB service in a stateless or message driven bean.
The persistent property means that the container is required to persist the timer state to a database. This is important if you need to guarantee that the timer will fire even if the server is taken offline (intentionally or crash). When the server comes back online, it is required to execute missed timers. Setting a timer as persistent also has the side-effect of ensuring that the timer only executes in one server JVM (but not necessarily the one that created it), whatever that means for your product. For example, in a clustered server environment, this typically means that even if EJB module is running on 3 JVMs, exactly one JVM will execute the timer.
persistent=true was the only option available prior to EJB 3.1. Some timer operations are not critical enough to warrant this level of reliability, so the option was added to allow non-persistent timers. Setting a timer as non-persistent also has the side-effect of ensuring it runs in the JVM in which it was created. This can be useful for updating an in-memory cache or static HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With