Class RecoveringBatchErrorHandler

All Implemented Interfaces:
BatchErrorHandler, ConsumerAwareBatchErrorHandler, ContainerAwareBatchErrorHandler, DeliveryAttemptAware, GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>

@Deprecated public class RecoveringBatchErrorHandler extends FailedBatchProcessor implements ContainerAwareBatchErrorHandler
Deprecated.
in favor of DefaultErrorHandler.
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
  • 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 - the BackOff.
    • 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 - the BackOff.
      Since:
      2.3
  • 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<?,?> data, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, MessageListenerContainer container)
      Deprecated.
      Description copied from interface: BatchErrorHandler
      Handle the exception.
      Specified by:
      handle in interface BatchErrorHandler
      Specified by:
      handle in interface ConsumerAwareBatchErrorHandler
      Specified by:
      handle in interface ContainerAwareBatchErrorHandler
      Parameters:
      thrownException - the exception.
      data - the consumer records.
      consumer - the consumer.
      container - the container.