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/10/01 06:49:32 UTC

[GitHub] [rocketmq] beijing-penguin edited a comment on issue #504: No route info of this topic problem

beijing-penguin edited a comment on issue #504: No route info of this topic problem
URL: https://github.com/apache/rocketmq/issues/504#issuecomment-536894347
 
 
   我使用的最新4.5的master分支源代码 eclipse java启动方式也不行。  
   我的步骤如下:  
   第一步  
   ```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  
   第二步  
   ```java
   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  
   ```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官方源代码,我已经全部设置为localhost,且都设置对了namesrv的端口和地址,rpc协议无论是ROCKETMQ还是JSON,都会报No route info of this topic, TopicTest的异常。。我想我的运行方式已经够明确了吧。

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