Skip to content

Refactored duplicate code in TopicPublishInfo#9257

Open
DivyanshIITB wants to merge 2 commits intoapache:developfrom
DivyanshIITB:fresh-start
Open

Refactored duplicate code in TopicPublishInfo#9257
DivyanshIITB wants to merge 2 commits intoapache:developfrom
DivyanshIITB:fresh-start

Conversation

@DivyanshIITB
Copy link
Copy Markdown
Contributor

Refactored TopicPublishInfo to remove duplicate code

  • Extracted common logic into a private method getMessageQueue.
  • Updated selectOneMessageQueue to use the new method.
  • Added a conditional version of queue selection for flexibility.

Resolves #6398

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 48.04%. Comparing base (2219fd8) to head (5c36694).

Files with missing lines Patch % Lines
...ocketmq/client/impl/producer/TopicPublishInfo.java 16.66% 5 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #9257      +/-   ##
=============================================
- Coverage      48.05%   48.04%   -0.01%     
- Complexity     12097    12100       +3     
=============================================
  Files           1322     1322              
  Lines          93127    93133       +6     
  Branches       11940    11941       +1     
=============================================
- Hits           44752    44747       -5     
- Misses         42831    42843      +12     
+ Partials        5544     5543       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

// Adding additional logic, filter by broker name
public MessageQueue selectOneMessageQueueWithCondition(String lastBrokerName) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When is this code called?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The method selectOneMessageQueue(String lastBrokerName) is called when selecting a message queue while avoiding the last used broker. It ensures that messages are not sent repeatedly to the same broker when possible, improving load balancing and fault tolerance.

If all available queues belong to the same broker, it falls back to selecting any queue

@DivyanshIITB
Copy link
Copy Markdown
Contributor Author

Hi @RongtongJin,
I wanted to check if you had any thoughts on my response. Please let me know if any clarifications or further details are needed. Thanks for your time!

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.

Remove duplicate code in TopicPublishInfo

3 participants