Interface PollingConsumerPollStrategy


  • public interface PollingConsumerPollStrategy
    Strategy for a PollingConsumer when polling an Endpoint.

    This pluggable strategy allows to plugin different implementations what to do, most noticeable what to do in case the polling goes wrong. This can be handled in the rollback method.

    • Method Detail

      • begin

        boolean begin​(Consumer consumer,
                      Endpoint endpoint)
        Called when poll is about to begin
        Parameters:
        consumer - the consumer
        endpoint - the endpoint being consumed
        Returns:
        true to begin polling, or false to skip polling this time.
      • commit

        void commit​(Consumer consumer,
                    Endpoint endpoint,
                    int polledMessages)
        Called when poll is completed successfully
        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

        boolean rollback​(Consumer consumer,
                         Endpoint endpoint,
                         int retryCounter,
                         Exception cause)
                  throws Exception
        Called when poll failed
        Parameters:
        consumer - the consumer
        endpoint - the endpoint being consumed
        retryCounter - current retry attempt, starting from 0.
        cause - 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.