Skip to content
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

Consider routing messages that fail due to a fatal exception straight into the dead letter topic #2113

Closed
v-chernyshev opened this issue Feb 17, 2022 · 4 comments · Fixed by #2123

Comments

@v-chernyshev
Copy link

Expected Behavior

It would be great to have a setting that would instruct the retryable topics system to skip the recovery attempts if one of the fatal-by-default exceptions is encountered during the message processing as it is highly likely that the malformed messages will fail in the retry topics too.

Current Behavior

The current implementation (assuming no notRetryOn overrides) routes the failed messages to the next retry topic in the recovery chain, until they eventually reach the DLT. There doesn't seem to be a way to programmatically query the default list of fatal exceptions either, which basically means that I have to copy-paste them somewhere to pass into noRetryOn.

Context

The main goal here is to avoid pointless recovery attempts for poison pill messages. See this StackOverflow question for more information. The only workaround I can think of is declaring a duplicate list of fatal exceptions, e.g.:

private static final List<Class<? extends Throwable>> FATAL_EXCEPTIONS = List.of(
        DeserializationException.class,
        MessageConversionException.class,
        ConversionException.class,
        MethodArgumentResolutionException.class,
        NoSuchMethodException.class,
        ClassCastException.class);

It may then be passed into notRetryOn.

@tomazfernandes
Copy link
Contributor

Hi @v-chernyshev, thanks for the suggestion.

Just to be clear, we're talking about a manageable global set of FATAL exceptions that will route the record straight to the DLT, different from the topic-by-topic classification configuration we currently have.

I'm currently working on another issue that is related and should address this too, so hopefully we should have this ready soon.

tomazfernandes added a commit to tomazfernandes/spring-kafka that referenced this issue Feb 20, 2022
Fixes spring-projectsGH-2118

The logic introduced to stop endless loops in DLR processing for fatal exceptions interferes with RT's single-topic strategy.
Make it optional and set the default to false in DLPRF for RT.
The loop is now addressed in DefaultDestinationTopicResolver as in spring-projectsGH-2113.
tomazfernandes added a commit to tomazfernandes/spring-kafka that referenced this issue Feb 20, 2022
Resolves spring-projectsGH-2113

Adds exception classification to DefaultDestinationTopicResolver so that fatal exceptions makes records go straight to the DLT.
Also stop DLT processing if such an exception is found (see spring-projectsGH-2118).
@tomazfernandes
Copy link
Contributor

@v-chernyshev, I opened a PR with this feature, if maybe you want to take a look
#2123

Thanks again for the suggestion

@garyrussell garyrussell added this to the 3.0.0-M2 milestone Feb 21, 2022
garyrussell pushed a commit that referenced this issue Feb 21, 2022
Resolves GH-2113

Adds exception classification to DefaultDestinationTopicResolver so that fatal exceptions makes records go straight to the DLT.
Also stop DLT processing if such an exception is found (see GH-2118).
garyrussell pushed a commit that referenced this issue Feb 21, 2022
Fixes GH-2118

The logic introduced to stop endless loops in DLR processing for fatal exceptions interferes with RT's single-topic strategy.
Make it optional and set the default to false in DLPRF for RT.
The loop is now addressed in DefaultDestinationTopicResolver as in GH-2113.
garyrussell pushed a commit that referenced this issue Feb 21, 2022
Resolves GH-2113

Adds exception classification to DefaultDestinationTopicResolver so that fatal exceptions makes records go straight to the DLT.
Also stop DLT processing if such an exception is found (see GH-2118).
garyrussell pushed a commit that referenced this issue Feb 21, 2022
Fixes GH-2118

The logic introduced to stop endless loops in DLR processing for fatal exceptions interferes with RT's single-topic strategy.
Make it optional and set the default to false in DLPRF for RT.
The loop is now addressed in DefaultDestinationTopicResolver as in GH-2113.
@v-chernyshev
Copy link
Author

Thanks for implementing this suggestion so quickly! I had a look through the PR and it looks good to me, but I'm by no means comfortable with the implementation details of Spring Kafka :)

@tomazfernandes
Copy link
Contributor

@v-chernyshev thanks for looking into the PR and for the feature suggestion. This feature will be available in today’s release, feel free to try it out and provide feedback!

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.

3 participants