开发者

Why is Jboss passing null Timer object to method annotated with @Timeout?

开发者 https://www.devze.com 2023-04-04 23:56 出处:网络
I have a stateless bean which manages my timer service: @Stateless @Depends(\"jboss.ha:service=HASingletonDeployer,type=Barrier\")

I have a stateless bean which manages my timer service:

@Stateless
@Depends("jboss.ha:service=HASingletonDeployer,type=Barrier")
public class TimerManagerBean implements ITimerManagerLocal {

private static final Logger log = Logger.getLogger(TimerManagerBean.class);
private @Resource
SessionContext ctx;

private @EJB ISomeEjbLocal someEjb;

public void scheduleTimer(long initialDuration, long intervalDuration, Serializable info) {
    if (info.equals(ITimerManagerLocal.TIMER_ID_1)) {
        ctx.getTimerService().createTimer(initialDuration, intervalDuration, info);
    } 
}

@Override
public void cancelTimer(Serializable info) {
    final Collection<Timer> timers = ctx.getTimerService().getTimers();
    for (final Timer timer : timers) {
        if (timer.getInfo().equals(info)) {
            log.info("Timer[info=" + info + "] found, cancelling...");
            timer.cancel();
            log.info("Timer[info=" + info + "] cancelled");
        }
    }
}

@Override
@Timeout
public void timeoutHandler(Timer timer) throws Exception {
    Serializable info = timer.getInfo();
    if (ITimerManagerLocal.TIMER_ID_1.equals(info)) {
               someEjb.doSomething(); // what happen if this throw exception?

    } 
    } 
}
}

Here is my local intefrace:

@Local
public interface ITimerManagerLocal {

public static final String TIMER_ID_1 = "TIMER_ID_1";

public void scheduleTimer(long initialDuration, long intervalDuration, Serializable info);

public void cancelTimer(Serializable info);

public void timeoutHandler(Timer timer) throws Exception;
}

I use it to create/cancel/schedule timers. This service used to work correctly for months, but now it began to pass null timer object to timeoutHandler metho开发者_开发百科d, which throws NullPointerException. This happen on each call of timeoutHandler method. I am using postgres to store timers information, not the hsdb. I think this began to happen after migrating to postgres 9, but i don't see why and may be i am wrong. Also, what happen in timeoutHandler method when timer.getInfo() throw NullPointerException (because timer is null). Where is this exception thrown? Could it prevent the correct rescheduling of the timer?

Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号