Skip to content

Conversation

LeeHyungGeol
Copy link
Contributor

@LeeHyungGeol LeeHyungGeol commented Oct 3, 2025

Fixes #3834

Description

Fixes validation logic for REUSABLE_RETRY_TOPIC to correctly handle multiple DLT topics in the destination chain.

Problem

When using sameIntervalTopicReuseStrategy = SINGLE_TOPIC with multiple DLTs configured through exceptionBasedDltRouting, the application failed to start with:

IllegalArgumentException: In the destination topic chain, the type REUSABLE_RETRY_TOPIC 
can only be specified as the last retry topic.

Solution

Modified DefaultDestinationTopicResolver.validateDestinations() to allow REUSABLE_RETRY_TOPIC to be followed by:

  • Nothing (last topic in chain)
  • One or more DLT topics

The validation still correctly rejects configurations where REUSABLE_RETRY_TOPIC is followed by regular RETRY, MAIN, or NO_OPS topics.

Changes

  • Core: DefaultDestinationTopicResolver.java: Updated validateDestinations() to check if all topics following a REUSABLE_RETRY_TOPIC are DLT topics
  • Unit Tests: Added 8 test cases covering valid and invalid configurations
  • Integration Tests: Added tests to verify runtime behavior with multiple DLTs, single DLT, and no DLT scenarios

Signed-off-by: LeeHyungGeol <rjf1138@naver.com>
@sobychacko
Copy link
Contributor

@LeeHyungGeol There are some checkstyle errros during the build. Could you address them? Thanks!

Signed-off-by: LeeHyungGeol <rjf1138@naver.com>
@LeeHyungGeol
Copy link
Contributor Author

LeeHyungGeol commented Oct 15, 2025

@sobychacko Thank you for the review! I've addressed all the checkstyle errors.

@sobychacko sobychacko merged commit d290b5e into spring-projects:main Oct 15, 2025
3 checks passed
sobychacko pushed a commit that referenced this pull request Oct 15, 2025
Fixes #3834

**Auto-cherry-pick to `3.3.x`**

Relaxes the validation constraint for `REUSABLE_RETRY_TOPIC` to allow it to be followed by
multiple DLT topics, enabling exception-based DLT routing with reusable retry topics.

Problem:

When using `sameIntervalTopicReuseStrategy = SINGLE_TOPIC` with multiple DLTs configured
through `exceptionBasedDltRouting`, the application failed to start with:

    `IllegalArgumentException`: In the destination topic chain, the type
    `REUSABLE_RETRY_TOPIC` can only be specified as the last retry topic.

This prevented exception-based DLT routing scenarios like:
    Main Topic → Reusable Retry Topic → Custom DLT → Default DLT

Previous Behavior:
  `REUSABLE_RETRY_TOPIC` could only be:
  - The last topic in the chain, OR
  - Followed by exactly one DLT topic

New Behavior:
  `REUSABLE_RETRY_TOPIC` can now be followed by multiple DLT topics, as long as all subsequent
   topics are DLT types. The validation still correctly rejects configurations where `REUSABLE_RETRY_TOPIC`
   is followed by regular `RETRY, MAIN`, or `NO_OPS` topics.

  Changes:
  - Updates `validateDestinations()` to use stream-based validation that
    checks all subsequent topics are DLTs
  - Uses lambda supplier for error message (lazy evaluation for better
    performance on the happy path)
  - Improves error message clarity: "followed only by DLT topics"
  - Adds 8 unit tests covering positive and negative validation cases
  - Adds 3 integration tests verifying runtime behavior with multiple
    DLTs, single DLT, and no DLT scenarios

Signed-off-by: LeeHyungGeol <rjf1138@naver.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In the destination topic chain, the type REUSABLE_RETRY_TOPIC can only be specified as the last retry topic

2 participants