webspherewebsphere-9ejb-timer

Is it possible to skip any missed @schedule events instead of catching them up?


Using Websphere 9, I have a schedule service, e.g:

@Schedule(minute="30", hour="6-20", dayOfWeek="Mon-Fri",
          dayOfMonth="*", month="*", year="*", info="TimerName", persistent=true)
public void scheduledTimeout(final Timer t)
{
    // do something
}

It's persistent so that it will only trigger on one of the nodes on the cluster.

If for some reason the timer runs long, or otherwise doesn't run; I don't want WebSphere to try again - I just want it to wait until the next trigger.

Is this possible?


Solution

  • I don't see any relevant settings in WAS v9 in regard of this, as what EJB spec says it is responsibility of bean provider to handle any out of sequence or additional events. So you would have to implement that logic in your bean using timer parameter.

    However you could consider WebSphere/Open Liberty server which adds additional configuration (see details here https://github.com/OpenLiberty/open-liberty/issues/10563) And allows you for example to specify what to do which such events:

    New missedPersistentTimerAction element will have the following 2 options:

    ALL The timeout method is invoked immediately for all missed expirations. When multiple expirations have been missed for the same timer, each invocation will occur synchronously until all missed expirations have been processed, then the timer will resume with the next future expiration.

    ALL is the current behavior, and will be the default when failover is not enabled.

    ONCE The timeout method is invoked once immediately. All other missed expirations are skipped and the timer will resume with the next future expiration.

    ONCE will be the default behavior when failover is enabled. This is the minimal level of support required by the specification.

    When the timer runs on server start, calling getNextTimeout() will return the next timeout in the future, accounting for all the expirations that will be skipped, not the next timeout based on the missed expiration (i.e. so not a time in the past)

    Note: Does not apply to single action timers. Single action timers will always run once on server start, and then removed.