Java Reference
In-Depth Information
Fault tolerance
With any timer, the question of fault tolerance is an important one. Even the most basic
alarm clocks include battery backup so that if the power is lost the clock continues to
track time and remembers your wake-up time. Thus, you can sleep through the night, and
an intermittent power failure—provided it doesn't occur when the alarm is supposed to
sound—won't result in you being late for work or missing that important flight to Hawaii.
If the power is out when the alarm is supposed to sound, there's not much the alarm clock
can do. With the EJB Timer Service, alarms will survive server restarts and failures with
no additional effort on your part.
When a method is scheduled, the container creates a timer that will execute the specified
method at the designated time. When the timer fires, the time condition has been met, and
the method is either called in the case of a singleton bean or an instance is plucked from the
method-ready pool and executed in the case of a stateless singleton bean. This is illustrated
in figure 7.3 . Note that singleton beans aren't serialized between server restarts, so it's im-
portant that beans persists their state. Timers aren't supported with stateful beans.
Figure 7.3. Timers on stateless beans versus singleton beans
 
Search WWH ::




Custom Search