Cancelling timer does not kill timer thread if timer is within transaction.
There was a post already on this forum - but it still remains unanswered. Let me rise this issue up again:
according to org.jboss.ejb.txttimer.TimerImpl code timer can be killed in 3 and only 3 cases:
1: When we are changing timer state and timer state is EXPIRED.
private void setTimerState(int state)
{
log.debug("setTimerState: " + TIMER_STATES[state]);
timerState = state;
// get rid of the expired timer
if (timerState == EXPIRED)
killTimer();
}
private void cancelInTx()
{
TimerServiceImpl timerService = getTimerService();
if (timerService.getTransaction() != null)
setTimerState(CANCELED_IN_TX);
else
killTimer();
}
public void afterCompletion(int status)
{
if (status == Status.STATUS_COMMITTED)
{
// ... code is omitted for the sake of space saving
}
if (status == Status.STATUS_ROLLEDBACK)
{
log.debug("rollback: " + this);
if (timerState == STARTED_IN_TX)
killTimer();
else if (timerState == CANCELED_IN_TX)
setTimerState(ACTIVE);
else if (timerState == IN_TIMEOUT)
// ... code is omitted for the sake of space saving
}
}