users@glassfish.java.net

[gf-users] EJB timer question

From: NBW <emailnbw_at_gmail.com>
Date: Fri, 31 Oct 2014 11:58:03 -0400

In a Glassfish 3.1.2b23 / JavaEE 6 environment I have a Stateless
@Singleton EJB with an @Asyncrhonous method that continually loops around
performing various logic.

During this execution it may call a method on an injected EJB @Stateless
@Singleton which programmatically creates a calendar timer, if it does not
already exist in the injected TimerService, set to fire every 10s. This
'2nd' EJB also has a @Timeout @Lock(LockType.WRITE) method to handle the
timer firing.

After the Timer is created the @Asynchronous method in the '1st' EJB may
block for a period of time. When this happens the @Timer method is not
called even though enough elapsed time has passed that the timer should
have fired.

If I change the method on the '2nd' EJB which creates the programatic timer
to be @Asynchronous then this behavior does not occur and the @Timeout
method will be called even while the '1st' EJB is blocking. The same
behavior is true if instead of using programatic timers I use @Schedule
timers.

I'm surprised that programatic timers can be blocked in this way. Is this
behavior as intended?

Thanks,

-Noah