First, make sure you configure the timer service to an external XA shared data source, as described here .
After delving into your question in the past, I remember some explanation from the developers on the mailing lists that the Glassfish implementation looks like this:
Say you have node A, B and C in the cluster. Permanent timers are created when node A "belongs" to node A (that is, timer events are delivered by node A). If node A fails, then its timers can be moved to another node.
After Glassfish does not support the @Singletons
cluster, you get as many timers as there are calls to initResetTimer()
. In addition, each restart / restart of the server will probably create a new timer instance on the node cluster, in addition to the old unspecified ones, so be sure to cancel your programmatically created timers :) To avoid this alltogether, use declarative @Schedule(...)
approach and Glassfish will create a timer once in the cluster and, hopefully, automatically transfer them on error.
Hope this helps.
UPDATE:
A programmatically created timer, permanent or intermittent, will be launched in the JVM / node, it was created regardless of clustering or not. You can summarize approximately: the number of independent timer instances is equal to the number of calls timer.createXxxTimer()
source share