EJB Timers and Clusters
Wondering if anyone else has come across this issue while working with EJB Timers in a clustered App Server environment?
I am trying to use an EJB Timer to periodically update a cache of values for a web application. To make sure the timer is started, I am using a ServletContextListener to tell my Stateless Session EJB to create the timer.
I first found that when I stopped and restarted the App Server that this code was creating new versions of the Timer along with the existing versions of the Timer - which makes sense since EJB Timers are persistent. Realizing my mistake, I added code to check if the Timer already existed (eg aTimer.getInfo().equals("MY TIMER NAME")). If the Timer already existed, then I would not recreate the timer.
The problem I then came across is that the second instance of my cluster was finding the Timer created by my first instance, and so it would not create a Timer for itself.
This is where I have my question. Has anyone else come across this? It seems that when I use the getTimers() method of TimerService, I am not being presented with timers only for the container I am in. I am using Oracle as my datasource, and I have queried the ejb__timer__tbl and seen that the OWNERID column has different values when both instances create the timer.
BTW - I have worked around the problem by generating a Timer name that contains the instance name (from the com.sun.aas.instanceName System Property), but would like to not to have to use a workaround forever.

