Pirate-Captain edited a comment on issue #3179:
URL: https://github.com/apache/rocketmq/issues/3179#issuecomment-887164930


   The version is 4.9.0.
   First of all, If set the autoCreateTopicEnable = false,when start the 
broker, the broker won't register the topic "TBW102" to the nameserver(See the 
constructor of TopicConfigManager, the line 70)
   ```
   if (this.brokerController.getBrokerConfig().isAutoCreateTopicEnable()) {
                   String topic = TopicValidator.AUTO_CREATE_TOPIC_KEY_TOPIC;
                   TopicConfig topicConfig = new TopicConfig(topic);
                   TopicValidator.addSystemTopic(topic);
                   
topicConfig.setReadQueueNums(this.brokerController.getBrokerConfig()
                       .getDefaultTopicQueueNums());
                   
topicConfig.setWriteQueueNums(this.brokerController.getBrokerConfig()
                       .getDefaultTopicQueueNums());
                   int perm = PermName.PERM_INHERIT | PermName.PERM_READ | 
PermName.PERM_WRITE;
                   topicConfig.setPerm(perm);
                   this.topicConfigTable.put(topicConfig.getTopicName(), 
topicConfig);
               }
   ```
   Second, when start a consumer, it will create a DefaultMQProducer in the 
MQClintInstance, and will register the producer into the 
producerTable(MQClientInstance.start line 244), and register the TBW102 to the 
DefaultMQProducerImpl's topicPublishInfoTable(DefaultMQProducerImpl line 207)
   the entry code is:
   ```
   this.defaultMQProducer.getDefaultMQProducerImpl().start(false);
   ```
   and the register code is (DefaultMQProducerImpl.start() line 199  line 207):
   ```
    boolean registerOK = 
mQClientFactory.registerProducer(this.defaultMQProducer.getProducerGroup(), 
this);
                   if (!registerOK) {
                       this.serviceState = ServiceState.CREATE_JUST;
                       throw new MQClientException("The producer group[" + 
this.defaultMQProducer.getProducerGroup()
                           + "] has been created before, specify another name 
please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
                           null);
                   }
   
                   
this.topicPublishInfoTable.put(this.defaultMQProducer.getCreateTopicKey(), new 
TopicPublishInfo());
   ```
   
   So, when the MQClientInstance scheduled executes the method 
updateTopicRouteInfoFromNameServer, it will put the 'TBW102' topic to the 
topicList, see MQClientInstance.updateTopicRouteInfoFromNameServer line 347
   ```
   // Producer
           {
               Iterator<Entry<String, MQProducerInner>> it = 
this.producerTable.entrySet().iterator();
               while (it.hasNext()) {
                   Entry<String, MQProducerInner> entry = it.next();
                   MQProducerInner impl = entry.getValue();
                   if (impl != null) {
                       Set<String> lst = impl.getPublishTopicList();
                       topicList.addAll(lst);
                   }
               }
           }
   ```
   the code above will put the topic of  TBW102  to the topicList, the next 
code update every topic in the topic list.
   
   I don't know whether do i describe clearly.


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