Configuring a timer service for network deployment

You can configure the Enterprise JavaBeans (EJB) timer service for timers that can persist through application server shutdowns and restarts.

Before you begin

A database instance must exist before you complete either of the processes that are documented in this topic. For example, you might have a DB2® or Oracle instance. You must configure the Timer Service to use that database.

About this task

WebSphere® Application Server implements the Enterprise JavaBeans (EJB) Timer Service. Based on your business needs, you can use persistent timers or non-persistent timers. Persistent timers are helpful if you are creating a timer for a time-based event that requires assurance of timer existence beyond the life cycle of the server to persist through server shutdowns and restarts. Previously started persistent timers automatically start when your server starts, and they require a database instance.

Non-persistent timers do not use a data store and are canceled when the application server is stopped or fails to remain in an active state. Non-persistent timers exist only on the server where they are created. In a clustered environment, if your EJB application automatically creates a non-persistent timer and this application is mirrored on multiple servers, each server has its own non-persistent timer that runs within that server environment. Programmatically created non-persistent timers only run in the cluster member where it was created.

Both persistent and non-persistent timers require a work manager. Persistent timers use the work manager that is used by the scheduler service. Non-persistent timers use the default work manager of the server by default but can be configured to use a different work manager through EJB timer scripting. Non-persistent timers do not use the scheduler service.

Configuring a persistent timer in a network deployment environment is mostly about using the same data source.

You can configure the timer service to share the same database across multiple servers. However, each server must use its own unique database table. Complete one of the following processes to configure the timer service to share the same database across multiple servers:

Avoid trouble: When configuring an EJB Timer/Scheduler, remember that the default scheduler uses the simple file-based Apache Derby database by default so that you can quickly get a functioning environment up and running. DO NOT use the Derby database for production use. Moreover, the default Derby database does not support a clustered job scheduler, nor a clustered batch container.

Procedure

  • Configure a scheduler instance for the cluster, then configure the timer service to use that scheduler instance.
    1. Configure a scheduler instance for the cluster.
      When you complete this action you create a custom scheduler instance. Next, configure the timer service to use that custom instance.
    2. In the administrative console, click Servers >Application Servers > servername > EJB Container Settings > EJB timer service settings.
      The timer service settings panel is displayed.
    3. Select Use custom scheduler instance.
    4. Select your Scheduler JNDI name from the list.
    5. Click Apply.
    6. Click OK.
  • Configure the timer service default scheduler instance for each server to use the same data source.
    1. Select Use internal EJB timer service scheduler instance.
      To customize the pre-configured instance:
    2. Select your data source JNDI name from the menu list to change the data source. You can use any supported database, such as DB2 or Oracle) select your Data source JNDI name from the menu list.
      The default database listed cannot be shared because it is configured for one server only, and it uses the single server version of Apache Derby, which can only be accessed by one server process at a time.
    3. Enter your chosen Datasource Alias.
    4. Enter your chosen Table Prefix if you want to have several server processes use the same database, but different tables.
    5. Enter a Poll Interval value in milliseconds.
      For more details see information about configuring the timer service.
    6. Click Apply.
    7. Click OK.
    8. Change all of your server processes to use the same database you chose from the Data source JNDI name menu list earlier.