Persistent EJB Timers on the Domain Data Grid
Since Payara Server 5.181
This feature is released in technical preview. It’s fully usable and supported but it’s subject to change in future versions. Read more in Features in Technical Preview. |
It is possible to persist an EJB Timer to the Domain Data Grid rather than to a database. The same feature is standard in Payara Micro.
Persisting an EJB Timer to the Domain Data Grid means that the Data Grid itself will store the timer details, preserving it even if the original instance leaves the cluster.
All stored timers are lost if the whole domain is stopped. |
The Persistence service for EJB Timers can be set in the administration console by navigating to the EJB Timer Service tab in the EJB Container node of a configuration.
To use the Data Grid to store EJB Timers set the Persistence Service to DataGrid
EJB Timers will be coordinated across a single deployment group and if an instance of the deployment group is stopped another instance in the same deployment group will take ownership of the timer and ensure it is fired.
Clustered Timer Firing Mode is NOT used in this version of Payara Server and is always "One Per Deployment Group" |
It is also possible to set the ejb-timer-service
from the command line. To get the current state, run the following command:
asadmin> get configs.config.${your-config}.ejb-container.ejb-timer-service
This will return the current state taken from the domain.xml configuration file, which by default should be something similar to the following:
asadmin> get configs.config.server-config.ejb-container.ejb-timer-service
configs.config.server-config.ejb-container.ejb-timer-service.ejb-timer-service=Database
configs.config.server-config.ejb-container.ejb-timer-service.max-redeliveries=1
configs.config.server-config.ejb-container.ejb-timer-service.minimum-delivery-interval-in-millis=1000
configs.config.server-config.ejb-container.ejb-timer-service.redelivery-interval-internal-in-millis=5000
Command get executed successfully.
To persist to the DataGrid you need only change the value for configs.config.server-config.ejb-container.ejb-timer-service.ejb-timer-service
to DataGrid
. To do this, run the following set
command:
asadmin> set configs.config.server-config.ejb-container.ejb-timer-service.ejb-timer-service=DataGrid
set commands are not dynamic. You will need to restart your domain to apply the changes.
|
Timer Migration
EJB Timers stored in the Domain Data Grid support timer migration between Instances in the same Deployment Group. You can migrate timers using the Administration console from the Deployment Group page. Timers can also be migrated between instances using asadmin commands like this:
asadmin> migrate-timers --target server1 server2
Where server1
is the active instance to migrate timers to and server2
is the failed instance.
Migration from Live Instances
Since Payara Server 5.2020.1
The migrate-timers
command can also be used to migrate timers that are scheduled to expire on a live instance.
Users previously had little control over the instance on a deployment group that a timer would execute on, with the
only way to force migration to another instance being to stop the instance they were currently executing on. This change
allows a user to pre-emptively move their timers around without having to resort to failover mechanics.