Class SeekUtils
- java.lang.Object
-
- org.springframework.kafka.listener.SeekUtils
-
public final class SeekUtils extends java.lang.Object
Seek utilities.- Since:
- 2.2
- Author:
- Gary Russell
-
-
Field Summary
Fields Modifier and Type Field Description static org.springframework.util.backoff.FixedBackOff
DEFAULT_BACK_OFF
The default back off - aFixedBackOff
with 0 interval andDEFAULT_MAX_FAILURES
- 1 retry attempts.static int
DEFAULT_MAX_FAILURES
The number of times a topic/partition/offset can fail before being rejected.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
doSeeks(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, java.lang.Exception exception, boolean recoverable, java.util.function.BiPredicate<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> skipper, org.springframework.core.log.LogAccessor logger)
Seek records to earliest position, optionally skipping the first.static void
seekOrRecover(java.lang.Exception thrownException, java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container, boolean commitRecovered, java.util.function.BiPredicate<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> skipPredicate, org.springframework.core.log.LogAccessor logger, KafkaException.Level level)
Seek the remaining records, optionally recovering the first.static void
seekPartitions(org.apache.kafka.clients.consumer.Consumer<?,?> consumer, java.util.Map<org.apache.kafka.common.TopicPartition,java.lang.Long> partitions, org.springframework.core.log.LogAccessor logger)
Perform seek operations on each partition.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
DEFAULT_BACK_OFF
public static final org.springframework.util.backoff.FixedBackOff DEFAULT_BACK_OFF
The default back off - aFixedBackOff
with 0 interval andDEFAULT_MAX_FAILURES
- 1 retry attempts.
-
-
Method Detail
-
doSeeks
public static boolean doSeeks(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, java.lang.Exception exception, boolean recoverable, java.util.function.BiPredicate<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> skipper, org.springframework.core.log.LogAccessor logger)
Seek records to earliest position, optionally skipping the first.- Parameters:
records
- the records.consumer
- the consumer.exception
- the exceptionrecoverable
- true if skipping the first record is allowed.skipper
- function to determine whether or not to skip seeking the first.logger
- aLogAccessor
for seek errors.- Returns:
- true if the failed record was skipped.
-
seekPartitions
public static void seekPartitions(org.apache.kafka.clients.consumer.Consumer<?,?> consumer, java.util.Map<org.apache.kafka.common.TopicPartition,java.lang.Long> partitions, org.springframework.core.log.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(java.lang.Exception thrownException, java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container, boolean commitRecovered, java.util.function.BiPredicate<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> skipPredicate, org.springframework.core.log.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 recovererd record offset.skipPredicate
- the skip predicate.logger
- the logger.level
- the log level for the thrown exception after handling.- Since:
- 2.5
-
-