Hi
I created a SLSB timer service. On calling the scheduleTimer() method from my testcase the
timer is created but the timeout method is executed multiple times. It waits for the
specified duration(1 min) and again executes multiple times. is there any specific reason.
I thought it might be because of pooling so I used the PoolClass to limit the pool size to
1. Below is the EJB code
***********************************************************
import java.rmi.RemoteException;
import java.util.Date;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.EJBException;
import javax.ejb.Remote;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.jws.WebService;
import org.apache.log4j.Logger;
import org.jboss.annotation.ejb.PoolClass;
@Stateless
@PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1)
public class HealthCheckTimerBean implements HealthCheckTimer
{
private static Logger log = Logger.getLogger(HealthCheckTimerBean.class);
private static @Resource SessionContext ctx;
public void scheduleTimer() throws RemoteException
{
long interval =60000;
System.out.println("HC Interval: "+interval);
if(interval<1)
{
log.error("Cannot create Health Check timer - HC interval not
defined");
throw new RemoteException("Cannot create Health Check timer - HC interval not
defined");
}
ctx.getTimerService().createTimer(interval,interval, "Probe Health Check
Timer");
}
@Timeout
public void timeoutHandler(Timer timer)throws RemoteException
{
System.out.println("---------------------");
System.out.println("* Received Timer event: " + timer.getInfo());
System.out.println("---------------------");
}
}
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4215383#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...