Interface PeriodTaskScheduler


public interface PeriodTaskScheduler
A shared scheduler to run small period tasks, such as updating internal statistics, or for custom components to have a background task. For example the AWS vault is using this to periodically check for secrets refreshed in AWS to trigger Camel to reload to use the updated secrets.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    Gets an existing task by a given type, assuming there is only one task of the given type.
    void
    Schedules the task once so the task keeps running always.
    void
    schedulePeriodTask(Runnable task, long period)
    Schedules the period task.
  • Method Details

    • schedulePeriodTask

      void schedulePeriodTask(Runnable task, long period)
      Schedules the period task.
      Parameters:
      task - the period task (the task can extend ServiceSupport to have lifecycle)
      period - the interval (approximate) in millis, between running the task
    • scheduledTask

      void scheduledTask(Runnable task)
      Schedules the task once so the task keeps running always. This is to be used for tasks that is not triggered in periods, but need to run forever.
      Parameters:
      task - the task (the task can extend ServiceSupport to have lifecycle)
    • getTaskByType

      <T> T getTaskByType(Class<T> type)
      Gets an existing task by a given type, assuming there is only one task of the given type.
      Parameters:
      type - the type of the task
      Returns:
      the task, or null if no tasks exists