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:610)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1223)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1173)
at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:214)
at com.ProducerTest01.main(ProducerTest01.java:46)
Broker禁止自动创建Topic,且用户没有通过手工方式创建Topic
官方文档中启动 Broker是这样的:
其实我们可以改成这样:
红字意思(允许自动创建Topic,且允许通过手工方式创建Topic)
客户端的 Producer 没有正确连接到Name Server
//Instantiate with a producer group name.
DefaultMQProducer producer = DefaultMQProducer("traffic_group");
// Specify name server addresses.
producer.setNamesrvAddr("localhost:9876");
检查producer的地址是否正确
缺少 Fastjson 的jar包
(由于本次使用的老项目环境,并没有整合maven一起使用,是每个每个jar的慢慢找的,所以才会导致这个缺包的问题)
添加 Fastjson jar包后成功
SendResult [sendStatus=SEND_OK, msgId=C0A803B13AE074A14FED747604D20000, offsetMsgId=C0A820ED00002A9F000000000002BEB2, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost.localdomain, queueId=0], queueOffset=250]
SendResult [sendStatus=SEND_OK, msgId=C0A803B13AE074A14FED7476050B0001, offsetMsgId=C0A820ED00002A9F000000000002BF64, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost.localdomain, queueId=1], queueOffset=250]
SendResult [sendStatus=SEND_OK, msgId=C0A803B13AE074A14FED747605120002, offsetMsgId=C0A820ED00002A9F000000000002C016, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost.localdomain, queueId=2], queueOffset=250]