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
    Modifier and Type
    Field
    Description
    static final String
    Service factory key.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Executes the next task (if supported by the reactive executor implementation)
    boolean
    Whether statistics is enabled
    void
    schedule(Runnable runnable)
    Schedules the task to be run (fairly)
    void
    Schedules the task to be prioritized and run asap
    void
    Schedules the task to be run later from the queue (current thread) This is used for routing Exchange using transactions.
    void
    Schedules the task to run synchronously (current thread)
    void
    setStatisticsEnabled(boolean statisticsEnabled)
    To enable statistics
  • Field Details

  • Method Details

    • schedule

      void schedule(Runnable runnable)
      Schedules the task to be run (fairly)
      Parameters:
      runnable - the task
    • scheduleMain

      void scheduleMain(Runnable runnable)
      Schedules the task to be prioritized and run asap
      Parameters:
      runnable - the task
    • scheduleSync

      void scheduleSync(Runnable runnable)
      Schedules the task to run synchronously (current thread)
      Parameters:
      runnable - the task
    • scheduleQueue

      void scheduleQueue(Runnable runnable)
      Schedules the task to be run later from the queue (current thread) This is used for routing Exchange using transactions.
      Parameters:
      runnable - the task
    • 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