Hi, Related to TimerService, can I define two Timer instances and bind each timer to a specific (different) method annotated @Timeout in the same EJB?
Thanks, Rod
Hi, Related to TimerService, can I define two Timer instances and bind each timer to a specific (different) method annotated @Timeout in the same EJB?
Thanks, Rod
Not really.
However, you can define 2 timers
ctx.getTimerService().createTimer(1000, 1000, "timerA");
ctx.getTimerService().createTimer(1000, 1000, "timerB");
and have one timeout method to handle the timeout of both timers.
@Timeout
public void handleTimeout(Timer timer) {
String info = (String)timer.getInfo();
if ( "timerA".equals(info) { handleTimerEventA(); }
else if ( "timerB".equals(info) { handleTimerEventB(); }
}