I want to wake up ejb timer on every two second. For that I am creating ScheulerExpression as the code below...
package com.fks.nclp.ejb.timer.service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.LocalBean;
import javax.ejb.ScheduleExpression;
import javax.ejb.Startup;
import javax.ejb.Timeout;
import javax.ejb.TimerConfig;
import javax.ejb.TimerService;
import com.sun.jersey.spi.resource.Singleton;
@LocalBean
@Singleton
@Startup
public class HelloWorldService {
@Resource
TimerService timerService;
@PostConstruct
public void initialize(){
System.out.println("EJB PRE CONSTRUCT");
ScheduleExpression expression = new ScheduleExpression();
//SET TIMER TO 2 SEC
expression.hour("*");
expression.minute("*");
expression.second("*/2");
timerService.createCalendarTimer(expression,new TimerConfig("TimerScheduler",false));
}
@Timeout
public void startTimer(){
System.out.println("THIS IS EJB TIMER PROGRAM");
}
}
But ... the EJB container is not waking up the scheduler after every two second.
Any Suggestion on this ? How can I make the expression to wake up every two second.
Thanks, Gunjan.