public class LimitedPollingConsumerPollStrategy extends DefaultPollingConsumerPollStrategy implements Service
PollingConsumerPollStrategy which supports suspending consumers if they
failed for X number of times in a row.
If Camel cannot successfully consumer from a given consumer, then after X consecutive failed attempts the consumer
will be suspended/stopped. This prevents the log to get flooded with failed attempts, for example during nightly runs.log| Constructor and Description |
|---|
LimitedPollingConsumerPollStrategy() |
| Modifier and Type | Method and Description |
|---|---|
void |
commit(Consumer consumer,
Endpoint endpoint,
int polledMessages)
Called when poll is completed successfully
|
int |
getLimit() |
protected boolean |
onRollback(Consumer consumer,
Endpoint endpoint)
Rollback occurred.
|
protected void |
onSuspend(Consumer consumer,
Endpoint endpoint)
The consumer is to be suspended because it exceeded the limit
|
boolean |
rollback(Consumer consumer,
Endpoint endpoint,
int retryCounter,
Exception cause)
Called when poll failed
|
void |
setLimit(int limit)
Sets the limit for how many straight rollbacks causes this strategy to suspend the fault consumer.
|
void |
start()
Starts the service
|
void |
stop()
Stops the service
|
beginpublic LimitedPollingConsumerPollStrategy()
public int getLimit()
public void setLimit(int limit)
limit - the limitpublic void commit(Consumer consumer, Endpoint endpoint, int polledMessages)
PollingConsumerPollStrategycommit in interface PollingConsumerPollStrategycommit in class DefaultPollingConsumerPollStrategyconsumer - the consumerendpoint - the endpoint being consumedpolledMessages - number of messages polled, will be 0 if no message was polled at all.public boolean rollback(Consumer consumer, Endpoint endpoint, int retryCounter, Exception cause) throws Exception
PollingConsumerPollStrategyrollback in interface PollingConsumerPollStrategyrollback in class DefaultPollingConsumerPollStrategyconsumer - the consumerendpoint - the endpoint being consumedretryCounter - current retry attempt, starting from 0.cause - the caused exceptionException - can be used to rethrow the caused exception. Notice that thrown an exception will
terminate the scheduler and thus Camel will not trigger again. So if you want to let the scheduler
to continue to run then do not throw any exception from this method.protected void onSuspend(Consumer consumer, Endpoint endpoint) throws Exception
consumer - the consumerendpoint - the endpointException - is thrown if error suspending the consumerprotected boolean onRollback(Consumer consumer, Endpoint endpoint) throws Exception
consumer - the consumerendpoint - the endpointException - can be thrown in case something goes wrongpublic void start() throws Exception
ServiceApache Camel