Skip to content

Fatal exceptions in Combining Blocking and Non-Blocking Retries #2457

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

Closed
garyrussell opened this issue Oct 24, 2022 Discussed in #2455 · 2 comments · Fixed by #2458
Closed

Fatal exceptions in Combining Blocking and Non-Blocking Retries #2457

garyrussell opened this issue Oct 24, 2022 Discussed in #2455 · 2 comments · Fixed by #2458
Assignees
Milestone

Comments

@garyrussell
Copy link
Contributor

Discussed in #2455

Originally posted by jgslima October 20, 2022
Documentation reference: link.

"In combination with the global retryable topic’s fatal exceptions classification, you can configure the framework for any behavior you’d like, such as having some exceptions trigger both blocking and non-blocking retries, trigger only one kind or the other, or go straight to the DLT without retries of any kind."

I was not able to understand how to configure something like this:

  • activate blocking retries for exceptions of type RuntimeException (which I have done by making blockingRetries.retryOn(RuntimeException.class));
  • but configuring some specific sub-classes of RuntimeException to go directly do DLT. For that, I tried to add them in manageNonBlockingFatalExceptions().

But, as far as I can verify here, exceptions added to manageNonBlockingFatalExceptions(), are used to skip just the "non blocking" retries, not the blocking ones. For example, when just making blockingRetries.retryOn(RuntimeException.class) if the listener throws a MessageConversionException (which is a pre-defined fatal exception) it goes through the blocking retries (and after that, it correctly skips the non blocking retries). This is not in accordance to the example code of the documentation, in regard to ShouldSkipBothRetriesException.

Also, I think the documentation above is a bit confusing. In the code example "Here’s an example with both configurations working together:", I do not understand how the behaviour for ShouldRetryOnlyBlockingException and ShouldRetryViaBothException would be different, because both are just being passed in blockingRetries.retryOn().

Thank you.

@garyrussell
Copy link
Contributor Author

Closing as invalid - the exception classifier always goes up the class hierarchy to find a classification, before traversing causes.

@garyrussell
Copy link
Contributor Author

Reinstated; I found a solution.

@garyrussell garyrussell reopened this Oct 24, 2022
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Oct 24, 2022
Resolves spring-projects#2457

Previously, classifying `RuntimeException` either for no retries or for
blocking retries would cause undesirable effects - its classification
would be found first because the classifier first traverses up the
class hierarchy to find a match before traversing down the cause links.

When classifying exception for retry, unwrap the 'LEFE' cause from a
`TimestampedException` and/or `ListenerExecutionFailedException` so
that the classification is made on that cause.

By default, the retry classifier has no classified exceptions when
used in "classify for retry" mode (instead of the default "classify
for no retry" mode). This means that, if `retryOn(RuntimeException.class)`
is used, then all `RuntimeException`s will be retried (including those
that are usually considered fatal).

With mixed blocking/non-blocking retries, change the behavior to include
the standard fatal exceptions in case the user configures all `RuntimeException`s
to use blocking retries.

Also tested with a Boot app to see that a conversion exception bypasses
all retries and goes straight to the DLT.
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Oct 24, 2022
Resolves spring-projects#2457

Previously, classifying `RuntimeException` either for no retries or for
blocking retries would cause undesirable effects - its classification
would be found first because the classifier first traverses up the
class hierarchy to find a match before traversing down the cause links.

When classifying exception for retry, unwrap the 'LEFE' cause from a
`TimestampedException` and/or `ListenerExecutionFailedException` so
that the classification is made on that cause.

By default, the retry classifier has no classified exceptions when
used in "classify for retry" mode (instead of the default "classify
for no retry" mode). This means that, if `retryOn(RuntimeException.class)`
is used, then all `RuntimeException`s will be retried (including those
that are usually considered fatal).

With mixed blocking/non-blocking retries, change the behavior to include
the standard fatal exceptions in case the user configures all `RuntimeException`s
to use blocking retries.

Also tested with a Boot app to see that a conversion exception bypasses
all retries and goes straight to the DLT.
artembilan pushed a commit that referenced this issue Oct 24, 2022
Resolves #2457

Previously, classifying `RuntimeException` either for no retries or for
blocking retries would cause undesirable effects - its classification
would be found first because the classifier first traverses up the
class hierarchy to find a match before traversing down the cause links.

When classifying exception for retry, unwrap the 'LEFE' cause from a
`TimestampedException` and/or `ListenerExecutionFailedException` so
that the classification is made on that cause.

By default, the retry classifier has no classified exceptions when
used in "classify for retry" mode (instead of the default "classify
for no retry" mode). This means that, if `retryOn(RuntimeException.class)`
is used, then all `RuntimeException`s will be retried (including those
that are usually considered fatal).

With mixed blocking/non-blocking retries, change the behavior to include
the standard fatal exceptions in case the user configures all `RuntimeException`s
to use blocking retries.

Also tested with a Boot app to see that a conversion exception bypasses
all retries and goes straight to the DLT.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant