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 Summary

    Constructors
    Constructor
    Description
    DueDateChecker(long timerResolution, boolean scheduleAsync, Function<TaskResultBuilder,Long> visitor)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Callback which is called when StreamProcessor is on closing phase.
    void
    Callback which is called when the StreamProcessor failed, during startup or processing.
    void
    Callback which is called when the processing is paused, will only called after onRecovered was called before.
    void
    Callback after reprocessing was successful and before regular processing begins
    void
    Callback which is called when the processing is resumed, will only called after onPaused was called before.
    void
    schedule(long dueDate)
    Schedules the next execution of the checker and stores it in nextExecution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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)
      Description copied from interface: StreamProcessorLifecycleAware
      Callback after reprocessing was successful and before regular processing begins
      Specified by:
      onRecovered in interface StreamProcessorLifecycleAware
    • onClose

      public void onClose()
      Description copied from interface: StreamProcessorLifecycleAware
      Callback which is called when StreamProcessor is on closing phase.
      Specified by:
      onClose in interface StreamProcessorLifecycleAware
    • onFailed

      public void onFailed()
      Description copied from interface: StreamProcessorLifecycleAware
      Callback which is called when the StreamProcessor failed, during startup or processing.
      Specified by:
      onFailed in interface StreamProcessorLifecycleAware
    • onPaused

      public void onPaused()
      Description copied from interface: StreamProcessorLifecycleAware
      Callback which is called when the processing is paused, will only called after onRecovered was called before.
      Specified by:
      onPaused in interface StreamProcessorLifecycleAware
    • onResumed

      public void onResumed()
      Description copied from interface: StreamProcessorLifecycleAware
      Callback which is called when the processing is resumed, will only called after onPaused was called before.
      Specified by:
      onResumed in interface StreamProcessorLifecycleAware