public class RecoveringBatchErrorHandler extends FailedRecordProcessor implements ContainerAwareBatchErrorHandler
BatchListenerFailedException, with the failed record. The
records before the record will have their offsets committed and the partitions for the
remaining records will be repositioned and/or the failed record can be recovered and
skipped. If some other exception is thrown, or a valid record is not provided in the
exception, error handling is delegated to a SeekToCurrentBatchErrorHandler with
this handler's BackOff. If the record is recovered, its offset is committed.logger| Constructor and Description |
|---|
RecoveringBatchErrorHandler()
Construct an instance with the default recoverer which simply logs the record after
(maxFailures) have occurred for a
topic/partition/offset.
|
RecoveringBatchErrorHandler(org.springframework.util.backoff.BackOff backOff)
Construct an instance with the default recoverer which simply logs the record after
the backOff returns STOP for a topic/partition/offset.
|
RecoveringBatchErrorHandler(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer)
Construct an instance with the provided recoverer which will be called after
(maxFailures) have occurred for a
topic/partition/offset.
|
RecoveringBatchErrorHandler(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
org.springframework.util.backoff.BackOff backOff)
Construct an instance with the provided recoverer which will be called after the
backOff returns STOP for a topic/partition/offset.
|
| Modifier and Type | Method and Description |
|---|---|
void |
handle(java.lang.Exception thrownException,
org.apache.kafka.clients.consumer.ConsumerRecords<?,?> data,
org.apache.kafka.clients.consumer.Consumer<?,?> consumer,
MessageListenerContainer container)
Handle the exception.
|
boolean |
isAckAfterHandle()
Return true if the offset should be committed for a handled error (no exception
thrown).
|
void |
setAckAfterHandle(boolean ackAfterHandle)
Set to false to prevent the container from committing the offset of a recovered
record (when the error handler does not itself throw an exception).
|
addNotRetryableException, clearThreadState, deliveryAttempt, getClassifier, getSkipPredicate, isCommitRecovered, removeNotRetryableException, setClassifications, setCommitRecovered, setResetStateOnRecoveryFailuregetLogLevel, setLogLevelclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandle, handlehandleclearThreadStatepublic RecoveringBatchErrorHandler()
public RecoveringBatchErrorHandler(org.springframework.util.backoff.BackOff backOff)
backOff - the BackOff.public RecoveringBatchErrorHandler(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer)
recoverer - the recoverer.public RecoveringBatchErrorHandler(@Nullable
java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
org.springframework.util.backoff.BackOff backOff)
recoverer - the recoverer; if null, the default (logging) recoverer is used.backOff - the BackOff.public boolean isAckAfterHandle()
GenericErrorHandlerisAckAfterHandle in interface GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>public void setAckAfterHandle(boolean ackAfterHandle)
GenericErrorHandlersetAckAfterHandle in interface GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecords<?,?>>ackAfterHandle - false to not commit.public void handle(java.lang.Exception thrownException,
org.apache.kafka.clients.consumer.ConsumerRecords<?,?> data,
org.apache.kafka.clients.consumer.Consumer<?,?> consumer,
MessageListenerContainer container)
BatchErrorHandlerhandle in interface BatchErrorHandlerhandle in interface ConsumerAwareBatchErrorHandlerhandle in interface ContainerAwareBatchErrorHandlerthrownException - the exception.data - the consumer records.consumer - the consumer.container - the container.