rocketmq icon indicating copy to clipboard operation
rocketmq copied to clipboard

No route info of this topic problem

Open yuanyaosmile opened this issue 8 years ago • 37 comments

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,应该如何设置

yuanyaosmile avatar Oct 24 '18 10:10 yuanyaosmile

服务端版本与客户端版本要对应。防火墙要关。

yuanyaosmile avatar Oct 25 '18 02:10 yuanyaosmile

sure?为啥我有时候可以自动创建,有时候不行呢?

vaxjaz avatar Oct 25 '18 08:10 vaxjaz

sure?为啥我有时候可以自动创建,有时候不行呢? 不行有报错吗?log中有啥?

yuanyaosmile avatar Oct 26 '18 01:10 yuanyaosmile

和你上述的报错信息一模一样。

vaxjaz avatar Oct 26 '18 01:10 vaxjaz

有人说是差了fastJson的包?不知道有没有这回事。

vaxjaz avatar Oct 26 '18 01:10 vaxjaz

服务端自动创建topic,设置autoCreateTopicEnable=true就行了。 FAQ中有解答,http://rocketmq.apache.org/docs/faq/ 报No route info of this topic这个错,可能是请求nameserver失败。 代码在DefaultMQProducerImpl#tryToFindTopicPublishInfo,里面逻辑并不是很多,自己debug一下就清楚了。

ymwneu avatar Nov 01 '18 11:11 ymwneu

还真是fastJson的问题。刚debug了源码。发现如果 在MQClientAPIImpl这个类中,会向服务端请求是否自动创建topic,会创建RemotingCommand请求对象,去请求服务端,序列化的type是fastJson,如果项目没有,请求都发不出去,抛了异常,自然无法创建topic。感谢指点!

vaxjaz avatar Nov 01 '18 12:11 vaxjaz

我并没有引入fastJson这个包,在版本不一致的时候,服务端已经加了autoCreateTopicEnable=true。版本一致就好了。这个包是根因嘛?

yuanyaosmile avatar Nov 01 '18 12:11 yuanyaosmile

There is still an improvement for this exception in RocketMQ. @yuanyaosmile

I would appreciate your engagement in the community if you could raise your question in the user email list. Issue is not the correct place for your request, please read the issue template, looking forward to your question in the email list:-

vongosling avatar Nov 02 '18 07:11 vongosling

我是4.4的最新版本,WIN10下,依然运行官方例子,报这个错误,以前都启动NAMESERVER,和BROKER成功了,为什么呢?

jackyrong avatar Apr 07 '19 15:04 jackyrong

也已经用了: mqbroker.exe -n localhost:9876 autoCreateTopicEnable=true

jackyrong avatar Apr 07 '19 15:04 jackyrong

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

坑爹 # 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 内部代码一行注释看不到,我也是服气了。

JerryChin avatar Jul 09 '19 02:07 JerryChin

强烈建议重开此 issue。

JerryChin avatar Jul 09 '19 02:07 JerryChin

@JerryChin Thanks for your summary for this issue, and we will reopen it for more users can pay more attention to this problem, and as you described, RocketMQ still has a high threshold for use. so would you like to optimize it together? It would be nice if you can polish the quickstart shell script and add some documentation. We will continue to track this issue with you.

duhenglucky avatar Jul 09 '19 02:07 duhenglucky

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

producer.setNamesrvAddr("localhost:9876");

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

Shellbye avatar Aug 06 '19 08:08 Shellbye

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.

jimgreen2013 avatar Aug 29 '19 08:08 jimgreen2013

I will pin this issue util someone gives us some feedback for this improvement. Details see https://github.com/apache/rocketmq/pull/1415

vongosling avatar Aug 29 '19 11:08 vongosling

hi~ @RongtongJin your code have been merged to branch develop, i'd like to test your improvement with client version 4.3.0 and see what will happen. but i don't know how can i compile from the source and get the broker up. can you help me? i tried something like:

  • mvn compile is ok
  • mvn install is not ok, because some test fail
  • mvn install -DskipTests is ok and will generate some jar files, then how can i start the name server and broker?

if i ask some stupid questions, please forgive me! i am really new to rocketmq. p.s I am big fan of redis and except i can test the latest rocketmq code very easily with a few command like redis~

jimgreen2013 avatar Aug 30 '19 03:08 jimgreen2013

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.

RongtongJin avatar Aug 30 '19 03:08 RongtongJin

hi~ @RongtongJin @vongosling @duhenglucky thanks for your help~ I have do some tests Here is the result:

test case1

  • broker version: build from lastest develop branch code
  • configuration: autoCreateTopicEnable = true
  • client version: 4.3.0
  • result: No route info of this topic error

test case2

  • broker version: build from lastest develop branch code
  • configuration: autoCreateTopicEnable = true
  • client version: 4.4.0
  • result: everything is ok

test case3

  • broker version: 4.3.0
  • configuration: autoCreateTopicEnable = true
  • client version: 4.3.0
  • result: everything is ok

Maybe i guess the new broker version isn't backward with old client version 4.3.0

jimgreen2013 avatar Aug 30 '19 04:08 jimgreen2013