bigdogiloveyou commented on issue #504:
URL: https://github.com/apache/rocketmq/issues/504#issuecomment-639490712


   > > @beijing-penguin 引起no route 
info的主要原因是因为Broker没有正确连接到NameServer。我发现你在代码中设置namesever地址,如果设置nameserver要起作用,则设置代码须在controller.initialize()之前。另外推荐你采用其他方式配置nameserver,比如设置eclipse中设置broker程序参数
 -n 
localhost:8888,可以看下nameserver的[最佳实践](http://rocketmq.apache.org/docs/best-practice-namesvr/)。
   > 
   > 非常感谢您的专业解答,确实 是broker main方法中设置controller应该在initialize()之前。我模拟命令行,再次用代码设置 
args = new String[] 
{"-n","127.0.0.1:9876","autoCreateTopicEnable=true"};入参的方法,问题得到解决。。再次感谢。
   > 
   > ```java
   > 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;
   >     }
   > ```
   
   谢谢你的示例,我也成功运行了


----------------------------------------------------------------
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]


Reply via email to