public class SeekToCurrentErrorHandler extends java.lang.Object implements ContainerAwareErrorHandler
| Modifier and Type | Field and Description |
|---|---|
protected static org.springframework.core.log.LogAccessor |
LOGGER |
| Constructor and Description |
|---|
SeekToCurrentErrorHandler()
Construct an instance with the default recoverer which simply logs the record after
(maxFailures) have occurred for a
topic/partition/offset.
|
SeekToCurrentErrorHandler(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.
|
SeekToCurrentErrorHandler(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
int maxFailures)
Construct an instance with the provided recoverer which will be called after
maxFailures have occurred for a topic/partition/offset.
|
SeekToCurrentErrorHandler(int maxFailures)
Construct an instance with the default recoverer which simply logs the record after
'maxFailures' have occurred for a topic/partition/offset.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNotRetryableException(java.lang.Class<? extends java.lang.Exception> exceptionType)
Add an exception type to the default list; if and only if an external classifier
has not been provided.
|
void |
clearThreadState()
Optional method to clear thread state; will be called just before a consumer
thread terminates.
|
protected org.springframework.classify.BinaryExceptionClassifier |
getClassifier()
Return the exception classifier.
|
void |
handle(java.lang.Exception thrownException,
java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records,
org.apache.kafka.clients.consumer.Consumer<?,?> consumer,
MessageListenerContainer container)
Handle the exception.
|
protected boolean |
isCommitRecovered()
Whether the offset for a recovered record should be committed.
|
boolean |
removeNotRetryableException(java.lang.Class<? extends java.lang.Exception> exceptionType)
Remove an exception type from the configured list; if and only if an external
classifier has not been provided.
|
void |
setClassifier(org.springframework.classify.BinaryExceptionClassifier classifier)
Set an exception classifier to determine whether the exception should cause a retry
(until exhaustion) or not.
|
void |
setCommitRecovered(boolean commitRecovered)
Set to true to commit the offset for a recovered record.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlehandlehandlepublic SeekToCurrentErrorHandler()
public SeekToCurrentErrorHandler(int maxFailures)
maxFailures - the maxFailures; a negative value is treated as infinity.public SeekToCurrentErrorHandler(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer)
recoverer - the recoverer.public SeekToCurrentErrorHandler(@Nullable
java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
int maxFailures)
recoverer - the recoverer; if null, the default (logging) recoverer is used.maxFailures - the maxFailures; a negative value is treated as infinity.protected boolean isCommitRecovered()
public void setCommitRecovered(boolean commitRecovered)
ContainerProperties.AckMode.MANUAL_IMMEDIATE. Whether or not
the commit is sync or async depends on the container's syncCommits
property.commitRecovered - true to commit.protected org.springframework.classify.BinaryExceptionClassifier getClassifier()
public void setClassifier(org.springframework.classify.BinaryExceptionClassifier classifier)
DeserializationExceptionMessageConversionExceptionMethodArgumentResolutionExceptionNoSuchMethodExceptionClassCastExceptiontraverseCauses
will be set to true because the container always wraps exceptions in a
ListenerExecutionFailedException.
This replaces the default classifier.classifier - the classifier.public void addNotRetryableException(java.lang.Class<? extends java.lang.Exception> exceptionType)
DeserializationExceptionMessageConversionExceptionMethodArgumentResolutionExceptionNoSuchMethodExceptionClassCastExceptionexceptionType - the exception type.removeNotRetryableException(Class),
setClassifier(BinaryExceptionClassifier)public boolean removeNotRetryableException(java.lang.Class<? extends java.lang.Exception> exceptionType)
DeserializationExceptionMessageConversionExceptionMethodArgumentResolutionExceptionNoSuchMethodExceptionClassCastExceptionexceptionType - the exception type.addNotRetryableException(Class),
setClassifier(BinaryExceptionClassifier)public void handle(java.lang.Exception thrownException,
java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>> records,
org.apache.kafka.clients.consumer.Consumer<?,?> consumer,
MessageListenerContainer container)
ErrorHandlerhandle in interface ConsumerAwareErrorHandlerhandle in interface ContainerAwareErrorHandlerhandle in interface ErrorHandlerhandle in interface RemainingRecordsErrorHandlerthrownException - the exception.records - the remaining records including the one that failed.consumer - the consumer.container - the container.public void clearThreadState()
ErrorHandlerclearThreadState in interface ErrorHandler