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.ComponentAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasCamelContext
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
- Direct Known Subclasses:
AbstractApiEndpoint
,DefaultPollingEndpoint
A base class for
Endpoint
which creates a ScheduledPollConsumer
-
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
ConstructorsModifierConstructorDescriptionprotected
protected
ScheduledPollEndpoint
(String endpointUri, org.apache.camel.Component component) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureConsumer
(org.apache.camel.Consumer consumer) void
configureProperties
(Map<String, Object> options) protected void
protected void
doConfigureConsumer
(org.apache.camel.Consumer consumer) int
int
int
long
Gets the default delay.long
getDelay()
long
org.apache.camel.spi.PollingConsumerPollStrategy
long
org.apache.camel.LoggingLevel
boolean
isGreedy()
boolean
boolean
boolean
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, doStart, doStop, 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.ComponentAware
getComponent
Methods inherited from interface org.apache.camel.Endpoint
createConsumer, createProducer, getEndpointBaseUri, isSingletonProducer
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.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
ScheduledPollEndpoint
-
ScheduledPollEndpoint
protected ScheduledPollEndpoint()
-
-
Method Details
-
configureConsumer
- Overrides:
configureConsumer
in classDefaultEndpoint
- Throws:
Exception
-
configureProperties
- Specified by:
configureProperties
in interfaceorg.apache.camel.Endpoint
- Overrides:
configureProperties
in classDefaultEndpoint
-
configureScheduledPollConsumerProperties
-
doConfigureConsumer
protected void doConfigureConsumer(org.apache.camel.Consumer consumer) -
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
-
setTimeUnit
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
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
-
getSchedulerProperties
-
setSchedulerProperties
To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler. -
getScheduledExecutorService
-
setScheduledExecutorService
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.
-