rocketmq: No route info of this topic problem

clinet exception:

org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, ffff
See http://rocketmq.apache.org/docs/faq/ for further details.
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:634)
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1253)
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1203)
	at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:214)
	at com.xx.rmq.Producer.main(Producer.java:55)

rocketmq server config:

autoCreateTopicEnable=true

问题: 我们手动在rokcetmq中创建topic时,客户端访问时正常的,如果不提前手动创建将会出现上面的异常,如果需要让服务端自动创建topic,应该如何设置

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 37 (13 by maintainers)

Most upvoted comments

历时一天终于跑起来了,回顾官网起步教程中存在的各种坑:

坑爹 # 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 的存在。

解决方案

编辑 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 DefaulCluster -o true -p 6 -r 8 -s true -t TopicTest -w 8

坑爹 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(); 即可。

坑爹 # 4

RocketMQ 内部代码一行注释看不到,我也是服气了。

hi~ @duhenglucky i am new to rocketmq. RocketMQ is cool and become more and more popular, so i’d like to help you guys to make the quick start more friendly to newbies like me. If there are some errors in my statement, please point out. here we go, after some investigation, these are what i find:

  • the Start Broker part is fine, because parameter -n locolhost:9876 set the name server.As that’s a quick start, if you can put that in configuration file by default, that will be really nice.
  • No route info of this topic problem error. If i use the same 4.3.0 version client as the official site Simple Example page suggests, the broker(version 4.4.0) won’t create topic automatically. however 4.4.0 version client works! My suggestions are:
    1. modify the official site simple example page, modify the client version to 4.4.0
    2. As that’s a quick start for newbie like me, add the autoCreateTopicEnable = true to broker config file by default
    3. maybe you can check the code and find the real cause for this bug
  • all quick start examples should set name server by default,add some code like producer.setNamesrvAddr("localhost:9876")
  • default broker jvm memory configuration is -Xms8g -Xmx8g -Xmn4g, that’s almost kill my poor computer… i think you can make it smaller for our poor personal computer~ The professional company guys will configure that option by themselves.

关于官网的``可以参考这里:https://exception.site/question/101

producer.setNamesrvAddr("localhost:9876");

居然是没有添加 Name Server 的地址导致的。同问官网的demo都没有自己运行吗?

用阿里云服务器的同学,如果rocketmq和你的微服务不在一台阿里云服务器上,那很有可能是阿里云使用内网IP的缘故导致No route info of this topic, TopicTest不能自动创建topic,把rocketmq和微服务放一台服务器就好了,这问题真·排到怀疑人生= =

@jimgreen2013 The pr#1415 does not modify the code of broker, but the code of client. So you should test with the newest client code in develop branch.

hi~ @jimgreen2013

  1. As far as I know, if broker does not set autoCreateTopicEnable = true, the new modification will still return No route info of this topic. My improvement is mainly for “No route info of tihis topic” caused by some network problem.
  2. You can refer to quick start on the official website to start name server and broker.

强烈建议重开此 issue。