-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addRetryableExceptions has no effect when called on the DefaultErrorHandler #3621
Comments
So, logic there in the
So, yeah, whatever we set into that We probably need to propagate those
BTW, you can use that Feel free to contribute the fix: https://github.com/spring-projects/spring-kafka/blob/main/CONTRIBUTING.adoc ! |
Hi, @devjeff ! |
Hi. I had no time to work on it so far. Therefore, it would be nice if you can take it over 👍 |
@devjeff Thanks a lot! I'm going to dig into this 😃 |
Hi, @artembilan , @devjeff . Hm... I think errorHandler.setRetryListeners(retryListener);
errorHandler.addNotRetryableExceptions(MyCustomException.class);
factory.setCommonErrorHandler(errorHandler); After batch listener throws Then, the In conclusion, IMHO, it does works well. For your informationLines 152 to 154 in 70a11a6
spring-kafka/spring-kafka/src/main/java/org/springframework/kafka/listener/ExceptionClassifier.java Lines 105 to 107 in 70a11a6
spring-kafka/spring-kafka/src/main/java/org/springframework/kafka/listener/ErrorHandlingUtils.java Lines 103 to 106 in 70a11a6
Then, |
Yes, I've seen this code, but the exceptions were not added to the classifier of the FallbackBatchErrorHandler. The classifier from the DefaultErrorHandler is not forwarded to the FallbackBatchErrorHandler in any way. Maybe you encountered some default behaviour. Can you try to add the exception to retryable exceptions and check if this works?
|
@devjeff
If I configure
In conclusion, If you are still in trouble, how about checking whether the |
In what version(s) of Spring for Apache Kafka are you seeing this issue?
3.2.4
Describe the bug
I tried to use the DefaultErrorHandler with a batch message listener. Here I wanted to specify some retryable exceptions (e. g. JDBCConnectionException) that cause a retry (as long as the backoff limit is not exceeded). What I noticed, is that calls to the metods "addRetryableExceptions " and "addNotRetryableExceptions" apparently have no effect.
The DefaultErrorHandler delegates error handling to a FallbackBatchErrorHandler (if the thrown exception is not a BatchListenerFailedException), but this handler never accesses the internal classifier instance of the DefaultErrorHandler, but instead creates a new one with the default exception list, s. also default constructor of the ExceptionClassifier.
To Reproduce
cf.setCommonErrorHandler(errorHandler)
cf.setBatchListener(true);
, although I think that this is not necessary to reproduce the problemExpected behavior
Maybe, this is the desired behaviour. If the message recovery fails, then the batch will be consumed again by the next poll anyway, which is effectively the same as a retry (and can result in an endless loop until the error is fixed). Still I think, that the DefaultErrorHandler should either not extend ExceptionClassifier or at least contain a description in the Javadoc explaining that the "addRetryableExceptions " and "addNotRetryableExceptions" have no effect on this class.
The text was updated successfully, but these errors were encountered: