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 forEndpointwhich creates aScheduledPollConsumer
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedScheduledPollEndpoint()protectedScheduledPollEndpoint(String endpointUri, org.apache.camel.Component component)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconfigureConsumer(org.apache.camel.Consumer consumer)voidconfigureProperties(Map<String,Object> options)protected voidconfigureScheduledPollConsumerProperties(Map<String,Object> options)protected voiddoConfigureConsumer(org.apache.camel.Consumer consumer)protected voiddoStart()protected voiddoStop()intgetBackoffErrorThreshold()intgetBackoffIdleThreshold()intgetBackoffMultiplier()longgetDefaultDelay()Gets the default delay.longgetDelay()longgetInitialDelay()org.apache.camel.spi.PollingConsumerPollStrategygetPollStrategy()longgetRepeatCount()org.apache.camel.LoggingLevelgetRunLoggingLevel()ScheduledExecutorServicegetScheduledExecutorService()ObjectgetScheduler()Map<String,Object>getSchedulerProperties()TimeUnitgetTimeUnit()booleanisGreedy()booleanisSendEmptyMessageWhenIdle()booleanisStartScheduler()booleanisUseFixedDelay()voidsetBackoffErrorThreshold(int backoffErrorThreshold)The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in.voidsetBackoffIdleThreshold(int backoffIdleThreshold)The number of subsequent idle polls that should happen before the backoffMultipler should kick-in.voidsetBackoffMultiplier(int backoffMultiplier)To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row.voidsetDelay(long delay)Milliseconds before the next poll.voidsetGreedy(boolean greedy)If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages.voidsetInitialDelay(long initialDelay)Milliseconds before the first poll starts.voidsetPollStrategy(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.voidsetRepeatCount(long repeatCount)Specifies a maximum limit of number of fires.voidsetRunLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel)The consumer logs a start/complete log line when it polls.voidsetScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)Allows for configuring a custom/shared thread pool to use for the consumer.voidsetScheduler(Object schedulerName)Allow to plugin a custom org.apache.camel.spi.ScheduledPollConsumerScheduler to use as the scheduler for firing when the polling consumer runs.voidsetSchedulerProperties(Map<String,Object> schedulerProperties)To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler.voidsetSendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle)If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead.voidsetStartScheduler(boolean startScheduler)Whether the scheduler should be auto started.voidsetTimeUnit(TimeUnit timeUnit)Time unit for initialDelay and delay options.voidsetUseFixedDelay(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:
configureConsumerin classDefaultEndpoint- Throws:
Exception
-
configureProperties
public void configureProperties(Map<String,Object> options)
- Specified by:
configurePropertiesin interfaceorg.apache.camel.Endpoint- Overrides:
configurePropertiesin 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:
doStartin classDefaultEndpoint- Throws:
Exception
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin 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.
-
-