Jean-Philippe Legault opened SPR-14909 and commented

Allowing ReschedulingRunnable to receive a TriggerContext on creation (instead of always creating a new one) and updating the TaskScheduler interface to add a new signature "ScheduledFuture<?> schedule(Runnable task, Trigger trigger, TriggerContext initialContext);" would allow me to resume a task that was created with a Trigger trough the TaskScheduler.

The current behavior is that a job scheduled with the TaskScheduler with the CronTrigger "0 0 0 /2 * " task will run in 2 days from now, no matter what. Updating this would allow me to resume a task.

As an example, if I have the CronTrigger "0 0 0 /2 * ", and I know that the last time this task ran was yesterday, I could setup an initial TriggerContext to be passed along the TaskScheduler and used at the creation of the first ReschedulingRunnable instead of using a new one. The following ReschedulingRunnable that will be created would use the current Context, which mean the behavior would not change after the first pass.


Issue Links: - #17987 Add ListenableScheduledFuture support to TaskScheduler

Comment From: jhoeller

I'm introducing static factory methods on CronTrigger with support for a resumptionTimestamp, coming with traditional semantics as resumeLenientExecution method (calculating the first trigger firing from the given timestamp but every subsequent firing on the previous completion time) and also with fixed-execution semantics as resumeFixedExecution (not missing any original trigger firing even on resumption, calculating subsequent firings from the previous scheduled time).