Class RetryingBatchErrorHandler
java.lang.Object
org.springframework.kafka.listener.KafkaExceptionLogLevelAware
org.springframework.kafka.listener.RetryingBatchErrorHandler
- All Implemented Interfaces:
BatchErrorHandler,ConsumerAwareBatchErrorHandler,ContainerAwareBatchErrorHandler,GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,,?>> ListenerInvokingBatchErrorHandler
@Deprecated
public class RetryingBatchErrorHandler
extends KafkaExceptionLogLevelAware
implements ListenerInvokingBatchErrorHandler
Deprecated.
A batch error handler that invokes the listener according to the supplied
BackOff. The consumer is paused/polled/resumed before each retry in order to
avoid a rebalance. If/when retries are exhausted, the provided
ConsumerRecordRecoverer is invoked for each record in the batch. If the
recoverer throws an exception, or the thread is interrupted while sleeping, seeks are
performed so that the batch will be redelivered on the next poll.- Since:
- 2.3.7
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Construct an instance with a defaultFixedBackOff(unlimited attempts with a 5 second back off).RetryingBatchErrorHandler(org.springframework.util.backoff.BackOff backOff, ConsumerRecordRecoverer recoverer) Deprecated.Construct an instance with the providedBackOffandConsumerRecordRecoverer. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandle(Exception thrownException, org.apache.kafka.clients.consumer.ConsumerRecords<?, ?> records, org.apache.kafka.clients.consumer.Consumer<?, ?> consumer, MessageListenerContainer container, Runnable invokeListener) 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.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
handleMethods inherited from interface org.springframework.kafka.listener.GenericErrorHandler
clearThreadStateMethods inherited from interface org.springframework.kafka.listener.ListenerInvokingBatchErrorHandler
handle
-
Constructor Details
-
RetryingBatchErrorHandler
public RetryingBatchErrorHandler()Deprecated.Construct an instance with a defaultFixedBackOff(unlimited attempts with a 5 second back off). -
RetryingBatchErrorHandler
public RetryingBatchErrorHandler(org.springframework.util.backoff.BackOff backOff, @Nullable ConsumerRecordRecoverer recoverer) Deprecated.Construct an instance with the providedBackOffandConsumerRecordRecoverer. If the recoverer isnull, the discarded records (topic-partition@offset) will be logged.- Parameters:
backOff- the back off.recoverer- the recoverer.
-
-
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<?, ?> records, org.apache.kafka.clients.consumer.Consumer<?, ?> consumer, MessageListenerContainer container, Runnable invokeListener) Deprecated.Description copied from interface:ContainerAwareBatchErrorHandlerHandle the exception.- Specified by:
handlein interfaceBatchErrorHandler- Specified by:
handlein interfaceContainerAwareBatchErrorHandler- Specified by:
handlein interfaceListenerInvokingBatchErrorHandler- Parameters:
thrownException- the exception.records- the consumer records.consumer- the consumer.container- the container.invokeListener- a callback to re-invoke the listener.
-
DefaultErrorHandler.