Managing enterprise beans (EJB) persistent timers

Applications or modules can create EJB persistent timers either automatically or programmatically that are stored in a database. An MXBean is provided for viewing the persistent timers that exist in the database and removing some or all persistent timers that are associated with an application.

About this task

The best way to manage EJB persistent timers is through the application that created the timers. The application that created the timer is able to provide the context of why the timer was created and exactly what action the timer performs when the timer reaches the expiration. However, for application development and diagnostic purposes the EJB timer service does provide an MXBean capable of performing basic timer management functions, com.ibm.websphere.ejbcontainer.mbean.EJBPersistentTimerServiceMXBean.

The MXBean provides operations to find the EJB persistent timers that are associated with an application, module, or specific bean. The viewable information includes the name of the bean that the timer is associated with and the schedule when the timer expires. Application-specific data that is associated with the timer might not be viewable. Operations are also provided to cancel a specific timer or all timers that are associated with an application, module, or bean.

The EJB APIs do not provide a mechanism for providing a unique identity when creating timers, however when the timer is stored in the database a unique identity is associated with the timer and used as the primary key into the database. There is no way to programmatically obtain the timer identity, but the identity is part of the viewable information provided by the MXBean 'get' operations. The identity appears in logs when an error is encountered involving the timer. And, the identity is the value that is used to cancel a specific timer through the 'cancelTimer' MXBean operation.

Note: All MXBean operations perform the same for both automatic and programmatic persistent timers.

Procedure

  1. Configure the application server to include an EJB feature that supports persistent timers and the rest connector in the server.xml file.
    <featureManager>
         <feature>servlet-3.1</feature>
         <feature>ejbPersistentTimer-3.2</feature>
         <feature>jdbc-4.1</feature>
         <feature>restConnector-2.0</feature>
    </featureManager>
  2. Start the JConsole from the JVM bin directory and connect to the Liberty server process.
  3. Navigate to the EJB timer service MXBean.
  4. Enter the application name in the String field of the first 'getTimers' operation and submit to receive information about the persistent timers for the application.