EJB Timer Service
EJB timer service is the service which enables you to receive timer callbacks periodically or at a specified time. For basic usage of the timer service, refer to EJB specification.
This chapter describes how to configure and use the timer service provided in JEUS EJB.
1. Configuring the Timer Service
In general, the JEUS EJB timer service follows the specification, but the function to manage the timer persistently can be used according to the desired performance and user’s need.
The following settings can be configured for the timer service.
-
EJB Engine’s Timer Service
Enables the shared properties and persistent timer service that are applied to all the beans using EJB timer service.
-
jeus-ejb-dd.xml
Configures how to manage Persistent Timers when deploying and updeploying each bean.
1.1. Configuring the Persistent Timer Service (EJB Engine)
The persistent timer service of an EJB engine can be configured by using domain.xml as follows.
<ejb-engine> <resolution>1000</resolution> <use-dynamic-proxy-for-ejb2>true</use-dynamic-proxy-for-ejb2> <enable-user-notify>false</enable-user-notify> <timer-service> <support-persistence>true</support-persistence> <max-retrial-count>1</max-retrial-count> <retrial-interval>5000</retrial-interval> <thread-pool> <min>2</min> <max>30</max> <period>3600000</period> </thread-pool> <database-setting> <data-source-id>tibero_XA1</data-source-id> <db-vendor>tibero</db-vendor> </database-setting> </timer-service> </ejb-engine>
The following describes each configuration items of Persistent Timer Service in the Advanced Options.
-
Thread Pool
The thread pool used for the timer service to execute the timeout() method is configured as follows.
Tag Description Min
Minimum number of threads in the pool.
Max
Maximum number of threads in the pool.
Period
Time period for which idle threads can remain in the pool before removal.
-
Database Setting
The following table describes the mandatory option settings in Advanced Options. Since the persistent timer internally uses CMP bean to access the database, the CMP bean is configured through the following options. Therefore, each item in CMP bean is identical to the schema settings of a CMP bean.
Tag Description DB Vendor
Database vendor used by the Timer CMP bean.
Data Source ID
DataSource name used by the Timer CMP bean.
1.2. Processing the Persistent Timer (jeus-ejb-dd.xml)
When an EJB Engine is configured to use a persistent timer service, the user can decide whether to use the persistent timer service for each bean, use the persistent timer that remains in the database before deploying it, or discard it. This can be done through the jeus-ejb-dd.xml file.
Persistent Timer Service can be configured in domain.xml. For more information, refer to Configuring the Persistent Timer Service (EJB Engine).
The following is an example of jeus-ejb-dd.xml in which persistent timer processing is configured through the <timer-service> element inside the <jeus-bean>.
<jeus-ejb-dd> . . . <beanlist> . . . <jeus-bean> . . . <timer-service> <support-persistence> true </support-persistence> </timer-service> . . . </jeus-bean> . . . </beanlist> . . . </jeus-ejb-dd>
The following describes the Timer element:
Tag | Description |
---|---|
<support-persistence> |
Determines whether to manage the timer of the bean persistently. |
1.3. Configuring the Cluster-Wide Timer Service
All EJB engines must use the same EJB timer service. The timer service configured in each MS will be ignored.
The following describes how to set a cluster-wide timer service in domain.xml.
<cluster> <cluster-wide-timer-service> <database-setting> <data-source-id>tibero_XA1</data-source-id> <db-vendor>tibero</db-vendor> </database-setting> </cluster-wide-timer-service> </cluster>
The description of each setting item is the same as the 'Database Setting' items in Configuring the Persistent Timer Service (EJB Engine).
2. Configuring Timer Monitoring
EJB timers can be monitored or cancelled using the console tool.
Using the Console Tool
An EJB timer that runs on the server can be monitored or cancelled using the console tool.
-
Monitoring
Information about an EJB timer can be displayed by using the ejb-timer-info command.
ejb-timer-info -server <server-name>
-
Cancellation
An EJB timer can be cancelled by using the cancel-ejb-timer command.
cancel-ejb-timer -server <server-name>
For more information about the previous two commands and EJB engine related commands, refer to EJB Engine Commands in JEUS Reference Guide. |
3. Cautions for Timer Service
The following describes cautions to consider when using a timer service.
-
Persistent Timer and JDBC Connection
Persistent Timer is stored in the Database, and CMP Bean that manages the Timers uses the Time Service - Database Setting - Data Source Id value of the EJB engine.
A transaction that includes beans which use the persistent timer also manages the datasource which is used by the Timer CMP bean. Therefore, you need to consider the datasource to determine whether to use LOCALXAResource or XAResource.
For detailed information about the datasource, refer to JEUS Server Guide.