Class SeekUtils

java.lang.Object
org.springframework.kafka.listener.SeekUtils

public final class SeekUtils extends Object
Seek utilities.
Since:
2.2
Author:
Gary Russell, Francois Rosiere
  • Field Details

    • DEFAULT_MAX_FAILURES

      public static final int DEFAULT_MAX_FAILURES
      The number of times a topic/partition/offset can fail before being rejected.
      See Also:
    • DEFAULT_BACK_OFF

      public static final FixedBackOff DEFAULT_BACK_OFF
      The default back off - a FixedBackOff with 0 interval and DEFAULT_MAX_FAILURES - 1 retry attempts.
  • Method Details

    • doSeeks

      public static boolean doSeeks(List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Exception exception, boolean recoverable, BiPredicate<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,Exception> skipper, LogAccessor logger)
      Seek records to earliest position, optionally skipping the first.
      Parameters:
      records - the records.
      consumer - the consumer.
      exception - the exception
      recoverable - true if skipping the first record is allowed.
      skipper - function to determine whether or not to skip seeking the first.
      logger - a LogAccessor for seek errors.
      Returns:
      true if the failed record was skipped.
    • doSeeks

      public static boolean doSeeks(List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Exception exception, boolean recoverable, RecoveryStrategy recovery, @Nullable MessageListenerContainer container, LogAccessor logger)
      Seek records to earliest position, optionally skipping the first.
      Parameters:
      records - the records.
      consumer - the consumer.
      exception - the exception
      recoverable - true if skipping the first record is allowed.
      recovery - the RecoveryStrategy.
      container - the container, or parent if a child.
      logger - a LogAccessor for seek errors.
      Returns:
      true if the failed record was skipped.
    • seekPartitions

      public static void seekPartitions(org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Map<org.apache.kafka.common.TopicPartition,Long> partitions, LogAccessor logger)
      Perform seek operations on each partition.
      Parameters:
      consumer - the consumer.
      partitions - the partitions.
      logger - the logger.
      Since:
      2.5
    • seekOrRecover

      public static void seekOrRecover(Exception thrownException, List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container, boolean commitRecovered, BiPredicate<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,Exception> skipPredicate, LogAccessor logger, KafkaException.Level level)
      Seek the remaining records, optionally recovering the first.
      Parameters:
      thrownException - the exception.
      records - the remaining records.
      consumer - the consumer.
      container - the container.
      commitRecovered - true to commit the recovered record offset.
      skipPredicate - the skip predicate.
      logger - the logger.
      level - the log level for the thrown exception after handling.
      Since:
      2.5
    • seekOrRecover

      public static void seekOrRecover(Exception thrownException, @Nullable List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container, boolean commitRecovered, RecoveryStrategy recovery, LogAccessor logger, KafkaException.Level level)
      Seek the remaining records, optionally recovering the first.
      Parameters:
      thrownException - the exception.
      records - the remaining records.
      consumer - the consumer.
      container - the container.
      commitRecovered - true to commit the recovered record offset.
      recovery - the RecoveryStrategy.
      logger - the logger.
      level - the log level for the thrown exception after handling.
      Since:
      2.7
    • isBackoffException

      public static boolean isBackoffException(Exception exception)
      Return true if the exception is a KafkaBackoffException.
      Parameters:
      exception - the exception.
      Returns:
      true if it's a back off.
      Since:
      2.7