DivyanshIITB commented on code in PR #9257:
URL: https://github.com/apache/rocketmq/pull/9257#discussion_r2006186195


##########
client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java:
##########
@@ -120,12 +120,27 @@ public MessageQueue selectOneMessageQueue(final String 
lastBrokerName) {
         }
     }
 
-    public MessageQueue selectOneMessageQueue() {
+    private MessageQueue getMessageQueue() {
         int index = this.sendWhichQueue.incrementAndGet();
         int pos = index % this.messageQueueList.size();
-
         return this.messageQueueList.get(pos);
     }
+    
+    public MessageQueue selectOneMessageQueue() {
+        return getMessageQueue();
+    }
+
+    // Adding additional logic, filter by broker name
+    public MessageQueue selectOneMessageQueueWithCondition(String 
lastBrokerName) {

Review Comment:
   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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to