org.apache.camel.impl
Class DefaultPollingConsumerPollStrategy

java.lang.Object
  extended by org.apache.camel.impl.DefaultPollingConsumerPollStrategy
All Implemented Interfaces:
PollingConsumerPollStrategy
Direct Known Subclasses:
LimitedPollingConsumerPollStrategy, RemoteFilePollingConsumerPollStrategy

public class DefaultPollingConsumerPollStrategy
extends Object
implements PollingConsumerPollStrategy

A default implementation that just logs a WARN level log in case of rollback.

The implement will not log if the rollback occurred during shutdown.

Version:

Field Summary
protected  org.slf4j.Logger log
           
 
Constructor Summary
DefaultPollingConsumerPollStrategy()
           
 
Method Summary
 boolean begin(Consumer consumer, Endpoint endpoint)
          Called when poll is about to begin
 void commit(Consumer consumer, Endpoint endpoint, int polledMessages)
          Called when poll is completed successfully
 boolean rollback(Consumer consumer, Endpoint endpoint, int retryCounter, Exception e)
          Called when poll failed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final transient org.slf4j.Logger log
Constructor Detail

DefaultPollingConsumerPollStrategy

public DefaultPollingConsumerPollStrategy()
Method Detail

begin

public boolean begin(Consumer consumer,
                     Endpoint endpoint)
Description copied from interface: PollingConsumerPollStrategy
Called when poll is about to begin

Specified by:
begin in interface PollingConsumerPollStrategy
Parameters:
consumer - the consumer
endpoint - the endpoint being consumed
Returns:
true to begin polling, or false to skip polling this time.

commit

public void commit(Consumer consumer,
                   Endpoint endpoint,
                   int polledMessages)
Description copied from interface: PollingConsumerPollStrategy
Called when poll is completed successfully

Specified by:
commit in interface PollingConsumerPollStrategy
Parameters:
consumer - the consumer
endpoint - the endpoint being consumed
polledMessages - number of messages polled, will be 0 if no message was polled at all.

rollback

public boolean rollback(Consumer consumer,
                        Endpoint endpoint,
                        int retryCounter,
                        Exception e)
                 throws Exception
Description copied from interface: PollingConsumerPollStrategy
Called when poll failed

Specified by:
rollback in interface PollingConsumerPollStrategy
Parameters:
consumer - the consumer
endpoint - the endpoint being consumed
retryCounter - current retry attempt, starting from 0.
e - the caused exception
Returns:
whether to retry immediately or not. Return false to ignore the problem, true to try immediately again
Throws:
Exception - 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.


Apache CAMEL