Interface ScheduledPollConsumerScheduler

All Superinterfaces:
AutoCloseable, CamelContextAware, HasCamelContext, Service, ShutdownableService

public interface ScheduledPollConsumerScheduler extends ShutdownableService, CamelContextAware
Pluggable scheduler that controls when a
invalid reference
org.apache.camel.support.ScheduledPollConsumer
wakes up to poll its source.

Polling consumers (file, FTP, mail, etc.) delegate all scheduling decisions to this SPI so that the polling trigger can be replaced without changing the consumer itself. The default implementation uses a ScheduledExecutorService with a fixed or initial delay, while the camel-quartz component provides an alternative that accepts CRON expressions for time-based firing.

A scheduler is initialized via onInit(org.apache.camel.Consumer) and then activated by calling startScheduler(), which begins firing the task registered with scheduleTask(Runnable). The consumer task itself is responsible for calling the consumer's polling logic; the scheduler only controls the firing cadence.

See Polling Consumer in the Camel user manual.

See Also:
  • Method Details

    • onInit

      void onInit(Consumer consumer)
      Initializes this ScheduledPollConsumerScheduler with the associated Consumer.
      Parameters:
      consumer - the consumer.
    • scheduleTask

      void scheduleTask(Runnable task)
      Schedules the task to run.
      Parameters:
      task - the task to run.
    • unscheduleTask

      void unscheduleTask()
      Attempts to unschedules the last task which was scheduled.

      An implementation may not implement this method.

    • startScheduler

      void startScheduler()
      Starts the scheduler.

      If the scheduler is already started, then this is a noop method call.

    • isSchedulerStarted

      boolean isSchedulerStarted()
      Whether the scheduler has been started.
      Returns:
      true if started, false otherwise.