You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/08/02 08:40:16 UTC

[GitHub] [rocketmq] RongtongJin commented on a change in pull request #3208: [ISSUE #3207] Improve the topicPublishInfo cache in producer

RongtongJin commented on a change in pull request #3208:
URL: https://github.com/apache/rocketmq/pull/3208#discussion_r680780898



##########
File path: client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
##########
@@ -713,15 +713,25 @@ private TopicPublishInfo tryToFindTopicPublishInfo(final String topic) {
         TopicPublishInfo topicPublishInfo = this.topicPublishInfoTable.get(topic);
         if (null == topicPublishInfo || !topicPublishInfo.ok()) {
             this.topicPublishInfoTable.putIfAbsent(topic, new TopicPublishInfo());
-            this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
             topicPublishInfo = this.topicPublishInfoTable.get(topic);
+            if (!topicPublishInfo.checkNotFoundFlag()) {
+                this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
+                topicPublishInfo = this.topicPublishInfoTable.get(topic);
+            }
         }
 
         if (topicPublishInfo.isHaveTopicRouterInfo() || topicPublishInfo.ok()) {
             return topicPublishInfo;
         } else {
-            this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);
-            topicPublishInfo = this.topicPublishInfoTable.get(topic);
+            boolean found;
+            if (!topicPublishInfo.checkNotFoundFlag()) {
+                found = this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);

Review comment:
       updateTopicRouteInfoFromNameServer return to whether topicRouteInfo is changed, not whether the route is found

##########
File path: client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
##########
@@ -713,15 +713,25 @@ private TopicPublishInfo tryToFindTopicPublishInfo(final String topic) {
         TopicPublishInfo topicPublishInfo = this.topicPublishInfoTable.get(topic);
         if (null == topicPublishInfo || !topicPublishInfo.ok()) {
             this.topicPublishInfoTable.putIfAbsent(topic, new TopicPublishInfo());
-            this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
             topicPublishInfo = this.topicPublishInfoTable.get(topic);
+            if (!topicPublishInfo.checkNotFoundFlag()) {
+                this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
+                topicPublishInfo = this.topicPublishInfoTable.get(topic);
+            }
         }
 
         if (topicPublishInfo.isHaveTopicRouterInfo() || topicPublishInfo.ok()) {
             return topicPublishInfo;
         } else {
-            this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);
-            topicPublishInfo = this.topicPublishInfoTable.get(topic);
+            boolean found;
+            if (!topicPublishInfo.checkNotFoundFlag()) {
+                found = this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);
+                topicPublishInfo = this.topicPublishInfoTable.get(topic);
+                if (!found) {
+                    topicPublishInfo.setNotFoundFlag();

Review comment:
       Is it appropriate to set the origin topic not found flag here?




-- 
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: dev-unsubscribe@rocketmq.apache.org

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