RongtongJin commented on code in PR #9549:
URL: https://github.com/apache/rocketmq/pull/9549#discussion_r2350415353


##########
broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java:
##########
@@ -310,6 +321,12 @@ public TopicConfig createTopicInSendMessageMethod(final 
String topic, final Stri
 
         if (createNew) {
             registerBrokerData(topicConfig);
+
+            if 
(this.brokerController.getBrokerConfig().isEnableRouteChangeNotification()
+                && this.brokerController.getRouteEventService() != null) {
+                this.brokerController.getRouteEventService().publishEvent(
+                    RouteEventType.TOPIC_CHANGE, topicConfig.getTopicName());
+            }

Review Comment:
   这些后面类似的重复的代码需要收敛到一起



##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1834,6 +1846,20 @@ public void run() {
                 }
             }
         }, 10, 5, TimeUnit.SECONDS);
+
+        if (this.routeEventService != null && this.topicConfigManager != null) 
{
+            Set<String> topics = 
this.topicConfigManager.getTopicConfigTable().keySet();
+            
+            for (String topic : topics) {
+                try {
+                    this.routeEventService.publishEvent(RouteEventType.START, 
topic);
+                    LOG.info("[START]: publish {}", topic);
+                } catch (Exception e) {
+                    LOG.error("Failed to publish route change event for topic: 
{}", topic, e);
+                }
+            }
+            LOG.info("Published route change events for {} topics", 
topics.size());
+        }

Review Comment:
   如果启动事件也要一个个通知的话,topic数量级百万情况下,量会很大



##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1392,6 +1401,9 @@ public ChangeInvisibleTimeProcessor 
getChangeInvisibleTimeProcessor() {
     protected void shutdownBasicService() {
 
         shutdown = true;
+        if (this.routeEventService != null) {

Review Comment:
   enableRouteChangeNotification在start和shutdown同样要起作用



##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1392,6 +1401,9 @@ public ChangeInvisibleTimeProcessor 
getChangeInvisibleTimeProcessor() {
     protected void shutdownBasicService() {
 
         shutdown = true;
+        if (this.routeEventService != null) {
+            this.routeEventService.publishEvent(RouteEventType.SHUTDOWN);
+        }

Review Comment:
   在unregisterBrokerAll之后 shutdown是最保险的,此时broker已经取消注册,proxy就能拿到下线的路由



##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1392,6 +1401,9 @@ public ChangeInvisibleTimeProcessor 
getChangeInvisibleTimeProcessor() {
     protected void shutdownBasicService() {
 
         shutdown = true;
+        if (this.routeEventService != null) {
+            this.routeEventService.publishEvent(RouteEventType.SHUTDOWN);
+        }

Review Comment:
   在unregisterBrokerAll之后 shutdown是最保险的,此时broker已经取消注册,proxy就能拿到下线的路由



##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1834,6 +1846,20 @@ public void run() {
                 }
             }
         }, 10, 5, TimeUnit.SECONDS);
+
+        if (this.routeEventService != null && this.topicConfigManager != null) 
{
+            Set<String> topics = 
this.topicConfigManager.getTopicConfigTable().keySet();
+            
+            for (String topic : topics) {
+                try {
+                    this.routeEventService.publishEvent(RouteEventType.START, 
topic);
+                    LOG.info("[START]: publish {}", topic);
+                } catch (Exception e) {
+                    LOG.error("Failed to publish route change event for topic: 
{}", topic, e);
+                }
+            }
+            LOG.info("Published route change events for {} topics", 
topics.size());
+        }

Review Comment:
   如果启动事件也要一个个通知的话,topic数量级百万情况下,量会很大,我理解应该和shutdown的事件一样,是broker级别的。



-- 
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