Package org.apache.camel.support
Class ScheduledPollEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.support.ScheduledPollEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
- Direct Known Subclasses:
AbstractApiEndpoint
,DefaultPollingEndpoint
public abstract class ScheduledPollEndpoint extends DefaultEndpoint
A base class forEndpoint
which creates aScheduledPollConsumer
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ScheduledPollEndpoint()
protected
ScheduledPollEndpoint(String endpointUri, org.apache.camel.Component component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configureConsumer(org.apache.camel.Consumer consumer)
void
configureProperties(Map<String,Object> options)
protected void
configureScheduledPollConsumerProperties(Map<String,Object> options)
protected void
doConfigureConsumer(org.apache.camel.Consumer consumer)
protected void
doStart()
protected void
doStop()
int
getBackoffErrorThreshold()
int
getBackoffIdleThreshold()
int
getBackoffMultiplier()
long
getDefaultDelay()
Gets the default delay.long
getDelay()
long
getInitialDelay()
org.apache.camel.spi.PollingConsumerPollStrategy
getPollStrategy()
long
getRepeatCount()
org.apache.camel.LoggingLevel
getRunLoggingLevel()
ScheduledExecutorService
getScheduledExecutorService()
Object
getScheduler()
Map<String,Object>
getSchedulerProperties()
TimeUnit
getTimeUnit()
boolean
isGreedy()
boolean
isSendEmptyMessageWhenIdle()
boolean
isStartScheduler()
boolean
isUseFixedDelay()
void
setBackoffErrorThreshold(int backoffErrorThreshold)
The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.void
setBackoffIdleThreshold(int backoffIdleThreshold)
The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.void
setBackoffMultiplier(int backoffMultiplier)
To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row.void
setDelay(long delay)
Milliseconds before the next poll.void
setGreedy(boolean greedy)
If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages.void
setInitialDelay(long initialDelay)
Milliseconds before the first poll starts.void
setPollStrategy(org.apache.camel.spi.PollingConsumerPollStrategy pollStrategy)
A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel.void
setRepeatCount(long repeatCount)
Specifies a maximum limit of number of fires.void
setRunLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel)
The consumer logs a start/complete log line when it polls.void
setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
Allows for configuring a custom/shared thread pool to use for the consumer.void
setScheduler(Object schedulerName)
Allow to plugin a custom org.apache.camel.spi.ScheduledPollConsumerScheduler to use as the scheduler for firing when the polling consumer runs.void
setSchedulerProperties(Map<String,Object> schedulerProperties)
To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler.void
setSendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle)
If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead.void
setStartScheduler(boolean startScheduler)
Whether the scheduler should be auto started.void
setTimeUnit(TimeUnit timeUnit)
Time unit for initialDelay and delay options.void
setUseFixedDelay(boolean useFixedDelay)
Controls if fixed delay or fixed rate is used.-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureExchange, configurePollingConsumer, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, 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, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.camel.Endpoint
createConsumer, createProducer, getEndpointBaseUri, isSingletonProducer
-
-
-
-
Constructor Detail
-
ScheduledPollEndpoint
protected ScheduledPollEndpoint(String endpointUri, org.apache.camel.Component component)
-
ScheduledPollEndpoint
protected ScheduledPollEndpoint()
-
-
Method Detail
-
configureConsumer
protected void configureConsumer(org.apache.camel.Consumer consumer) throws Exception
- Overrides:
configureConsumer
in classDefaultEndpoint
- Throws:
Exception
-
configureProperties
public void configureProperties(Map<String,Object> options)
- Specified by:
configureProperties
in interfaceorg.apache.camel.Endpoint
- Overrides:
configureProperties
in classDefaultEndpoint
-
configureScheduledPollConsumerProperties
protected void configureScheduledPollConsumerProperties(Map<String,Object> options)
-
doConfigureConsumer
protected void doConfigureConsumer(org.apache.camel.Consumer consumer)
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classDefaultEndpoint
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classDefaultEndpoint
- Throws:
Exception
-
isStartScheduler
public boolean isStartScheduler()
-
setStartScheduler
public void setStartScheduler(boolean startScheduler)
Whether the scheduler should be auto started.
-
getInitialDelay
public long getInitialDelay()
-
setInitialDelay
public void setInitialDelay(long initialDelay)
Milliseconds before the first poll starts. The default value is 1000.
-
getDelay
public long getDelay()
-
setDelay
public void setDelay(long delay)
Milliseconds before the next poll. The default value is 500.
-
getDefaultDelay
public long getDefaultDelay()
Gets the default delay.
-
getTimeUnit
public TimeUnit getTimeUnit()
-
setTimeUnit
public void setTimeUnit(TimeUnit timeUnit)
Time unit for initialDelay and delay options.
-
isUseFixedDelay
public boolean isUseFixedDelay()
-
setUseFixedDelay
public void setUseFixedDelay(boolean useFixedDelay)
Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details.
-
getPollStrategy
public org.apache.camel.spi.PollingConsumerPollStrategy getPollStrategy()
-
setPollStrategy
public void setPollStrategy(org.apache.camel.spi.PollingConsumerPollStrategy pollStrategy)
A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel. In other words the error occurred while the polling was gathering information, for instance access to a file network failed so Camel cannot access it to scan for files. The default implementation will log the caused exception at WARN level and ignore it.
-
getRunLoggingLevel
public org.apache.camel.LoggingLevel getRunLoggingLevel()
-
setRunLoggingLevel
public void setRunLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel)
The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that.
-
isSendEmptyMessageWhenIdle
public boolean isSendEmptyMessageWhenIdle()
-
setSendEmptyMessageWhenIdle
public void setSendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle)
If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead.
-
isGreedy
public boolean isGreedy()
-
setGreedy
public void setGreedy(boolean greedy)
If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages.
-
setScheduler
public void setScheduler(Object schedulerName)
Allow to plugin a custom org.apache.camel.spi.ScheduledPollConsumerScheduler to use as the scheduler for firing when the polling consumer runs. This option is used for referring to one of the built-in schedulers either spring, or quartz. Using none refers to no scheduler to be used. Notice: If using a custom scheduler then the options for initialDelay, useFixedDelay, timeUnit, and scheduledExecutorService may not be in use. Use the text quartz to refer to use the Quartz scheduler; and use the text spring to use the Spring based; and use the text #myScheduler to refer to a custom scheduler by its id in the Registry. See Quartz page for an example.
-
getScheduler
public Object getScheduler()
-
setSchedulerProperties
public void setSchedulerProperties(Map<String,Object> schedulerProperties)
To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler.
-
getScheduledExecutorService
public ScheduledExecutorService getScheduledExecutorService()
-
setScheduledExecutorService
public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool. This option allows you to share a thread pool among multiple consumers.
-
getBackoffMultiplier
public int getBackoffMultiplier()
-
setBackoffMultiplier
public void setBackoffMultiplier(int backoffMultiplier)
To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured.
-
getBackoffIdleThreshold
public int getBackoffIdleThreshold()
-
setBackoffIdleThreshold
public void setBackoffIdleThreshold(int backoffIdleThreshold)
The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.
-
getBackoffErrorThreshold
public int getBackoffErrorThreshold()
-
setBackoffErrorThreshold
public void setBackoffErrorThreshold(int backoffErrorThreshold)
The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.
-
getRepeatCount
public long getRepeatCount()
-
setRepeatCount
public void setRepeatCount(long repeatCount)
Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever.
-
-