I have an application working with TimerService, I am creating a few timers to run specific tasks. It is working fine. However, I am noticing some delay in the timeouts. I have a timeout "A" scheduled to run every 10 minutes and another "B" to run every 3 minutes. If "A" takes 5 minutes to run, "B" only will run after "A" ends, causing a 2 minutes delay.It is a problem, because the things are not ready when it supposed to be. My question is, if there is a way to TimerService run simultaneously. The pieces of code that I'm using is below. I appreciate any help.
Schedule creation:
// Every schedule extend from this class.
public abstract class Schedule {
@Resource
private TimerService timerService;
public void start() {
TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo(name);
timerConfig.setPersistent(false);
timerService
.createCalendarTimer(this.calendarSchedule, timerConfig);
}
}
Schedule Implementation:
@Named
@Stateless
public class MyScheduleEJB extends Schedule {
@Timeout
public void timeout(Timer timer) {
// do the work
}
}