Class ErrorHandlingUtils


  • public final class ErrorHandlingUtils
    extends java.lang.Object
    Utilities for error handling.
    Since:
    2.8
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String recordsToString​(org.apache.kafka.clients.consumer.ConsumerRecords<?,​?> records)
      Represent the records as a comma-delimited String of topic-part@offset.
      static void retryBatch​(java.lang.Exception thrownException, org.apache.kafka.clients.consumer.ConsumerRecords<?,​?> records, org.apache.kafka.clients.consumer.Consumer<?,​?> consumer, MessageListenerContainer container, java.lang.Runnable invokeListener, org.springframework.util.backoff.BackOff backOff, CommonErrorHandler seeker, java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecords<?,​?>,​java.lang.Exception> recoverer, org.springframework.core.log.LogAccessor logger, KafkaException.Level logLevel)
      Retry a complete batch by pausing the consumer and then, in a loop, poll the consumer, wait for the next back off, then call the listener.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • retryBatch

        public static void retryBatch​(java.lang.Exception thrownException,
                                      org.apache.kafka.clients.consumer.ConsumerRecords<?,​?> records,
                                      org.apache.kafka.clients.consumer.Consumer<?,​?> consumer,
                                      MessageListenerContainer container,
                                      java.lang.Runnable invokeListener,
                                      org.springframework.util.backoff.BackOff backOff,
                                      CommonErrorHandler seeker,
                                      java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecords<?,​?>,​java.lang.Exception> recoverer,
                                      org.springframework.core.log.LogAccessor logger,
                                      KafkaException.Level logLevel)
        Retry a complete batch by pausing the consumer and then, in a loop, poll the consumer, wait for the next back off, then call the listener. When retries are exhausted, call the recoverer with the ConsumerRecords.
        Parameters:
        thrownException - the exception.
        records - the records.
        consumer - the consumer.
        container - the container.
        invokeListener - the Runnable to run (call the listener).
        backOff - the backOff.
        seeker - the common error handler that re-seeks the entire batch.
        recoverer - the recoverer.
        logger - the logger.
        logLevel - the log level.
      • recordsToString

        public static java.lang.String recordsToString​(org.apache.kafka.clients.consumer.ConsumerRecords<?,​?> records)
        Represent the records as a comma-delimited String of topic-part@offset.
        Parameters:
        records - the records.
        Returns:
        the String.