public class RetryingBatchErrorHandler extends KafkaExceptionLogLevelAware implements ListenerInvokingBatchErrorHandler
BackOff. The consumer is paused/polled/resumed before each retry in order to
avoid a rebalance. If/when retries are exhausted, the provided
ConsumerRecordRecoverer is invoked. If the recoverer throws an exception, or
the thread is interrupted while sleeping, seeks are performed so that the batch will be
redelivered on the next poll.| Constructor and Description |
|---|
RetryingBatchErrorHandler()
Construct an instance with a default
FixedBackOff (unlimited attempts with
a 5 second back off). |
RetryingBatchErrorHandler(org.springframework.util.backoff.BackOff backOff,
ConsumerRecordRecoverer recoverer)
Construct an instance with the provided
BackOff and
ConsumerRecordRecoverer. |
| Modifier and Type | Method and Description |
|---|---|
void |
handle(java.lang.Exception thrownException,
org.apache.kafka.clients.consumer.ConsumerRecords<?,?> records,
org.apache.kafka.clients.consumer.Consumer<?,?> consumer,
MessageListenerContainer container,
java.lang.Runnable invokeListener)
Handle the exception.
|
getLogLevel, setLogLevelclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlehandlehandleclearThreadState, isAckAfterHandlepublic RetryingBatchErrorHandler()
FixedBackOff (unlimited attempts with
a 5 second back off).public RetryingBatchErrorHandler(org.springframework.util.backoff.BackOff backOff,
@Nullable
ConsumerRecordRecoverer recoverer)
BackOff and
ConsumerRecordRecoverer. If the recoverer is null, the discarded
records (topic-partition@offset) will be logged.backOff - the back off.recoverer - the recoverer.public void handle(java.lang.Exception thrownException,
org.apache.kafka.clients.consumer.ConsumerRecords<?,?> records,
org.apache.kafka.clients.consumer.Consumer<?,?> consumer,
MessageListenerContainer container,
java.lang.Runnable invokeListener)
ContainerAwareBatchErrorHandlerhandle in interface BatchErrorHandlerhandle in interface ContainerAwareBatchErrorHandlerhandle in interface ListenerInvokingBatchErrorHandlerthrownException - the exception.records - the consumer records.consumer - the consumer.container - the container.invokeListener - a callback to re-invoke the listener.