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.
in favor of DefaultErrorHandler.
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 Details

    • RetryingBatchErrorHandler

      public RetryingBatchErrorHandler()
      Deprecated.
      Construct an instance with a default FixedBackOff (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 provided BackOff and ConsumerRecordRecoverer. If the recoverer is null, 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: GenericErrorHandler
      Return true if the offset should be committed for a handled error (no exception thrown).
      Specified by:
      isAckAfterHandle in interface GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>
      Returns:
      true to commit.
    • setAckAfterHandle

      public void setAckAfterHandle(boolean ackAfterHandle)
      Deprecated.
      Description copied from interface: GenericErrorHandler
      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).
      Specified by:
      setAckAfterHandle in interface GenericErrorHandler<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: ContainerAwareBatchErrorHandler
      Handle the exception.
      Specified by:
      handle in interface BatchErrorHandler
      Specified by:
      handle in interface ContainerAwareBatchErrorHandler
      Specified by:
      handle in interface ListenerInvokingBatchErrorHandler
      Parameters:
      thrownException - the exception.
      records - the consumer records.
      consumer - the consumer.
      container - the container.
      invokeListener - a callback to re-invoke the listener.