Package org.apache.camel.support.task
Interface BlockingTask
- All Superinterfaces:
Task
- All Known Implementing Classes:
BackgroundTask
,ForegroundTask
Defines a task that blocks the code execution when ran. The task under execution must be thread-safe.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.support.task.Task
Task.Status
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether the task has been submitted for running (the state of the task can be waiting for next run etc).boolean
run
(org.apache.camel.CamelContext camelContext, BooleanSupplier supplier) Run the taskdefault <T> boolean
Run the taskMethods inherited from interface org.apache.camel.support.task.Task
elapsed, getCurrentDelay, getCurrentElapsedTime, getException, getFirstAttemptTime, getLastAttemptTime, getName, getNextAttemptTime, getStatus, iteration
-
Method Details
-
run
default <T> boolean run(org.apache.camel.CamelContext camelContext, Predicate<T> predicate, T payload) throws TaskRunFailureException Run the task- Type Parameters:
T
- The type of the payload passed to the predicate when testing the task- Parameters:
camelContext
- the camel contextpredicate
- the task as a predicate. The result of the predicate is used to check if the task has completed or not. The predicate must return true if the execution has completed or false otherwise. Failures on the task should be handled on the predicate using the payload as wrapper for In/Out if necessarypayload
- a payload to be passed to the task- Returns:
- true if the task has completed successfully or false if: 1) the budget is exhausted or 2) the task was interrupted.
- Throws:
TaskRunFailureException
- is thrown to provide information why the last run failed, but the task should keep continue
-
run
boolean run(org.apache.camel.CamelContext camelContext, BooleanSupplier supplier) throws TaskRunFailureException Run the task- Parameters:
camelContext
- the camel contextsupplier
- the task as a boolean supplier. The result is used to check if the task has completed or not. The supplier must return true if the execution has completed or false otherwise.- Returns:
- true if the task has completed successfully or false if: 1) the budget is exhausted or 2) the task was interrupted.
- Throws:
TaskRunFailureException
- is thrown to provide information why the last run failed, but the task should keep continue
-
isRunning
boolean isRunning()Whether the task has been submitted for running (the state of the task can be waiting for next run etc).- Returns:
- true if the run method has been called.
-