Package org.apache.camel.impl.engine
Class LimitedPollingConsumerPollStrategy
- java.lang.Object
-
- org.apache.camel.support.DefaultPollingConsumerPollStrategy
-
- org.apache.camel.impl.engine.LimitedPollingConsumerPollStrategy
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.Service
,org.apache.camel.spi.PollingConsumerPollStrategy
public class LimitedPollingConsumerPollStrategy extends org.apache.camel.support.DefaultPollingConsumerPollStrategy implements org.apache.camel.Service
APollingConsumerPollStrategy
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 Summary
Constructors Constructor Description LimitedPollingConsumerPollStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 limitboolean
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()
-
-
-
Method Detail
-
getLimit
public int getLimit()
-
setLimit
public void setLimit(int limit)
Sets the limit for how many straight rollbacks causes this strategy to suspend the fault consumer. When the consumer has been suspended, it has to be manually resumed/started to be active again. The limit is by default 3.- Parameters:
limit
- the limit
-
commit
public void commit(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint, int polledMessages)
- Specified by:
commit
in interfaceorg.apache.camel.spi.PollingConsumerPollStrategy
- Overrides:
commit
in classorg.apache.camel.support.DefaultPollingConsumerPollStrategy
-
rollback
public boolean rollback(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint, int retryCounter, Exception cause) throws Exception
- Specified by:
rollback
in interfaceorg.apache.camel.spi.PollingConsumerPollStrategy
- Overrides:
rollback
in classorg.apache.camel.support.DefaultPollingConsumerPollStrategy
- Throws:
Exception
-
onSuspend
protected void onSuspend(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint) throws Exception
The consumer is to be suspended because it exceeded the limit- Parameters:
consumer
- the consumerendpoint
- the endpoint- Throws:
Exception
- is thrown if error suspending the consumer
-
onRollback
protected boolean onRollback(org.apache.camel.Consumer consumer, org.apache.camel.Endpoint endpoint) throws Exception
Rollback occurred.- Parameters:
consumer
- the consumerendpoint
- the endpoint- Returns:
- whether or not to retry immediately, is default false
- Throws:
Exception
- can be thrown in case something goes wrong
-
start
public void start()
- Specified by:
start
in interfaceorg.apache.camel.Service
-
stop
public void stop()
- Specified by:
stop
in interfaceorg.apache.camel.Service
-
-