users@glassfish.java.net

Re: How to enable EJB Timer on GlassFish Cluster?

From: <glassfish_at_javadesktop.org>
Date: Tue, 04 May 2010 06:32:03 PDT

My EJB timer code:
********************************************
import java.util.Date;
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;

@Stateless
public class TimerBean implements TimerLocal {

    @Resource SessionContext context;

    public void setupTimer() {
        Date timerStart = new Date();
        TimerService timerService = context.getTimerService();
        timerService.createTimer(0, 500, timerStart); // every 5 seconds
    }

    @Timeout
    public void timerAction(Timer timer) {
        System.out.println("Time: " + (new Date()));
    }
}
************************************
Glassfish Console->Configuration->EJB Container->EJB Timer Service->Timer Datasource

The code works properly if "Timer Datasource" is set as default.

The code doesn't work and gives "EJB Timer Service not available" if "Timer Datasource" is changed to the data source for the external ejbTimerPool.

Yet I can ping the ejbTimerPool successfully!
Could you tell what could went wrong?
[Message sent by forum member 'raejean99']

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