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(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.
|
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,
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.
|
SeekToCurrentErrorHandler(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
int maxFailures)
Deprecated.
in favor of
SeekToCurrentErrorHandler(BiConsumer, BackOff).
IMPORTANT When using a FixedBackOff, the maxAttempts property
represents retries (one less than maxFailures). To retry indefinitely, use a
fixed or exponential BackOff configured appropriately.
To use the other constructor with the semantics of this one, with maxFailures
equal to 3, use
new SeekToCurrentErrorHandler(recoverer, new FixedBackOff(0L, 2L). |
SeekToCurrentErrorHandler(int maxFailures)
Deprecated.
in favor of
SeekToCurrentErrorHandler(BackOff).
IMPORTANT When using a FixedBackOff, the maxAttempts property
represents retries (one less than maxFailures). To retry indefinitely, use a
fixed or exponential BackOff configured appropriately.
To use the other constructor with the semantics of this one, with maxFailures
equal to 3, use new SeekToCurrentErrorHandler(new FixedBackOff(0L, 2L). |
| 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()
@Deprecated public SeekToCurrentErrorHandler(int maxFailures)
SeekToCurrentErrorHandler(BackOff).
IMPORTANT When using a FixedBackOff, the maxAttempts property
represents retries (one less than maxFailures). To retry indefinitely, use a
fixed or exponential BackOff configured appropriately.
To use the other constructor with the semantics of this one, with maxFailures
equal to 3, use new SeekToCurrentErrorHandler(new FixedBackOff(0L, 2L).maxFailures - the maxFailures; a negative value is treated as infinity.public SeekToCurrentErrorHandler(org.springframework.util.backoff.BackOff backOff)
backOff - the BackOff.public SeekToCurrentErrorHandler(java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer)
recoverer - the recoverer.@Deprecated
public SeekToCurrentErrorHandler(@Nullable
java.util.function.BiConsumer<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>,java.lang.Exception> recoverer,
int maxFailures)
SeekToCurrentErrorHandler(BiConsumer, BackOff).
IMPORTANT When using a FixedBackOff, the maxAttempts property
represents retries (one less than maxFailures). To retry indefinitely, use a
fixed or exponential BackOff configured appropriately.
To use the other constructor with the semantics of this one, with maxFailures
equal to 3, use
new SeekToCurrentErrorHandler(recoverer, new FixedBackOff(0L, 2L).recoverer - the recoverer; if null, the default (logging) recoverer is used.maxFailures - the maxFailures; a negative value is treated as infinity.public SeekToCurrentErrorHandler(@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.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()
GenericErrorHandlerclearThreadState in interface GenericErrorHandler<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>>