Java Reference
In-Depth Information
vice. Using the Timer Service to monitor the pilot tubes on an airplane and calculate engine
thrust would be a bad solution.
We'll now examine the types of beans that support timers, fault tolerance, and methods for
creating timers. After we've talked about these features in the abstract, we'll dive into code.
Supported bean types
As of EJB 3.1, the EJB Timer Service can be used with stateless session beans, singleton
beans, and message-driven beans. Stateful session beans aren't supported—perhaps in a fu-
ture revision support will be added, but it doesn't exist today. What this means is that unless
you're using a singleton bean, it's your responsibility to persist state between timer invoca-
tions. Each time a timer fires, a potentially different stateless session bean will be retrieved
and invoked, as shown in figure 7.2 . Singleton beans can be used where state needs to
be maintained between timer invocations with one caveat: too many timers on a singleton
bean can result in complications as timers clash attempting to execute on the same method
at the same time or different methods at the same time. Let's turn our attention toward fault
tolerance.
Figure 7.2. Timer Service and the stateless pool
 
Search WWH ::




Custom Search