Is it possible to run EJB Timer (@Schedule) on each node of a cluster? Is it enough to declare the timer as non-persistent? Do I need a database which can be accessed by both nodes or can I use the internal derby database?
The use case behind this requirement is to refresh some data in the memory of each node.
AppServer is Glassfish 3.1 (Java EE 6).
Yes, you want a non-persistent timer. Per the EJB 3.1 specification:
Non-persistent timers can be created programmatically or automatically (using
@Schedule
or the deployment descriptor). For automatic non-persistent timers, the container creates a new non-persistent timer during application initialization for each JVM across which the container is distributed.
(As an aside, Derby databases can only be shared by multiple processes if you use Derby network server. Multiple application server processes cannot open a Derby database simultaneously.)