Package org.apache.camel.util.backoff
Class SimpleBackOffTimer
java.lang.Object
org.apache.camel.util.backoff.SimpleBackOffTimer
- All Implemented Interfaces:
Closeable
,AutoCloseable
,BackOffTimer
A simple timer utility that use a linked
BackOff
to determine when a task should be executed.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.util.backoff.BackOffTimer
BackOffTimer.Task
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleBackOffTimer
(String name, ScheduledExecutorService scheduler) SimpleBackOffTimer
(ScheduledExecutorService scheduler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Stops and closes this timer.getName()
Gets the name of this timer.getTasks()
Access to unmodifiable set of all the tasksvoid
remove
(BackOffTimer.Task task) Removes the taskschedule
(BackOff backOff, ThrowingFunction<BackOffTimer.Task, Boolean, Exception> function) Schedule the given function/task to be executed some time in the future according to the given backOff.int
size()
Number of tasks
-
Constructor Details
-
SimpleBackOffTimer
-
SimpleBackOffTimer
-
-
Method Details
-
schedule
public BackOffTimer.Task schedule(BackOff backOff, ThrowingFunction<BackOffTimer.Task, Boolean, Exception> function) Schedule the given function/task to be executed some time in the future according to the given backOff.- Specified by:
schedule
in interfaceBackOffTimer
- Parameters:
backOff
- the settings for how often to run the taskfunction
- the function to call for each run- Returns:
- the task
-
getName
Gets the name of this timer.- Specified by:
getName
in interfaceBackOffTimer
-
remove
Removes the task- Specified by:
remove
in interfaceBackOffTimer
-
getTasks
Access to unmodifiable set of all the tasks- Specified by:
getTasks
in interfaceBackOffTimer
-
size
Number of tasks- Specified by:
size
in interfaceBackOffTimer
-
close
Stops and closes this timer.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-