Class KafkaConsumerBackoffManager

  • All Implemented Interfaces:
    java.util.EventListener, org.springframework.context.ApplicationListener<ListenerContainerPartitionIdleEvent>

    public class KafkaConsumerBackoffManager
    extends java.lang.Object
    implements org.springframework.context.ApplicationListener<ListenerContainerPartitionIdleEvent>
    A manager that backs off consumption for a given topic if the timestamp provided is not due. Use with SeekToCurrentErrorHandler to guarantee that the message is read again after partition consumption is resumed (or seek it manually by other means). It's also necessary to set a ContainerProperties.setIdlePartitionEventInterval(Long) so the Manager can resume the partition consumption. Note that when a record backs off the partition consumption gets paused for approximately that amount of time, so you must have a fixed backoff value per partition in order to make sure no record waits more than it should.
    Since:
    2.7
    Author:
    Tomaz Fernandes, Gary Russell
    See Also:
    SeekToCurrentErrorHandler
    • Field Detail

      • INTERNAL_BACKOFF_CLOCK_BEAN_NAME

        public static final java.lang.String INTERNAL_BACKOFF_CLOCK_BEAN_NAME
        Internal Back Off Clock Bean Name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • KafkaConsumerBackoffManager

        public KafkaConsumerBackoffManager​(ListenerContainerRegistry registry,
                                           @Qualifier("internalBackOffClock")
                                           java.time.Clock clock,
                                           org.springframework.core.task.TaskExecutor taskExecutor,
                                           org.springframework.retry.backoff.Sleeper sleeper)