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.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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
protected String
createInstanceName
(Properties prop) protected void
doStart()
protected void
protected void
doStop()
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 or not 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 classpathvoid
setPropertiesRef
(String propertiesRef) References to an existingProperties
orMap
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 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
-
setPropertiesRef
References to an existingProperties
orMap
to lookup in the registry to use for configuring quartz. -
getProperties
-
setProperties
Properties to configure the Quartz scheduler. -
getPropertiesFile
-
setPropertiesFile
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 setRejectedExecutionException
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
-
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
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 classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-
onCamelContextStarted
public void onCamelContextStarted(org.apache.camel.CamelContext context, boolean alreadyStarted) throws Exception - Specified by:
onCamelContextStarted
in interfaceorg.apache.camel.StartupListener
- Throws:
Exception
-
onCamelContextFullyStarted
public void onCamelContextFullyStarted(org.apache.camel.CamelContext context, boolean alreadyStarted) throws Exception - Specified by:
onCamelContextFullyStarted
in interfaceorg.apache.camel.StartupListener
- Throws:
Exception
-
doStartScheduler
- Throws:
Exception
-