sohutv / mqcloud

RocketMQ企业级一站式服务平台
Apache License 2.0
1.91k stars 272 forks source link

当broker配置autoCreateTopicEnable=false,rocketmq日志出现大量MQClientException: CODE: 17 #18

Open ziyunmuxu opened 3 years ago

ziyunmuxu commented 3 years ago

分析是对象池中MQClientInstance定时线程updateTopicRouteInfoFromNameServer,会默认扫描TBW102,但是对于broker配置autoCreateTopicEnable=false,并没有生成TBW102的topic,不知道这种的日志中不停出现告警信息,有什么处理方式没有?

具体告警日志如下: 2021-04-28 10:34:33 WARN MQClientFactoryScheduledThread - updateTopicRouteInfoFromNameServer Exception org.apache.rocketmq.client.exception.MQClientException: CODE: 17 DESC: No topic route info in name server for the topic: TBW102 See http://rocketmq.apache.org/docs/faq/ for further details. at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1385) at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1355) at org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:622) at org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:509) at org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:358) at org.apache.rocketmq.client.impl.factory.MQClientInstance$3.run(MQClientInstance.java:275) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

gaoyf commented 3 years ago

两种解决方案 1.自己创建TBW102 topic。 2.修改rocketmq client的这行代码

this.topicPublishInfoTable.put(this.defaultMQProducer.getCreateTopicKey(), new TopicPublishInfo());

修改为如下即可:

if (defaultMQProducer.isFetchAutoCreateTopicRouteInfo()) {
    this.topicPublishInfoTable.put(this.defaultMQProducer.getCreateTopicKey(), new TopicPublishInfo());
}
在DefaultMQProducer定义一个变量
// 是否抓取自动创建topic的路由信息
private boolean fetchAutoCreateTopicRouteInfo;

另外,这个异常是由于#1985引入的,主要是这个代码: image

我感觉官方merge代码时review不经过测试。。。,你这个问题应该在rocketmq社区提。