Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No route info of this topic problem #504

Closed
yuanyaosmile opened this issue Oct 24, 2018 · 31 comments
Assignees
Milestone

Comments

@yuanyaosmile
Copy link

@yuanyaosmile yuanyaosmile commented Oct 24, 2018

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

This comment has been minimized.

Copy link
Author

@yuanyaosmile yuanyaosmile commented Oct 25, 2018

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

@love-jay

This comment has been minimized.

Copy link

@love-jay love-jay commented Oct 25, 2018

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

@yuanyaosmile

This comment has been minimized.

Copy link
Author

@yuanyaosmile yuanyaosmile commented Oct 26, 2018

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

@love-jay

This comment has been minimized.

Copy link

@love-jay love-jay commented Oct 26, 2018

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

@love-jay

This comment has been minimized.

Copy link

@love-jay love-jay commented Oct 26, 2018

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

@ymwneu

This comment has been minimized.

Copy link
Contributor

@ymwneu ymwneu commented Nov 1, 2018

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

@love-jay

This comment has been minimized.

Copy link

@love-jay love-jay commented Nov 1, 2018

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

@yuanyaosmile

This comment has been minimized.

Copy link
Author

@yuanyaosmile yuanyaosmile commented Nov 1, 2018

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

@vongosling

This comment has been minimized.

Copy link
Member

@vongosling vongosling commented Nov 2, 2018

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 vongosling closed this Nov 2, 2018
@vongosling vongosling changed the title No route info of this topic, ffff No route info of this topic problem Nov 2, 2018
@jackyrong

This comment has been minimized.

Copy link

@jackyrong jackyrong commented Apr 7, 2019

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

@jackyrong

This comment has been minimized.

Copy link

@jackyrong jackyrong commented Apr 7, 2019

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

@JerryChin

This comment has been minimized.

Copy link

@JerryChin JerryChin commented Jul 9, 2019

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

坑爹 # 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

This comment has been minimized.

Copy link

@JerryChin JerryChin commented Jul 9, 2019

强烈建议重开此 issue。

@duhenglucky

This comment has been minimized.

Copy link
Contributor

@duhenglucky duhenglucky commented Jul 9, 2019

@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 duhenglucky reopened this Jul 9, 2019
@Shellbye

This comment has been minimized.

Copy link

@Shellbye Shellbye commented Aug 6, 2019

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

producer.setNamesrvAddr("localhost:9876");

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

@jimgreen2013

This comment has been minimized.

Copy link

@jimgreen2013 jimgreen2013 commented Aug 29, 2019

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.
@vongosling

This comment has been minimized.

Copy link
Member

@vongosling vongosling commented Aug 29, 2019

I will pin this issue util someone gives us some feedback for this improvement. Details see #1415

@vongosling vongosling pinned this issue Aug 29, 2019
@jimgreen2013

This comment has been minimized.

Copy link

@jimgreen2013 jimgreen2013 commented Aug 30, 2019

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~

@RongtongJin

This comment has been minimized.

Copy link
Contributor

@RongtongJin RongtongJin commented Aug 30, 2019

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.
@jimgreen2013

This comment has been minimized.

Copy link

@jimgreen2013 jimgreen2013 commented Aug 30, 2019

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

@duhenglucky

This comment has been minimized.

Copy link
Contributor

@duhenglucky duhenglucky commented Aug 30, 2019

@jimgreen2013 yep, RocketMQ 4.3.0 version changed the default "TBW102" value, this will lead to some compatibility issues and it is recommended to test with the latest version 4.5.2.

@RongtongJin

This comment has been minimized.

Copy link
Contributor

@RongtongJin RongtongJin commented Aug 30, 2019

@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.

@vongosling

This comment has been minimized.

Copy link
Member

@vongosling vongosling commented Sep 3, 2019

@yuanyaosmile @jimgreen2013 Could you help to verify the preview version for this improvement, just redo it as @RongtongJin suggestion.

@beijing-penguin

This comment has been minimized.

Copy link

@beijing-penguin beijing-penguin commented Oct 1, 2019

我使用的最新4.5.2的master分支源代码 eclipse java启动,报错“No route info of this topic, TopicTest”
我的步骤如下:
第一步启动Namesrv main方法-->org.apache.rocketmq.namesrv.NamesrvStartup.java

public static void main(String[] args) {
        main0(args);
    }

    public static NamesrvController main0(String[] args) {

        try {
            NamesrvController controller = createNamesrvController(args);
            controller.getNettyServerConfig().setListenPort(8888);
            start(controller);
            String tip = "The Name Server boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();
            log.info(tip);
            System.out.printf("%s%n", tip);
            return controller;
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(-1);
        }

        return null;
    }

控制台输出:The Name Server boot success. serializeType=ROCKETMQ
第二步启动Broker的main方法--->org.apache.rocketmq.broker.BrokerStartup.java
并用代码设置setAutoCreateTopicEnable=true,如下

public static void main(String[] args) {
        start(createBrokerController(args));
    }

    public static BrokerController start(BrokerController controller) {
        try {
            controller.getBrokerConfig().setNamesrvAddr("localhost:8888");
            controller.getBrokerConfig().setAutoCreateTopicEnable(true);
            //controller.getBrokerConfig().setBrokerTopicEnable(true);
            controller.getBrokerConfig().setBrokerIP1("localhost");
            System.err.println(controller.getBrokerAddr());
            controller.start();
            
            String tip = "The broker[" + controller.getBrokerConfig().getBrokerName() + ", "
                + controller.getBrokerAddr() + "] boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();

            if (null != controller.getBrokerConfig().getNamesrvAddr()) {
                tip += " and name server is " + controller.getBrokerConfig().getNamesrvAddr();
            }

            log.info(tip);
            System.err.println(String.valueOf(controller.getBrokerConfig().isAutoCreateTopicEnable()));
            System.out.printf("%s%n", tip);
            return controller;
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(-1);
        }

        return null;
    }

控制台输出:
localhost:10911
true
The broker[WIN-FMHILLP1PVS, localhost:10911] boot success. serializeType=ROCKETMQ and name server is localhost:8888
第三步,启动官方自带simaple中的org.apache.rocketmq.example.ordermessage.Producer.java

    public static void main(String[] args) throws MQClientException, InterruptedException {
        DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
        producer.setNamesrvAddr("localhost:8888");
        producer.start();

        for (int i = 0; i < 1000; i++) {
            try {
                Message msg = new Message("TopicTest" , "TagA",
                    ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET) 
                );

                SendResult sendResult = producer.send(msg);
                System.out.printf("%s%n", sendResult);
            } catch (Exception e) {
                e.printStackTrace();
                Thread.sleep(1000);
            }
        }
        //producer.shutdown();
    }

控制台输出:

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:657)
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1280)
	at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1226)
	at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:283)
	at org.apache.rocketmq.example.quickstart.Producer.main(Producer.java:40)

问题分析:
用的最新4.5.2官方源代码,我已经全部设置为localhost,且都设置对了namesrv的端口和地址,rpc协议无论是ROCKETMQ还是JSON,都会报No route info of this topic, TopicTest的异常。。

@RongtongJin

This comment has been minimized.

Copy link
Contributor

@RongtongJin RongtongJin commented Oct 1, 2019

@beijing-penguin
当前已经有一个PR提交到develop分支,还未被合入主分支,你可以尝试一下develop分支的客户端代码,如果是下面第一个原因导致的no route info of this topic,会直接抛出相应的错误。

对于修改之前的版本,建议你检查一下客户端的日志,日志中会有更加详细的异常信息,在控制台上只能看到抛出异常。

此外,根据no route info of this topic出现的原因,建议你从以下几个方面排查。

  1. 确保producer能连接上nameserver并且能从nameserver中获取topic的元数据信息。
    检查方法:通过查看日志、调试等方法进行检查,在最新的develop分支中该原因导致会直接抛出对应的异常。
    可能的原因:客户端没有设置nameserver,防火墙等网络问题。
  2. 确保nameserver中包含了需要发送的topic的路由。
    检查方法:通过admin工具或rocketmq web console进行检查。
    可能的原因:
    (1)Topic不存在且Broker禁止自动创建Topic(autoCreateTopicEnable=false),且没有通过手工方式创建Topic。
    (2)Broker没有正确连接到NameServer(broker能定期向nameserver发送心跳)
  3. 其他原因:Netty版本问题,fastjson问题,topic权限问题(权限至少可写)
    检查方法:需要通过查日志,调试等方法综合进行检查。

期待你能告诉我最后的原因。

@beijing-penguin

This comment has been minimized.

Copy link

@beijing-penguin beijing-penguin commented Oct 1, 2019

@beijing-penguin
当前已经有一个PR提交到develop分支,还未被合入主分支,你可以尝试一下develop分支的客户端代码,如果是下面第一个原因导致的no route info of this topic,会直接抛出相应的错误。

对于修改之前的版本,建议你检查一下客户端的日志,日志中会有更加详细的异常信息,在控制台上只能看到抛出异常。

此外,根据no route info of this topic出现的原因,建议你从以下几个方面排查。

  1. 确保producer能连接上nameserver并且能从nameserver中获取topic的元数据信息。
    检查方法:通过查看日志、调试等方法进行检查,在最新的develop分支中该原因导致会直接抛出对应的异常。
    可能的原因:客户端没有设置nameserver,防火墙等网络问题。
  2. 确保nameserver中包含了需要发送的topic的路由。
    检查方法:通过admin工具或rocketmq web console进行检查。
    可能的原因:
    (1)Topic不存在且Broker禁止自动创建Topic(autoCreateTopicEnable=false),且没有通过手工方式创建Topic。
    (2)Broker没有正确连接到NameServer(broker能定期向nameserver发送心跳)
  3. 其他原因:Netty版本问题,fastjson问题,topic权限问题(权限至少可写)
    检查方法:需要通过查日志,调试等方法综合进行检查。

期待你能告诉我最后的原因。

一、我切换到了develop分支,也尝试默认不设置,或者设置不同的namesrv端口
image

二,我是用eclipse本地启动,并且关闭了本地防火墙
image

三、我使用的是官方源代码,fastjson,netty等版本全部使用官方pom配置文件构建。。启动流程如下
①启动namesrv,设置端口为8888 (尝试过不设置端口,默认使用9876,也会报异常)
image
②启动broker,并设置controller.getBrokerConfig().setAutoCreateTopicEnable(true);
image
③设置producer.setNamesrvAddr("localhost:8888"); 运行生产者
image

四、查看namesrv.log文件。抛出了一个奇怪的错误,exceptionCaught 127.0.0.1:49195 提示中的端口49195,是从来没设置过的这种端口。。。
image

我的其他信息
broker.conf
image
broker.log
image

@RongtongJin

This comment has been minimized.

Copy link
Contributor

@RongtongJin RongtongJin commented Oct 1, 2019

@beijing-penguin 客户端的日志(rocketmq_client.log)是否更加详细信息,这个更重要。另外nameserver日志中(namesrv.log)是否存在“new broker registered...“,如果不存在很可能是broker没有注册成功。

@beijing-penguin

This comment has been minimized.

Copy link

@beijing-penguin beijing-penguin commented Oct 1, 2019

@beijing-penguin 客户端的日志(rocketmq_client.log)是否更加详细信息,这个更重要。另外nameserver日志中(namesrv.log)是否存在“new broker registered...“,如果不存在很可能是broker没有注册成功。

namesrv.log 不存在new broker registered 这些关键字
这是rocketmq_client.log客户端的日志。
image

@RongtongJin

This comment has been minimized.

Copy link
Contributor

@RongtongJin RongtongJin commented Oct 2, 2019

@beijing-penguin 引起no route info的主要原因是因为Broker没有正确连接到NameServer。我发现你在代码中设置namesever地址,如果设置nameserver要起作用,则设置代码须在controller.initialize()之前。另外推荐你采用其他方式配置nameserver,比如设置eclipse中设置broker程序参数 -n localhost:8888,可以看下nameserver的最佳实践

@beijing-penguin

This comment has been minimized.

Copy link

@beijing-penguin beijing-penguin commented Oct 2, 2019

@beijing-penguin 引起no route info的主要原因是因为Broker没有正确连接到NameServer。我发现你在代码中设置namesever地址,如果设置nameserver要起作用,则设置代码须在controller.initialize()之前。另外推荐你采用其他方式配置nameserver,比如设置eclipse中设置broker程序参数 -n localhost:8888,可以看下nameserver的最佳实践

非常感谢您的专业解答,确实 是broker main方法中设置controller应该在initialize()之前。我模拟命令行,再次用代码设置 args = new String[] {"-n","127.0.0.1:9876","autoCreateTopicEnable=true"};入参的方法,问题得到解决。。再次感谢。

public static void main(String[] args) {
        args = new String[] {"-n","127.0.0.1:9876","autoCreateTopicEnable=true"};
        start(createBrokerController(args));
    }

    public static BrokerController start(BrokerController controller) {
        try {
            //controller.getBrokerConfig().setBrokerIP1("localhost");
            //controller.getBrokerConfig().setNamesrvAddr("localhost:8888");
            //controller.getBrokerConfig().setAutoCreateTopicEnable(true);
            controller.start();

            String tip = "The broker[" + controller.getBrokerConfig().getBrokerName() + ", "
                + controller.getBrokerAddr() + "] boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();

            if (null != controller.getBrokerConfig().getNamesrvAddr()) {
                tip += " and name server is " + controller.getBrokerConfig().getNamesrvAddr();
            }

            log.info(tip);
            System.out.printf("%s%n", tip);
            return controller;
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(-1);
        }

        return null;
    }
@duhenglucky

This comment has been minimized.

Copy link
Contributor

@duhenglucky duhenglucky commented Nov 11, 2019

The polishment will be released in 4.6.0, and relative PR has been merged, so someone else if has other questions, please feel free to reopen it as it indeed is a hot issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.