Class QuartzComponent

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultComponent
org.apache.camel.component.quartz.QuartzComponent
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Component, org.apache.camel.ExtendedStartupListener, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, org.apache.camel.StartupListener, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@Component("quartz") public class QuartzComponent extends org.apache.camel.support.DefaultComponent implements org.apache.camel.ExtendedStartupListener
This component will hold a Quartz Scheduler that will provide scheduled timer based endpoint that generate a QuartzMessage to a route.
  • Field Summary

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    QuartzComponent(org.apache.camel.CamelContext camelContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a task to be executed as part of initializing and starting the scheduler; or executes the task if the scheduler has already been started.
    protected org.apache.camel.Endpoint
    createEndpoint(String uri, String remaining, Map<String,Object> parameters)
     
    protected String
     
    protected void
     
    protected void
     
    protected void
     
     
     
     
    org.quartz.Scheduler
     
    org.quartz.SchedulerFactory
     
    boolean
     
    boolean
    Is the quartz scheduler clustered?
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    void
    onCamelContextFullyStarted(org.apache.camel.CamelContext context, boolean alreadyStarted)
     
    void
    onCamelContextStarted(org.apache.camel.CamelContext context, boolean alreadyStarted)
     
    void
    setAutoStartScheduler(boolean autoStartScheduler)
    Whether the scheduler should be auto started.
    void
    setEnableJmx(boolean enableJmx)
    Whether to enable Quartz JMX which allows to manage the Quartz scheduler from JMX.
    void
    setIgnoreExpiredNextFireTime(boolean ignoreExpiredNextFireTime)
    Whether to ignore quartz cannot schedule a trigger because the trigger will never fire in the future.
    void
    setInterruptJobsOnShutdown(boolean interruptJobsOnShutdown)
    Whether to interrupt jobs on shutdown which forces the scheduler to shutdown quicker and attempt to interrupt any running jobs.
    void
    setPrefixInstanceName(boolean prefixInstanceName)
    Whether to prefix the Quartz Scheduler instance name with the CamelContext name.
    void
    setPrefixJobNameWithEndpointId(boolean prefixJobNameWithEndpointId)
    Whether to prefix the quartz job with the endpoint id.
    void
    setProperties(Map properties)
    Properties to configure the Quartz scheduler.
    void
    setPropertiesFile(String propertiesFile)
    File name of the properties to load from the classpath
    void
    setPropertiesRef(String propertiesRef)
    References to an existing Properties or Map to lookup in the registry to use for configuring quartz.
    void
    setScheduler(org.quartz.Scheduler scheduler)
    To use the custom configured Quartz scheduler, instead of creating a new Scheduler.
    void
    setSchedulerFactory(org.quartz.SchedulerFactory schedulerFactory)
    To use the custom SchedulerFactory which is used to create the Scheduler.

    Methods inherited from class org.apache.camel.support.DefaultComponent

    afterConfiguration, createEndpoint, createEndpoint, doBuild, doInit, getAndRemoveOrResolveReferenceParameter, getAndRemoveOrResolveReferenceParameter, getAndRemoveParameter, getAndRemoveParameter, getCamelContext, getComponentPropertyConfigurer, getDefaultName, getEndpointPropertyConfigurer, getExtension, getSupportedExtensions, ifStartsWithReturnRemainder, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, registerExtension, registerExtension, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceParameter, resolveAndRemoveReferenceParameter, resolveRawParameterValues, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setLazyStartProducer, setProperties, setProperties, setProperties, useIntrospectionOnEndpoint, useRawUri, validateParameters, validateURI

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StartupListener

    onCamelContextStarting

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Constructor Details

    • QuartzComponent

      public QuartzComponent()
    • QuartzComponent

      public QuartzComponent(org.apache.camel.CamelContext camelContext)
  • Method Details

    • isAutoStartScheduler

      public boolean isAutoStartScheduler()
    • setAutoStartScheduler

      public void setAutoStartScheduler(boolean autoStartScheduler)
      Whether the scheduler should be auto started.

      This option is default true

    • isPrefixJobNameWithEndpointId

      public boolean isPrefixJobNameWithEndpointId()
    • setPrefixJobNameWithEndpointId

      public void setPrefixJobNameWithEndpointId(boolean prefixJobNameWithEndpointId)
      Whether to prefix the quartz job with the endpoint id.

      This option is default false.

    • isEnableJmx

      public boolean isEnableJmx()
    • setEnableJmx

      public void setEnableJmx(boolean enableJmx)
      Whether to enable Quartz JMX which allows to manage the Quartz scheduler from JMX.

      This options is default true

    • getPropertiesRef

      public String getPropertiesRef()
    • setPropertiesRef

      public void setPropertiesRef(String propertiesRef)
      References to an existing Properties or Map to lookup in the registry to use for configuring quartz.
    • getProperties

      public Map getProperties()
    • setProperties

      public void setProperties(Map properties)
      Properties to configure the Quartz scheduler.
    • getPropertiesFile

      public String getPropertiesFile()
    • setPropertiesFile

      public void setPropertiesFile(String propertiesFile)
      File name of the properties to load from the classpath
    • isPrefixInstanceName

      public boolean isPrefixInstanceName()
    • setPrefixInstanceName

      public void setPrefixInstanceName(boolean prefixInstanceName)
      Whether to prefix the Quartz Scheduler instance name with the CamelContext name.

      This is enabled by default, to let each CamelContext use its own Quartz scheduler instance by default. You can set this option to false to reuse Quartz scheduler instances between multiple CamelContext's.

    • isInterruptJobsOnShutdown

      public boolean isInterruptJobsOnShutdown()
    • setInterruptJobsOnShutdown

      public void setInterruptJobsOnShutdown(boolean interruptJobsOnShutdown)
      Whether to interrupt jobs on shutdown which forces the scheduler to shutdown quicker and attempt to interrupt any running jobs. If this is enabled then any running jobs can fail due to being interrupted. When a job is interrupted then Camel will mark the exchange to stop continue routing and set RejectedExecutionException as caused exception. Therefore use this with care, as its often better to allow Camel jobs to complete and shutdown gracefully.
    • isIgnoreExpiredNextFireTime

      public boolean isIgnoreExpiredNextFireTime()
    • setIgnoreExpiredNextFireTime

      public void setIgnoreExpiredNextFireTime(boolean ignoreExpiredNextFireTime)
      Whether to ignore quartz cannot schedule a trigger because the trigger will never fire in the future. This can happen when using a cron trigger that are configured to only run in the past. By default, Quartz will fail to schedule the trigger and therefore fail to start the Camel route. You can set this to true which then logs a WARN and then ignore the problem, meaning that the route will never fire in the future.
    • getSchedulerFactory

      public org.quartz.SchedulerFactory getSchedulerFactory()
    • createInstanceName

      protected String createInstanceName(Properties prop)
    • isClustered

      public boolean isClustered() throws org.quartz.SchedulerException
      Is the quartz scheduler clustered?
      Throws:
      org.quartz.SchedulerException
    • setSchedulerFactory

      public void setSchedulerFactory(org.quartz.SchedulerFactory schedulerFactory)
      To use the custom SchedulerFactory which is used to create the Scheduler.
    • getScheduler

      public org.quartz.Scheduler getScheduler()
    • addScheduleInitTask

      public void addScheduleInitTask(SchedulerInitTask task)
      Adds a task to be executed as part of initializing and starting the scheduler; or executes the task if the scheduler has already been started.
    • setScheduler

      public void setScheduler(org.quartz.Scheduler scheduler)
      To use the custom configured Quartz scheduler, instead of creating a new Scheduler.
    • createEndpoint

      protected org.apache.camel.Endpoint createEndpoint(String uri, String remaining, Map<String,Object> parameters) throws Exception
      Specified by:
      createEndpoint in class org.apache.camel.support.DefaultComponent
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • onCamelContextStarted

      public void onCamelContextStarted(org.apache.camel.CamelContext context, boolean alreadyStarted) throws Exception
      Specified by:
      onCamelContextStarted in interface org.apache.camel.StartupListener
      Throws:
      Exception
    • onCamelContextFullyStarted

      public void onCamelContextFullyStarted(org.apache.camel.CamelContext context, boolean alreadyStarted) throws Exception
      Specified by:
      onCamelContextFullyStarted in interface org.apache.camel.StartupListener
      Throws:
      Exception
    • doStartScheduler

      protected void doStartScheduler() throws Exception
      Throws:
      Exception