Interface ReactiveExecutor
public interface ReactiveExecutor
SPI for plugging a custom reactive (non-blocking) dispatch engine into Camel's internal routing loop.
Camel's async routing engine decomposes message processing into a series of continuation tasks rather than blocking a
thread for the full duration of a route. This interface is the hook point that decides how those continuations are
queued and executed:
schedule(Runnable) for fair background dispatch, scheduleMain(Runnable) for
high-priority dispatch that should run as soon as possible, scheduleSync(Runnable) to run on the current
thread immediately, and scheduleQueue(Runnable) to defer to the current-thread queue (used for transactional
routing where all steps must run on the same thread).
The built-in DefaultReactiveExecutor uses a simple single-threaded loop driven by the calling thread.
Alternative implementations can delegate to Vert.x, Project Reactor, or other reactive runtimes. The factory key
FACTORY is used by FactoryFinder for discovery.
See Threading Model in the Camel user manual.- Since:
- 3.0
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanExecutes the next task (if supported by the reactive executor implementation)booleanWhether statistics is enabledvoidSchedules the task to be run (fairly)voidscheduleMain(Runnable runnable) Schedules the task to be prioritized and run asapvoidscheduleQueue(Runnable runnable) Schedules the task to be run later from the queue (current thread) This is used for routingExchangeusing transactions.voidscheduleSync(Runnable runnable) Schedules the task to run synchronously (current thread)voidsetStatisticsEnabled(boolean statisticsEnabled) To enable statistics
-
Field Details
-
FACTORY
-
-
Method Details
-
schedule
Schedules the task to be run (fairly)- Parameters:
runnable- the task
-
scheduleMain
Schedules the task to be prioritized and run asap- Parameters:
runnable- the task
-
scheduleSync
Schedules the task to run synchronously (current thread)- Parameters:
runnable- the task
-
scheduleQueue
-
executeFromQueue
boolean executeFromQueue()Executes the next task (if supported by the reactive executor implementation)- Returns:
- true if a task was executed or false if no more pending tasks
-
setStatisticsEnabled
void setStatisticsEnabled(boolean statisticsEnabled) To enable statistics -
isStatisticsEnabled
boolean isStatisticsEnabled()Whether statistics is enabled
-