Class DueDateChecker

java.lang.Object
io.camunda.zeebe.engine.processing.scheduled.DueDateChecker
All Implemented Interfaces:
StreamProcessorLifecycleAware

public final class DueDateChecker extends Object implements StreamProcessorLifecycleAware
The Due Date Checker is a special purpose checker (for due date related tasks) that doesn't execute periodically but can be scheduled to run at a specific due date, i.e. it can idle for extended periods of time and only runs when needed.

This class is thread safe and can be used concurrently. However, it cannot entirely prevent that multiple executions are scheduled. See the comment in execute(TaskResultBuilder) for details.

  • Constructor Details

    • DueDateChecker

      public DueDateChecker(long timerResolution, boolean scheduleAsync, Function<TaskResultBuilder,Long> visitor)
      Parameters:
      timerResolution - The resolution in ms for the timer
      scheduleAsync - Whether to schedule the execution happens asynchronously or not
      visitor - Function that runs the task and returns the next due date or -1 if there is none
  • Method Details

    • schedule

      public void schedule(long dueDate)
      Schedules the next execution of the checker and stores it in nextExecution.

      When called it guarantees that there is an execution scheduled at or before the provided due date within the timerResolution.

      If there is no execution scheduled, it always schedules a new one. If there is already an execution scheduled for a later time (within the timer resolution), that execution is cancelled and replaced by the new one. In all other cases, no new execution is scheduled.

      It is guaranteed that the next execution is scheduled at least timerResolution ms into the future. For example when the due date is in the past, now or in the very near future. This is to prevent the checker from being immediately rescheduled and thus not giving any other tasks a chance to run.

      This method is thread safe and can be called concurrently. On concurrent scheduling, this execution is cancelled and rescheduled.

      Parameters:
      dueDate - The due date for the next execution
    • onRecovered

      public void onRecovered(ReadonlyStreamProcessorContext processingContext)
      Specified by:
      onRecovered in interface StreamProcessorLifecycleAware
    • onClose

      public void onClose()
      Specified by:
      onClose in interface StreamProcessorLifecycleAware
    • onFailed

      public void onFailed()
      Specified by:
      onFailed in interface StreamProcessorLifecycleAware
    • onPaused

      public void onPaused()
      Specified by:
      onPaused in interface StreamProcessorLifecycleAware
    • onResumed

      public void onResumed()
      Specified by:
      onResumed in interface StreamProcessorLifecycleAware