users@glassfish.java.net

Re: Timer Service in a cluster

From: <glassfish_at_javadesktop.org>
Date: Fri, 27 Apr 2007 08:01:14 PDT

HI Darren,

A cluster is homogenous, meaning each application deployed to a cluster runs identically on every
server instance in the cluster. There is no notion of deploying an application to only one
server instance in a cluster. You can define a stand-alone server instance and deploy an
application to that, in which case you know the application is being deployed to only one
server instance.

Regarding the EJB Timer Service, the simply guarantee required by the spec is that for each
call to createTimer(), one timer is created. That's true whether the call to createTimer is made
from an application running in a cluster or not. Unfortunately, the automatic timer creation
use-case is not supported in the current version of the EJB spec. It's a feature we are
likely to add in the next version of the spec.

The typical workaround is to define a .war within the same .ear as the EJB application and
register a ServletContextListener to receive a web application initialization callback.
Within the callback, you can invoke an EJB that will create the Timer.
However, you'll also need to use the TimerService.getTimers() operation to ensure that
your timer hasn't been created before calling createTimer(). This protects against
duplicate creation on server restart and from within other server instances in the case
that the application is deployed to a cluster.

 --ken
[Message sent by forum member 'ksak' (ksak)]

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