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 have seeks performed. When the retries are exhausted, the failed record is sent to the recoverer instead of being included in the seeks. If other exceptions are thrown processing is delegated to the fallback handler.
    Since:
    2.8
    • Constructor Detail

      • FailedBatchProcessor

        public FailedBatchProcessor​(@Nullable
                                    java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>,​java.lang.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 fall back handler.
      • FailedBatchProcessor

        public FailedBatchProcessor​(@Nullable
                                    java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>,​java.lang.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 fall back handler.
        Since:
        2.9
    • Method Detail

      • getFallbackBatchHandler

        protected CommonErrorHandler getFallbackBatchHandler()
        Return the fallback batch error handler.
        Returns:
        the handler.
        Since:
        2.8.8
      • doHandle

        protected void doHandle​(java.lang.Exception thrownException,
                                org.apache.kafka.clients.consumer.ConsumerRecords<?,​?> data,
                                org.apache.kafka.clients.consumer.Consumer<?,​?> consumer,
                                MessageListenerContainer container,
                                java.lang.Runnable invokeListener)
      • handle

        protected <K,​V> org.apache.kafka.clients.consumer.ConsumerRecords<K,​V> handle​(java.lang.Exception thrownException,
                                                                                                  org.apache.kafka.clients.consumer.ConsumerRecords<?,​?> data,
                                                                                                  org.apache.kafka.clients.consumer.Consumer<?,​?> consumer,
                                                                                                  MessageListenerContainer container,
                                                                                                  java.lang.Runnable invokeListener)