Class SeekToCurrentBatchErrorHandler
- java.lang.Object
-
- org.springframework.kafka.listener.KafkaExceptionLogLevelAware
-
- org.springframework.kafka.listener.SeekToCurrentBatchErrorHandler
-
- All Implemented Interfaces:
BatchErrorHandler,ConsumerAwareBatchErrorHandler,ContainerAwareBatchErrorHandler,GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>
public class SeekToCurrentBatchErrorHandler extends KafkaExceptionLogLevelAware implements ContainerAwareBatchErrorHandler
An error handler that seeks to the current offset for each topic in a batch of records. Used to rewind partitions after a message failure so that the batch can be replayed.- Since:
- 2.1
-
-
Constructor Summary
Constructors Constructor Description SeekToCurrentBatchErrorHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearThreadState()Optional method to clear thread state; will be called just before a consumer thread terminates.voidhandle(java.lang.Exception thrownException, org.apache.kafka.clients.consumer.ConsumerRecords<?,?> data, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container)Handle the exception.voidsetBackOff(org.springframework.util.backoff.BackOff backOff)Set aBackOffto suspend the thread after performing the seek.-
Methods inherited from class org.springframework.kafka.listener.KafkaExceptionLogLevelAware
getLogLevel, setLogLevel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.kafka.listener.ConsumerAwareBatchErrorHandler
handle
-
Methods inherited from interface org.springframework.kafka.listener.ContainerAwareBatchErrorHandler
handle, handle
-
Methods inherited from interface org.springframework.kafka.listener.GenericErrorHandler
isAckAfterHandle, setAckAfterHandle
-
-
-
-
Method Detail
-
setBackOff
public void setBackOff(org.springframework.util.backoff.BackOff backOff)
Set aBackOffto suspend the thread after performing the seek. Since this error handler can never "recover" after retries are exhausted, if the back off returns STOP, then the previous interval is used.- Parameters:
backOff- the back off.- Since:
- 2.3
-
handle
public void handle(java.lang.Exception thrownException, @Nullable org.apache.kafka.clients.consumer.ConsumerRecords<?,?> data, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container)Description copied from interface:BatchErrorHandlerHandle the exception.- Specified by:
handlein interfaceBatchErrorHandler- Specified by:
handlein interfaceConsumerAwareBatchErrorHandler- Specified by:
handlein interfaceContainerAwareBatchErrorHandler- Parameters:
thrownException- the exception.data- the consumer records.consumer- the consumer.container- the container.
-
clearThreadState
public void clearThreadState()
Description copied from interface:GenericErrorHandlerOptional method to clear thread state; will be called just before a consumer thread terminates.- Specified by:
clearThreadStatein interfaceGenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>
-
-