[Issue #1458] Reduce unnecessary creation of retry topics and DLQ topics#1459
Open
zjxxzjwang wants to merge 5 commits intoapache:masterfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the consumer initialization process by reducing unnecessary metadata lookups for retry and dead letter queue (DLQ) topics. Previously, the code always queried both old-format retry and DLQ topics regardless of whether they were already configured. The optimization now only checks for old topic formats when the corresponding fields are not set, avoiding redundant network calls.
Changes:
- Refactored metadata lookup logic into a helper function
CheckTopicIsExists - Added conditional checks to only query old topic formats when DLQ policy fields are empty
- Improved logic to handle scenarios where only retry or only DLQ topics are configured
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RobertIndie
reviewed
Jan 30, 2026
Member
RobertIndie
left a comment
There was a problem hiding this comment.
Is it possible to add a test for it?
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Author
I have added a test case, please review it. @RobertIndie |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Reduce unnecessary creation of retry topic and DLQ topic.
The following scenarios:
These scenarios will trigger the getPartitionedTopicMetadata operation for both the retry topic and DLQ topic, resulting in the loading of the default retry topic and default DLQ topic. This leads to resource wastage.
Modifications
Perform verification separately. If retryLetterTopic or deadLetterTopic is set, do not proceed to getPartitionedTopicMetadata.
Documentation
docdoc-requireddoc-not-neededdoc-complete