0

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?

simonalexander2005
  • 4,338
  • 4
  • 48
  • 92

1 Answers1

1

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.

Gas
  • 17,601
  • 4
  • 46
  • 93
  • Thanks, that's great, but I don't get to choose the application server. You say I need to check within the `@Schedule` method itself - is there any way to tell if this is on-time or catching up? – simonalexander2005 Oct 24 '22 at 09:36
  • @simonalexander2005 unfortunately no easy way to do it. You would have to store last execution and compare it with next events to see if they should be skipped based on your schedule. See these threads: https://stackoverflow.com/questions/25929097/java-ee-7-get-schedule-date-when-is-set-to-persistent-true https://stackoverflow.com/questions/28310894/how-to-get-ejb-schedule-expired-date-time – Gas Oct 24 '22 at 10:31
  • Thanks. Could you put that into the answer so it doesn't get lost if the comments are removed? – simonalexander2005 Nov 03 '22 at 10:44