Package org.apache.camel.spi
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 TypeMethodDescription<T> T
getTaskByType
(Class<T> type) Gets an existing task by a given type, assuming there is only one task of the given type.void
scheduledTask
(Runnable task) Schedules the task once so the task keeps running always.void
schedulePeriodTask
(Runnable task, long period) Schedules the period task.
-
Method Details
-
schedulePeriodTask
Schedules the period task.- Parameters:
task
- the period task (the task can extendServiceSupport
to have lifecycle)period
- the interval (approximate) in millis, between running the task
-
scheduledTask
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 extendServiceSupport
to have lifecycle)
-
getTaskByType
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
-