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.StartupListener,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@Component("quartz") public class QuartzComponent extends org.apache.camel.support.DefaultComponent implements org.apache.camel.ExtendedStartupListenerThis component will hold a Quartz Scheduler that will provide scheduled timer based endpoint that generate a QuartzMessage to a route.
-
-
Constructor Summary
Constructors Constructor Description QuartzComponent()QuartzComponent(org.apache.camel.CamelContext camelContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddScheduleInitTask(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.protected org.apache.camel.EndpointcreateEndpoint(String uri, String remaining, Map<String,Object> parameters)protected StringcreateInstanceName(Properties prop)protected voiddoStart()protected voiddoStartScheduler()protected voiddoStop()MapgetProperties()StringgetPropertiesFile()StringgetPropertiesRef()org.quartz.SchedulergetScheduler()org.quartz.SchedulerFactorygetSchedulerFactory()booleanisAutoStartScheduler()booleanisClustered()Is the quartz scheduler clustered?booleanisEnableJmx()booleanisIgnoreExpiredNextFireTime()booleanisInterruptJobsOnShutdown()booleanisPrefixInstanceName()booleanisPrefixJobNameWithEndpointId()voidonCamelContextFullyStarted(org.apache.camel.CamelContext context, boolean alreadyStarted)voidonCamelContextStarted(org.apache.camel.CamelContext context, boolean alreadyStarted)voidsetAutoStartScheduler(boolean autoStartScheduler)Whether or not the scheduler should be auto started.voidsetEnableJmx(boolean enableJmx)Whether to enable Quartz JMX which allows to manage the Quartz scheduler from JMX.voidsetIgnoreExpiredNextFireTime(boolean ignoreExpiredNextFireTime)Whether to ignore quartz cannot schedule a trigger because the trigger will never fire in the future.voidsetInterruptJobsOnShutdown(boolean interruptJobsOnShutdown)Whether to interrupt jobs on shutdown which forces the scheduler to shutdown quicker and attempt to interrupt any running jobs.voidsetPrefixInstanceName(boolean prefixInstanceName)Whether to prefix the Quartz Scheduler instance name with the CamelContext name.voidsetPrefixJobNameWithEndpointId(boolean prefixJobNameWithEndpointId)Whether to prefix the quartz job with the endpoint id.voidsetProperties(Map properties)Properties to configure the Quartz scheduler.voidsetPropertiesFile(String propertiesFile)File name of the properties to load from the classpathvoidsetPropertiesRef(String propertiesRef)References to an existingPropertiesorMapto lookup in the registry to use for configuring quartz.voidsetScheduler(org.quartz.Scheduler scheduler)To use the custom configured Quartz scheduler, instead of creating a new Scheduler.voidsetSchedulerFactory(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
-
-
-
-
Method Detail
-
isAutoStartScheduler
public boolean isAutoStartScheduler()
-
setAutoStartScheduler
public void setAutoStartScheduler(boolean autoStartScheduler)
Whether or not the scheduler should be auto started. This options 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 existingPropertiesorMapto 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 setRejectedExecutionExceptionas 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.SchedulerExceptionIs 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:
createEndpointin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
onCamelContextStarted
public void onCamelContextStarted(org.apache.camel.CamelContext context, boolean alreadyStarted) throws Exception- Specified by:
onCamelContextStartedin interfaceorg.apache.camel.StartupListener- Throws:
Exception
-
onCamelContextFullyStarted
public void onCamelContextFullyStarted(org.apache.camel.CamelContext context, boolean alreadyStarted) throws Exception- Specified by:
onCamelContextFullyStartedin interfaceorg.apache.camel.StartupListener- Throws:
Exception
-
-