EJB Timer Bean Definition

The EJB container provides the timer service, which is the infrastructure for the registration and callbacks of timers and, hence, provides the methods for creating and canceling them. The timer service of the enterprise bean container enables you to schedule timed notifications for all types of enterprise beans except for stateful session beans. You can schedule a timed notification to occur at a specific time, after duration of time, or at timed intervals. For example, you could set timers to go off at 10:30 AM on May 23, in 30 days, or every 12 hours.

The EJB container provides different types of timers. The timer can be a single-event timer, which can occur at a specific time or after a specific elapsed duration, or an interval timer, which may occur on a regular schedule. Essentially, three types of timers are possible, as outlined in the table below:

Table 1. Types of Timers
Type of Timer Description
Single-event timer Create a single-action timer that expires after a specified duration.
Single event with expiration date Create a single-action timer that expires at a given point in time.
Interval timer with initial expiration Duration Create an interval timer whose first expiration occurs after a specified duration, and whose subsequent expirations occur after a specified interval.
Interval timer with initial expiration Date Create an interval timer whose first expiration occurs at a given point in time and whose subsequent expirations occur after a specified interval.