Class ExceptionClassifier
java.lang.Object
org.springframework.kafka.listener.KafkaExceptionLogLevelAware
org.springframework.kafka.listener.ExceptionClassifier
- Direct Known Subclasses:
DeadLetterPublishingRecoverer
,DefaultDestinationTopicResolver
,FailedRecordProcessor
Supports exception classification.
- Since:
- 2.8
- Author:
- Gary Russell
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addNotRetryableExceptions
(Class<? extends Exception>... exceptionTypes) Add exception types to the default list.final void
addRetryableExceptions
(Class<? extends Exception>... exceptionTypes) Add exception types that can be retried.void
By default, unmatched types classify as true.void
defaultFalse
(boolean retainStandardFatal) By default, unmatched types classify as true.Return a list of the framework default fatal exceptions.protected org.springframework.classify.BinaryExceptionClassifier
Return the exception classifier.protected void
notRetryable
(Stream<Class<? extends Exception>> notRetryable) Subclasses can override this to receive notification of configuration of not retryable exceptions.removeClassification
(Class<? extends Exception> exceptionType) Remove an exception type from the configured list.void
setClassifications
(Map<Class<? extends Throwable>, Boolean> classifications, boolean defaultValue) Set an exception classifications to determine whether the exception should cause a retry (until exhaustion) or not.Methods inherited from class org.springframework.kafka.listener.KafkaExceptionLogLevelAware
getLogLevel, setLogLevel
-
Constructor Details
-
ExceptionClassifier
public ExceptionClassifier()Construct the instance.
-
-
Method Details
-
defaultFatalExceptionsList
Return a list of the framework default fatal exceptions. This method produces a new list for each call, so changing the list's contents has no effect on the framework itself. Thus, it should be used only as a reference.- Returns:
- the default fatal exceptions list.
-
defaultFalse
public void defaultFalse(boolean retainStandardFatal) By default, unmatched types classify as true. Call this method to make the default false, and optionally retain types implicitly classified as false. This should be called before calling any of the classification modification methods. This can be useful if you want to classify a super class of one or more of the standard fatal exceptions as retryable.- Parameters:
retainStandardFatal
- true to retain.- Since:
- 3.0
-
defaultFalse
public void defaultFalse()By default, unmatched types classify as true. Call this method to make the default false, and remove types explicitly classified as false. This should be called before calling any of the classification modification methods.- Since:
- 2.8.4
-
getClassifier
protected org.springframework.classify.BinaryExceptionClassifier getClassifier()Return the exception classifier.- Returns:
- the classifier.
-
setClassifications
public void setClassifications(Map<Class<? extends Throwable>, Boolean> classifications, boolean defaultValue) Set an exception classifications to determine whether the exception should cause a retry (until exhaustion) or not. If not, we go straight to the recoverer. By default, the following exceptions will not be retried: All others will be retried. When calling this method, the defaults will not be applied.- Parameters:
classifications
- the classifications.defaultValue
- whether to retry non-matching exceptions.- See Also:
-
BinaryExceptionClassifier(Map, boolean)
addNotRetryableExceptions(Class...)
-
addNotRetryableExceptions
@SafeVarargs public final void addNotRetryableExceptions(Class<? extends Exception>... exceptionTypes) Add exception types to the default list. By default, the following exceptions will not be retried:DeserializationException
MessageConversionException
ConversionException
MethodArgumentResolutionException
NoSuchMethodException
ClassCastException
defaultFalse()
has been called.- Parameters:
exceptionTypes
- the exception types.- See Also:
-
notRetryable
Subclasses can override this to receive notification of configuration of not retryable exceptions.- Parameters:
notRetryable
- the not retryable exceptions.- Since:
- 2.9.3
-
addRetryableExceptions
Add exception types that can be retried. Call this afterdefaultFalse()
to specify those exception types that should be classified as true. All others will be retried, unlessdefaultFalse()
has been called.- Parameters:
exceptionTypes
- the exception types.- Since:
- 2.8.4
- See Also:
-
removeClassification
Remove an exception type from the configured list. By default, the following exceptions will not be retried:DeserializationException
MessageConversionException
ConversionException
MethodArgumentResolutionException
NoSuchMethodException
ClassCastException
defaultFalse()
has been called.- Parameters:
exceptionType
- the exception type.- Returns:
- the classification of the exception if removal was successful; null otherwise.
- Since:
- 2.8.4
- See Also:
-