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
- Author:
- Gary Russell
-
-
Constructor Summary
Constructors Constructor Description SeekToCurrentBatchErrorHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearThreadState()
Optional method to clear thread state; will be called just before a consumer thread terminates.void
handle(java.lang.Exception thrownException, org.apache.kafka.clients.consumer.ConsumerRecords<?,?> data, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container)
Handle the exception.void
setBackOff(org.springframework.util.backoff.BackOff backOff)
Set aBackOff
to 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 aBackOff
to 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, org.apache.kafka.clients.consumer.ConsumerRecords<?,?> data, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container)
Description copied from interface:BatchErrorHandler
Handle the exception.- Specified by:
handle
in interfaceBatchErrorHandler
- Specified by:
handle
in interfaceConsumerAwareBatchErrorHandler
- Specified by:
handle
in interfaceContainerAwareBatchErrorHandler
- Parameters:
thrownException
- the exception.data
- the consumer records.consumer
- the consumer.container
- the container.
-
clearThreadState
public void clearThreadState()
Description copied from interface:GenericErrorHandler
Optional method to clear thread state; will be called just before a consumer thread terminates.- Specified by:
clearThreadState
in interfaceGenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>
-
-