使用RocketMQ发送消息抛出异常,异常如下:
org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest
See http://rocketmq.apache.org/docs/faq/ for further details.
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:657)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1280)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1226)
at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:283)
at org.apache.rocketmq.example.quickstart.Producer.main(Producer.java:67)
原因:
Broker
禁止自动创建Topic
,且用户没有通过手动创建此Topic
,或者broker
和 Nameserver
网络不通;
解决方案:
1. 修改broker.properties配置,自动创建topic,添加如下:
autoCreateTopicEnable=true
2. 升级RocketMQ版本为4.4.0
,新版本会默认自动创建
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.4.0</version>
</dependency>