knightingal commented on issue #504: No route info of this topic problem URL: https://github.com/apache/rocketmq/issues/504#issuecomment-569203894 > > ## 坑爹 No route info of this topic # 3 > 还是遇到这个错误?! 你是不是参考了以下官方示例? > > ``` > public class AsyncProducer { > public static void main(String[] args) throws Exception { > //Instantiate with a producer group name. > DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name"); > // Specify name server addresses. > producer.setNamesrvAddr("localhost:9876"); > //Launch the instance. > producer.start(); > producer.setRetryTimesWhenSendAsyncFailed(0); > for (int i = 0; i < 100; i++) { > final int index = i; > //Create a message instance, specifying topic, tag and message body. > Message msg = new Message("TopicTest", > "TagA", > "OrderID188", > "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET)); > producer.send(msg, new SendCallback() { > @Override > public void onSuccess(SendResult sendResult) { > System.out.printf("%-10d OK %s %n", index, > sendResult.getMsgId()); > } > @Override > public void onException(Throwable e) { > System.out.printf("%-10d Exception %s %n", index, e); > e.printStackTrace(); > } > }); > } > //Shut down once the producer instance is not longer in use. > producer.shutdown(); > } > } > ``` > > 以上代码创建完成 Producer 之后,立即调用 shutdown(),导致异步操作失败,最终抛出一个风马牛不相及的异常 `No route info of this topic `: > > ``` > org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest > ``` > > #### 解决方案 > 注释掉 `producer.shutdown();` 即可。 > 这个真是醉了。官网的演示代码自己都不运行一遍的吗?
---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
