GenerousMan commented on code in PR #9637:
URL: https://github.com/apache/rocketmq/pull/9637#discussion_r2297172564


##########
broker/src/main/java/org/apache/rocketmq/broker/longpolling/PopLongPollingService.java:
##########
@@ -163,11 +164,47 @@ public void notifyMessageArrivingWithRetryTopic(final 
String topic, final int qu
         if (KeyBuilder.isPopRetryTopicV2(topic)) {
             notifyTopic = KeyBuilder.parseNormalTopic(topic);
         } else {
-            notifyTopic = topic;
+            if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
+                notifyTopic = findTopicForV1RetryTopic(topic);
+            else notifyTopic = topic;
         }
         notifyMessageArriving(notifyTopic, queueId, offset, tagsCode, 
msgStoreTime, filterBitMap, properties);
     }
 
+    /**
+     * Find the correct topic name for V1 retry topic by checking topicCidMap
+     * @param retryTopic V1 retry topic name
+     * @return the original topic name, retryTopic otherwise
+     */
+    private String findTopicForV1RetryTopic(String retryTopic) {
+        // Check if the potential group exists in topicCidMap
+        boolean hasDuplicatedTopic = false;
+        String originalTopic = null;
+        for (String topic : topicCidMap.keySet()) {

Review Comment:
   Here, using “_” directly as the delimiter and basing topic/cid detection and 
duplicate checks on the split result avoids most traversal overhead, reducing 
the time complexity from O(mn) to nearly O(1).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to