Class FailedBatchProcessor

All Implemented Interfaces:
DeliveryAttemptAware
Direct Known Subclasses:
DefaultErrorHandler

public abstract class FailedBatchProcessor extends FailedRecordProcessor
Subclass of FailedRecordProcessor that can process (and recover) a batch. If the listener throws a BatchListenerFailedException, the offsets prior to the failed record are committed and the remaining records (starting from the failed one) are re-sought for redelivery. When retries are exhausted, the failed record is sent to the recoverer instead of being included in the seeks. Any other exception type is delegated to the fallback handler.

Note: committing offsets for preceding records assumes those records were fully and irreversibly processed before the exception was thrown. Batch listeners that process records in parallel, use multi-step pipelines, or run inside a transaction should throw a plain RuntimeException instead of BatchListenerFailedException if they cannot guarantee that; doing so causes the full batch to be redelivered rather than silently skipping records whose side effects may not have completed.

Since:
2.8
See Also:
  • Constructor Details

    • FailedBatchProcessor

      public FailedBatchProcessor(@Nullable BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>, Exception> recoverer, org.springframework.util.backoff.BackOff backOff, CommonErrorHandler fallbackHandler)
      Construct an instance with the provided properties.
      Parameters:
      recoverer - the recoverer.
      backOff - the back off.
      fallbackHandler - the fallback handler.
    • FailedBatchProcessor

      public FailedBatchProcessor(@Nullable BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>, Exception> recoverer, org.springframework.util.backoff.BackOff backOff, @Nullable BackOffHandler backOffHandler, CommonErrorHandler fallbackHandler)
      Construct an instance with the provided properties.
      Parameters:
      recoverer - the recoverer.
      backOff - the back off.
      backOffHandler - the BackOffHandler
      fallbackHandler - the fallback handler.
      Since:
      2.9
  • Method Details