Class RecoveringBatchErrorHandler
java.lang.Object
org.springframework.kafka.listener.KafkaExceptionLogLevelAware
org.springframework.kafka.listener.ExceptionClassifier
org.springframework.kafka.listener.FailedRecordProcessor
org.springframework.kafka.listener.FailedBatchProcessor
org.springframework.kafka.listener.RecoveringBatchErrorHandler
- All Implemented Interfaces:
BatchErrorHandler,ConsumerAwareBatchErrorHandler,ContainerAwareBatchErrorHandler,DeliveryAttemptAware,GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>
@Deprecated
public class RecoveringBatchErrorHandler
extends FailedBatchProcessor
implements ContainerAwareBatchErrorHandler
Deprecated.
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. If
the listener throws a
BatchListenerFailedException, with the failed record. The
records before the record will have their offsets committed and the partitions for the
remaining records will be repositioned and/or the failed record can be recovered and
skipped. If some other exception is thrown, or a valid record is not provided in the
exception, error handling is delegated to a SeekToCurrentBatchErrorHandler with
this handler's BackOff. If the record is recovered, its offset is committed.- Since:
- 2.5
-
Field Summary
Fields inherited from class org.springframework.kafka.listener.FailedRecordProcessor
logger -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Construct an instance with the default recoverer which simply logs the record after 10 (maxFailures) have occurred for a topic/partition/offset.RecoveringBatchErrorHandler(BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?, ?>, Exception> recoverer) Deprecated.Construct an instance with the provided recoverer which will be called after 10 (maxFailures) have occurred for a topic/partition/offset.RecoveringBatchErrorHandler(BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?, ?>, Exception> recoverer, org.springframework.util.backoff.BackOff backOff) Deprecated.Construct an instance with the provided recoverer which will be called after the backOff returns STOP for a topic/partition/offset.RecoveringBatchErrorHandler(org.springframework.util.backoff.BackOff backOff) Deprecated.Construct an instance with the default recoverer which simply logs the record after the backOff returns STOP for a topic/partition/offset. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandle(Exception thrownException, org.apache.kafka.clients.consumer.ConsumerRecords<?, ?> data, org.apache.kafka.clients.consumer.Consumer<?, ?> consumer, MessageListenerContainer container) Deprecated.Handle the exception.booleanDeprecated.Return true if the offset should be committed for a handled error (no exception thrown).voidsetAckAfterHandle(boolean ackAfterHandle) Deprecated.Set to false to prevent the container from committing the offset of a recovered record (when the error handler does not itself throw an exception).Methods inherited from class org.springframework.kafka.listener.FailedBatchProcessor
doHandleMethods inherited from class org.springframework.kafka.listener.FailedRecordProcessor
clearThreadState, deliveryAttempt, getRecoveryStrategy, getRecoveryStrategy, getSkipPredicate, isCommitRecovered, setBackOffFunction, setCommitRecovered, setResetStateOnExceptionChange, setResetStateOnRecoveryFailure, setRetryListenersMethods inherited from class org.springframework.kafka.listener.ExceptionClassifier
addNotRetryableExceptions, addRetryableExceptions, defaultFalse, getClassifier, removeClassification, removeNotRetryableException, setClassificationsMethods inherited from class org.springframework.kafka.listener.KafkaExceptionLogLevelAware
getLogLevel, setLogLevelMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.kafka.listener.ConsumerAwareBatchErrorHandler
handleMethods inherited from interface org.springframework.kafka.listener.ContainerAwareBatchErrorHandler
handle, handleMethods inherited from interface org.springframework.kafka.listener.GenericErrorHandler
clearThreadState
-
Constructor Details
-
RecoveringBatchErrorHandler
public RecoveringBatchErrorHandler()Deprecated.Construct an instance with the default recoverer which simply logs the record after 10 (maxFailures) have occurred for a topic/partition/offset. -
RecoveringBatchErrorHandler
public RecoveringBatchErrorHandler(org.springframework.util.backoff.BackOff backOff) Deprecated.Construct an instance with the default recoverer which simply logs the record after the backOff returns STOP for a topic/partition/offset.- Parameters:
backOff- theBackOff.
-
RecoveringBatchErrorHandler
public RecoveringBatchErrorHandler(BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?, ?>, Exception> recoverer) Deprecated.Construct an instance with the provided recoverer which will be called after 10 (maxFailures) have occurred for a topic/partition/offset.- Parameters:
recoverer- the recoverer.
-
RecoveringBatchErrorHandler
public RecoveringBatchErrorHandler(@Nullable BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?, ?>, Exception> recoverer, org.springframework.util.backoff.BackOff backOff) Deprecated.Construct an instance with the provided recoverer which will be called after the backOff returns STOP for a topic/partition/offset.- Parameters:
recoverer- the recoverer; if null, the default (logging) recoverer is used.backOff- theBackOff.- Since:
- 2.3
-
-
Method Details
-
isAckAfterHandle
public boolean isAckAfterHandle()Deprecated.Description copied from interface:GenericErrorHandlerReturn true if the offset should be committed for a handled error (no exception thrown).- Specified by:
isAckAfterHandlein interfaceGenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>> - Returns:
- true to commit.
-
setAckAfterHandle
public void setAckAfterHandle(boolean ackAfterHandle) Deprecated.Description copied from interface:GenericErrorHandlerSet to false to prevent the container from committing the offset of a recovered record (when the error handler does not itself throw an exception).- Specified by:
setAckAfterHandlein interfaceGenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>> - Parameters:
ackAfterHandle- false to not commit.
-
handle
public void handle(Exception thrownException, @Nullable org.apache.kafka.clients.consumer.ConsumerRecords<?, ?> data, org.apache.kafka.clients.consumer.Consumer<?, ?> consumer, MessageListenerContainer container) Deprecated.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.
-
DefaultErrorHandler.