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. Currently it support Cron and Simple trigger scheduling type.
-
-
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 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.protected org.apache.camel.Endpoint
createEndpoint(String uri, String remaining, Map<String,Object> parameters)
protected String
createInstanceName(Properties prop)
protected void
doStart()
protected void
doStartScheduler()
protected void
doStop()
Map
getProperties()
String
getPropertiesFile()
String
getPropertiesRef()
org.quartz.Scheduler
getScheduler()
org.quartz.SchedulerFactory
getSchedulerFactory()
boolean
isAutoStartScheduler()
boolean
isClustered()
Is the quartz scheduler clustered?boolean
isEnableJmx()
boolean
isInterruptJobsOnShutdown()
boolean
isPrefixInstanceName()
boolean
isPrefixJobNameWithEndpointId()
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
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
-
-
-
-
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 existingProperties
orMap
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 setRejectedExecutionException
as caused exception. Therefore use this with care, as its often better to allow Camel jobs to complete and shutdown gracefully.
-
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 classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.DefaultComponent
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- 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
-
-