public class LimitedPollingConsumerPollStrategy extends org.apache.camel.support.DefaultPollingConsumerPollStrategy implements org.apache.camel.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.| Constructor and Description |
|---|
LimitedPollingConsumerPollStrategy() |
| Modifier and Type | Method and Description |
|---|---|
void |
commit(org.apache.camel.Consumer consumer,
org.apache.camel.Endpoint endpoint,
int polledMessages) |
int |
getLimit() |
protected boolean |
onRollback(org.apache.camel.Consumer consumer,
org.apache.camel.Endpoint endpoint)
Rollback occurred.
|
protected void |
onSuspend(org.apache.camel.Consumer consumer,
org.apache.camel.Endpoint endpoint)
The consumer is to be suspended because it exceeded the limit
|
boolean |
rollback(org.apache.camel.Consumer consumer,
org.apache.camel.Endpoint endpoint,
int retryCounter,
Exception cause) |
void |
setLimit(int limit)
Sets the limit for how many straight rollbacks causes this strategy to suspend the fault consumer.
|
void |
start() |
void |
stop() |
public LimitedPollingConsumerPollStrategy()
public int getLimit()
public void setLimit(int limit)
limit - the limitpublic void commit(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint, int polledMessages)
commit in interface org.apache.camel.spi.PollingConsumerPollStrategycommit in class org.apache.camel.support.DefaultPollingConsumerPollStrategypublic boolean rollback(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint, int retryCounter, Exception cause) throws Exception
rollback in interface org.apache.camel.spi.PollingConsumerPollStrategyrollback in class org.apache.camel.support.DefaultPollingConsumerPollStrategyExceptionprotected void onSuspend(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint) throws Exception
consumer - the consumerendpoint - the endpointException - is thrown if error suspending the consumerprotected boolean onRollback(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint) throws Exception
consumer - the consumerendpoint - the endpointException - can be thrown in case something goes wrongpublic void start() throws Exception
start in interface org.apache.camel.ServiceExceptionApache Camel