public abstract class ScheduledPollConsumer extends DefaultConsumer implements Runnable, Suspendable, PollingConsumerPollingStrategy
log
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
ScheduledPollConsumer(Endpoint endpoint,
Processor processor) |
ScheduledPollConsumer(Endpoint endpoint,
Processor processor,
ScheduledExecutorService scheduledExecutorService) |
Modifier and Type | Method and Description |
---|---|
void |
afterPoll()
Callback invoked after the poll.
|
long |
beforePoll(long timeout)
Callback invoked before the poll.
|
protected void |
doShutdown()
Implementations override this method to perform customized shutdown.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
protected void |
doSuspend()
Implementations override this method to support customized suspend/resume.
|
int |
getBackoffCounter() |
int |
getBackoffErrorThreshold() |
int |
getBackoffIdleThreshold() |
int |
getBackoffMultiplier() |
long |
getDelay() |
long |
getInitialDelay() |
PollingConsumerPollStrategy |
getPollStrategy() |
LoggingLevel |
getRunLoggingLevel() |
ScheduledExecutorService |
getScheduledExecutorService() |
ScheduledPollConsumerScheduler |
getScheduler() |
Map<String,Object> |
getSchedulerProperties() |
TimeUnit |
getTimeUnit() |
boolean |
isGreedy() |
protected boolean |
isPollAllowed() |
protected boolean |
isPolling()
Whether polling is currently in progress
|
boolean |
isSchedulerStarted() |
boolean |
isSendEmptyMessageWhenIdle() |
boolean |
isStartScheduler() |
boolean |
isUseFixedDelay() |
void |
onInit()
Callback invoked when the consumer is initialized such as when the
PollingConsumer starts. |
protected abstract int |
poll()
The polling method which is invoked periodically to poll this consumer
|
protected void |
processEmptyMessage()
No messages to poll so send an empty message instead.
|
void |
run()
Invoked whenever we should be polled
|
void |
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(PollingConsumerPollStrategy pollStrategy) |
void |
setRunLoggingLevel(LoggingLevel runLoggingLevel) |
void |
setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) |
void |
setScheduler(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.
|
createUoW, doneUoW, getAsyncProcessor, getEndpoint, getExceptionHandler, getProcessor, getRoute, handleException, handleException, setExceptionHandler, setRoute, toString
doResume, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public ScheduledPollConsumer(Endpoint endpoint, Processor processor)
public ScheduledPollConsumer(Endpoint endpoint, Processor processor, ScheduledExecutorService scheduledExecutorService)
protected void processEmptyMessage() throws Exception
Exception
- is thrown if error processing the empty message.protected boolean isPollAllowed()
protected boolean isPolling()
public ScheduledPollConsumerScheduler getScheduler()
public void setScheduler(ScheduledPollConsumerScheduler scheduler)
public Map<String,Object> getSchedulerProperties()
public void setSchedulerProperties(Map<String,Object> schedulerProperties)
public long getInitialDelay()
public void setInitialDelay(long initialDelay)
public long getDelay()
public void setDelay(long delay)
public TimeUnit getTimeUnit()
public void setTimeUnit(TimeUnit timeUnit)
public boolean isUseFixedDelay()
public void setUseFixedDelay(boolean useFixedDelay)
public LoggingLevel getRunLoggingLevel()
public void setRunLoggingLevel(LoggingLevel runLoggingLevel)
public PollingConsumerPollStrategy getPollStrategy()
public void setPollStrategy(PollingConsumerPollStrategy pollStrategy)
public boolean isStartScheduler()
public void setStartScheduler(boolean startScheduler)
public void setSendEmptyMessageWhenIdle(boolean sendEmptyMessageWhenIdle)
public boolean isSendEmptyMessageWhenIdle()
public boolean isGreedy()
public void setGreedy(boolean greedy)
public int getBackoffCounter()
public int getBackoffMultiplier()
public void setBackoffMultiplier(int backoffMultiplier)
public int getBackoffIdleThreshold()
public void setBackoffIdleThreshold(int backoffIdleThreshold)
public int getBackoffErrorThreshold()
public void setBackoffErrorThreshold(int backoffErrorThreshold)
public ScheduledExecutorService getScheduledExecutorService()
public boolean isSchedulerStarted()
public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
protected abstract int poll() throws Exception
Exception
- can be thrown if an exception occurred during pollingprotected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class DefaultConsumer
Exception
ServiceSupport.doStop()
public void startScheduler()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class DefaultConsumer
Exception
ServiceSupport.doStart()
protected void doShutdown() throws Exception
ServiceSupport
doShutdown
in class ServiceSupport
Exception
protected void doSuspend() throws Exception
ServiceSupport
doSuspend
in class ServiceSupport
Exception
public void onInit() throws Exception
PollingConsumerPollingStrategy
PollingConsumer
starts.onInit
in interface PollingConsumerPollingStrategy
Exception
- can be thrown if error initializing.public long beforePoll(long timeout) throws Exception
PollingConsumerPollingStrategy
beforePoll
in interface PollingConsumerPollingStrategy
timeout
- the timeoutException
- can be thrown if error occurredpublic void afterPoll() throws Exception
PollingConsumerPollingStrategy
afterPoll
in interface PollingConsumerPollingStrategy
Exception
- can be thrown if error occurredApache Camel