Class ErrorHandlingUtils
- java.lang.Object
-
- org.springframework.kafka.listener.ErrorHandlingUtils
-
public final class ErrorHandlingUtils extends java.lang.ObjectUtilities for error handling.- Since:
- 2.8
- Author:
- Gary Russell
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidclearRetryListeners()Clear the retry listeners.static java.lang.StringrecordsToString(org.apache.kafka.clients.consumer.ConsumerRecords<?,?> records)Represent the records as a comma-delimited String oftopic-part@offset.static voidretryBatch(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)static voidretryBatch(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, java.util.List<RetryListener> retryListenersArg, org.springframework.classify.BinaryExceptionClassifier classifier)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.static voidsetRetryListeners(java.util.List<RetryListener> listeners)Set the retry listeners.static java.lang.ExceptionunwrapIfNeeded(java.lang.Exception exception)Remove aTimestampedException, if present.
-
-
-
Method Detail
-
setRetryListeners
public static void setRetryListeners(java.util.List<RetryListener> listeners)
Set the retry listeners.- Parameters:
listeners- the listeners.- Since:
- 2.8.10
-
clearRetryListeners
public static void clearRetryListeners()
Clear the retry listeners.- Since:
- 2.8.10
-
retryBatch
@Deprecated 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)Deprecated.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 theConsumerRecords.- Parameters:
thrownException- the exception.records- the records.consumer- the consumer.container- the container.invokeListener- theRunnableto 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.
-
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, @Nullable java.util.List<RetryListener> retryListenersArg, org.springframework.classify.BinaryExceptionClassifier classifier)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 theConsumerRecords.- Parameters:
thrownException- the exception.records- the records.consumer- the consumer.container- the container.invokeListener- theRunnableto 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.retryListenersArg- the retry listeners.classifier- the exception classifier.- Since:
- 2.8.11
-
recordsToString
public static java.lang.String recordsToString(org.apache.kafka.clients.consumer.ConsumerRecords<?,?> records)
Represent the records as a comma-delimited String oftopic-part@offset.- Parameters:
records- the records.- Returns:
- the String.
-
unwrapIfNeeded
public static java.lang.Exception unwrapIfNeeded(java.lang.Exception exception)
Remove aTimestampedException, if present. Remove aListenerExecutionFailedException, if present.- Parameters:
exception- the exception.- Returns:
- the unwrapped cause or cause of cause.
- Since:
- 2.8.11
-
-