You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/07/09 02:18:55 UTC
[GitHub] [rocketmq] JerryChin commented on issue #504: No route info of this
topic problem
JerryChin commented on issue #504: No route info of this topic problem
URL: https://github.com/apache/rocketmq/issues/504#issuecomment-509460336
历时一天终于跑起来了,回顾官网起步教程中存在的各种坑:
### 坑爹 # 1
启动 Broker
> nohup sh bin/mqbroker -n localhost:9876 &
> tail -f ~/logs/rocketmqlogs/broker.log
The broker[%s, 172.30.30.233:10911] boot success...
很遗憾,上述方式直接忽略指定 Name Server 的步骤,导致 Name Server 不知道 Broker 的存在。
** How to fix **
编辑 `conf/broker.conf`
```
namesrvAddr = YOUR_NAME_SERVER_IP:PORT
```
使用以下指令启动 Broker
> nohup sh bin/mqnamesrv -c conf/broker.conf &
> tail -f ~/logs/rocketmqlogs/namesrv.log
The broker[broker-a, 192.168.3.211:10911] boot success. serializeType=JSON and name server is 192.168.3.211:9876 (我自己的输出结果,应该跟你的有出入)
### 坑爹 No route info of this topic # 2
RocketMQ 并不会自动创建 TopicTest,因此你必须手动创建该 Topic。
```
bin\mqadmin updateTopic -n YOUR_NAME_SERVER_IP:PORT -b YOUR_BROKER_IP:PORT -c DefaulCluster1 -o true -p 6 -r 8 -s true -t TopicTest -w 8
```
### 坑爹 No route info of this topic # 3
还是遇到这个错误?! 你是不是参考了以下官方示例?
```
public class SyncProducer {
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();
for (int i = 0; i < 100; i++) {
//Create a message instance, specifying topic, tag and message body.
Message msg = new Message("TopicTest" /* Topic */,
"TagA" /* Tag */,
("Hello RocketMQ " +
i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */
);
//Call send message to deliver message to one of brokers.
SendResult sendResult = producer.send(msg);
System.out.printf("%s%n", sendResult);
}
//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();` 即可。
### 坑爹 # 4
RocketMQ 内部代码一行注释看不到,我也是服气了。
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services