RocketMQ 解决 No route info of this topic 异常步骤

RocketMQ 解决 No route info of this topic 异常步骤

Exception in thread "main" org.apache.rocketmq.client.exception.MQClientException: No route info for this topic, TopicTest
For more information, please visit the url, http://rocketmq.apache.org/docs/faq/
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendSelectImpl(DefaultMQProducerImpl.java:1031)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:997)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:992)
at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:389)
at com.example.mq.Producer.main(Producer.java:40)
00:35:20.088 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[] result: true
00:35:45.168 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[] result: true
00:36:15.161 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[] result: true
00:36:45.164 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[] result: true

RocketMQ 解决 No route info of this topic 异常步骤

rocketmq运行时提示 No route info of this topic 异常产生的原因可能是

①Broker禁止自动创建Topic,且用户没有通过手工方式创建Topic

②Broker没有正确连接到Name Server
③Producer没有正确连接到Name Server 

首先解决①这种情况,启动顺序要先启动nameserver,再启动broker,启动broker时加上autoCreateTopicEnable=true 

例如 nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &

启动没有异常检查下nameserver中是否成功注册了broker,有两种方式 
第一种、看broker的日志 如果出现形如
2018-02-28 16:21:35 INFO BrokerControllerScheduledThread1 - register broker to name server 192.168.192.129:9876 OK
2018-02-28 16:22:05 INFO BrokerControllerScheduledThread1 - register broker to name server 192.168.192.129:9876 OK
证明已经连接到nameserver上
第二种、 在bin目录下执行命令sh mqadmin clusterList -n localhost:9876 如果看到
#Cluster Name     #Broker Name            #BID  #Addr                  #Version                #InTPS(LOAD)       #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
DefaultCluster    DEFAULT_BROKER          0     192.168.192.129:10911  V4_2_0_SNAPSHOT          0.00(0,0ms)         0.00(0,0ms)          0 422168.55 -1.0000
也是证明已经连接到nameserver上。

RocketMQ 解决 No route info of this topic 异常步骤


如果按前两步检查没有问题,但启动还是报错,那么剩下的可能原因是producer无法连接到nameserver,很可能是防火墙的原因 ,要检验猜测只需要关闭防火墙,命令为systemctl stop firewalld.service
然后再次验证,应该已经可以使用了。