users@glassfish.java.net

Re: Clustered Timer Service Behavior

From: <glassfish_at_javadesktop.org>
Date: Fri, 12 Dec 2008 14:54:57 PST

In our situation, we are calling createTimer() within the contextInitialized() of a ServletContextListener and each instance in the cluster invokes that ServletContextListener. There is no client per-se that invokes createTimer() on a specific server instance. If the timer is supposed to be triggered only on one of the cluster instances, then how does the cluster decide what instance triggers the timer? There must be some sort of algorithm to choose what instance triggers the timers since you said before the end result behavior must be the same in standalone and cluster mode. Based on what you've said, after that instance is chosen to trigger the timer, that timer will always be triggered on that one instance, right? Therefore, if the timer only invokes a local session bean, the timer-driven code will always execute on a single instance.

If I understand you correctly, it sounds like in my case, one server instance out of the cluster "wins" at triggering the timer for the life of that server instance. There is no real load balancing of the timers unless the timer invokes a remote session bean or some other EJB component that is distributed amongst the cluster instances.
[Message sent by forum member 'tmjkeeney' (tmjkeeney)]

http://forums.java.net/jive/thread.jspa?messageID=321517