Package org.apache.camel.support
Class ScheduledPollConsumer
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultConsumer
-
- org.apache.camel.support.ScheduledPollConsumer
-
- All Implemented Interfaces:
AutoCloseable
,Runnable
,org.apache.camel.Consumer
,org.apache.camel.EndpointAware
,org.apache.camel.PollingConsumerPollingStrategy
,org.apache.camel.RouteAware
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.RouteIdAware
,org.apache.camel.StatefulService
,org.apache.camel.Suspendable
,org.apache.camel.SuspendableService
- Direct Known Subclasses:
AbstractApiConsumer
,DefaultScheduledPollConsumer
,ScheduledBatchPollingConsumer
public abstract class ScheduledPollConsumer extends DefaultConsumer implements Runnable, org.apache.camel.Suspendable, org.apache.camel.PollingConsumerPollingStrategy
A useful base class for any consumer which is polling based
-
-
Constructor Summary
Constructors Constructor Description ScheduledPollConsumer(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)
ScheduledPollConsumer(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor, ScheduledExecutorService scheduledExecutorService)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
afterPoll()
long
beforePoll(long timeout)
protected void
doInit()
protected void
doShutdown()
protected void
doStart()
protected void
doStop()
protected void
doSuspend()
int
getBackoffCounter()
int
getBackoffErrorThreshold()
int
getBackoffIdleThreshold()
int
getBackoffMultiplier()
long
getDelay()
long
getInitialDelay()
org.apache.camel.spi.PollingConsumerPollStrategy
getPollStrategy()
long
getRepeatCount()
org.apache.camel.LoggingLevel
getRunLoggingLevel()
ScheduledExecutorService
getScheduledExecutorService()
org.apache.camel.spi.ScheduledPollConsumerScheduler
getScheduler()
Map<String,Object>
getSchedulerProperties()
TimeUnit
getTimeUnit()
boolean
isGreedy()
protected boolean
isPollAllowed()
boolean
isPolling()
Whether polling is currently in progressboolean
isSchedulerStarted()
boolean
isSendEmptyMessageWhenIdle()
boolean
isStartScheduler()
boolean
isUseFixedDelay()
void
onInit()
protected abstract int
poll()
The polling method which is invoked periodically to poll this consumerprotected void
processEmptyMessage()
No messages to poll so send an empty message instead.void
run()
Invoked whenever we should be polledvoid
setBackoffErrorThreshold(int backoffErrorThreshold)
void
setBackoffIdleThreshold(int backoffIdleThreshold)
void
setBackoffMultiplier(int backoffMultiplier)
void
setDelay(long delay)
void
setGreedy(boolean greedy)
void
setInitialDelay(long initialDelay)
void
setPollStrategy(org.apache.camel.spi.PollingConsumerPollStrategy pollStrategy)
void
setRepeatCount(long repeatCount)
void
setRunLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel)
void
setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
void
setScheduler(org.apache.camel.spi.ScheduledPollConsumerScheduler scheduler)
void
setSchedulerProperties(Map<String,Object> schedulerProperties)
void
setSendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle)
void
setStartScheduler(boolean startScheduler)
void
setTimeUnit(TimeUnit timeUnit)
void
setUseFixedDelay(boolean useFixedDelay)
void
startScheduler()
Starts the scheduler.-
Methods inherited from class org.apache.camel.support.DefaultConsumer
createUoW, doneUoW, getAsyncProcessor, getEndpoint, getExceptionHandler, getProcessor, getRoute, getRouteId, handleException, handleException, setExceptionHandler, setRoute, setRouteId, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, 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, wait, wait, wait
-
-
-
-
Constructor Detail
-
ScheduledPollConsumer
public ScheduledPollConsumer(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)
-
ScheduledPollConsumer
public ScheduledPollConsumer(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor, ScheduledExecutorService scheduledExecutorService)
-
-
Method Detail
-
processEmptyMessage
protected void processEmptyMessage() throws Exception
No messages to poll so send an empty message instead.- Throws:
Exception
- is thrown if error processing the empty message.
-
isPollAllowed
protected boolean isPollAllowed()
-
isPolling
public boolean isPolling()
Whether polling is currently in progress
-
getScheduler
public org.apache.camel.spi.ScheduledPollConsumerScheduler getScheduler()
-
setScheduler
public void setScheduler(org.apache.camel.spi.ScheduledPollConsumerScheduler scheduler)
-
getInitialDelay
public long getInitialDelay()
-
setInitialDelay
public void setInitialDelay(long initialDelay)
-
getDelay
public long getDelay()
-
setDelay
public void setDelay(long delay)
-
getTimeUnit
public TimeUnit getTimeUnit()
-
setTimeUnit
public void setTimeUnit(TimeUnit timeUnit)
-
isUseFixedDelay
public boolean isUseFixedDelay()
-
setUseFixedDelay
public void setUseFixedDelay(boolean useFixedDelay)
-
getRunLoggingLevel
public org.apache.camel.LoggingLevel getRunLoggingLevel()
-
setRunLoggingLevel
public void setRunLoggingLevel(org.apache.camel.LoggingLevel runLoggingLevel)
-
getPollStrategy
public org.apache.camel.spi.PollingConsumerPollStrategy getPollStrategy()
-
setPollStrategy
public void setPollStrategy(org.apache.camel.spi.PollingConsumerPollStrategy pollStrategy)
-
isStartScheduler
public boolean isStartScheduler()
-
setStartScheduler
public void setStartScheduler(boolean startScheduler)
-
setSendEmptyMessageWhenIdle
public void setSendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle)
-
isSendEmptyMessageWhenIdle
public boolean isSendEmptyMessageWhenIdle()
-
isGreedy
public boolean isGreedy()
-
setGreedy
public void setGreedy(boolean greedy)
-
getBackoffCounter
public int getBackoffCounter()
-
getBackoffMultiplier
public int getBackoffMultiplier()
-
setBackoffMultiplier
public void setBackoffMultiplier(int backoffMultiplier)
-
getBackoffIdleThreshold
public int getBackoffIdleThreshold()
-
setBackoffIdleThreshold
public void setBackoffIdleThreshold(int backoffIdleThreshold)
-
getBackoffErrorThreshold
public int getBackoffErrorThreshold()
-
setBackoffErrorThreshold
public void setBackoffErrorThreshold(int backoffErrorThreshold)
-
getRepeatCount
public long getRepeatCount()
-
setRepeatCount
public void setRepeatCount(long repeatCount)
-
getScheduledExecutorService
public ScheduledExecutorService getScheduledExecutorService()
-
isSchedulerStarted
public boolean isSchedulerStarted()
-
setScheduledExecutorService
public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
-
poll
protected abstract int poll() throws Exception
The polling method which is invoked periodically to poll this consumer- Returns:
- number of messages polled, will be 0 if no message was polled at all.
- Throws:
Exception
- can be thrown if an exception occurred during polling
-
doInit
protected void doInit() throws Exception
- Overrides:
doInit
in classDefaultConsumer
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classDefaultConsumer
- Throws:
Exception
-
startScheduler
public void startScheduler()
Starts the scheduler. If the scheduler is already started, then this is a noop method call.
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classDefaultConsumer
- Throws:
Exception
-
doShutdown
protected void doShutdown() throws Exception
- Overrides:
doShutdown
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doSuspend
protected void doSuspend() throws Exception
- Overrides:
doSuspend
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
onInit
public void onInit() throws Exception
- Specified by:
onInit
in interfaceorg.apache.camel.PollingConsumerPollingStrategy
- Throws:
Exception
-
beforePoll
public long beforePoll(long timeout) throws Exception
- Specified by:
beforePoll
in interfaceorg.apache.camel.PollingConsumerPollingStrategy
- Throws:
Exception
-
-