Using persistent and non-persistent timers

Timers can be either persistent or non-persistent. In this recipe, we will learn more about what persistence means and how to create either a persistent or non-persistent timer.

Getting ready

A persistent/non-persistent timer is created using the @Schedule annotation and setting its persistent attribute to true/false. If programmatic timers are being used, the TimerConfig's setPersistent method is passed an argument of true/false.

Persistent timers are able to survive application and server crashes. When the system recovers, any persistent timers will be recreated and missed callback events will be executed. When replay of missed timer events is not desired, then a non-persistent timer should be used. For ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.