Skip to content

Comments

[Issue #1458] Reduce unnecessary creation of retry topics and DLQ topics#1459

Open
zjxxzjwang wants to merge 5 commits intoapache:masterfrom
zjxxzjwang:master-Reduce-unnecessary-loading-of-retry-topics-and-dlq
Open

[Issue #1458] Reduce unnecessary creation of retry topics and DLQ topics#1459
zjxxzjwang wants to merge 5 commits intoapache:masterfrom
zjxxzjwang:master-Reduce-unnecessary-loading-of-retry-topics-and-dlq

Conversation

@zjxxzjwang
Copy link

@zjxxzjwang zjxxzjwang commented Jan 21, 2026

Motivation

Reduce unnecessary creation of retry topic and DLQ topic.

The following scenarios:

  1. When retryLetterTopic is not set but deadLetterTopic is set
  2. When retryLetterTopic is set but deadLetterTopic is not set

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

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@RobertIndie RobertIndie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a test for it?

@zjxxzjwang
Copy link
Author

Is it possible to add a test for it?

I have added a test case, please review it. @RobertIndie

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.

2 participants