You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@rocketmq.apache.org by ju...@sina.com on 2018/09/27 07:34:29 UTC

回复:关于MQClientException: No route info of this topic

hello,我也是最近遇到了这个问题,已经查到原因:
4.3.0版本中,异步发送起了新的线程进行发送,不阻塞当前线程,在异步发送之前,producer已经shutdown,导致发送前创建channel失败,获取不到route info;
解决方案:shutdown之前sleep等待一段时间
----- 原始邮件 -----
发件人:"631521383@qq.com" <63...@qq.com>
收件人:users <us...@rocketmq.apache.org>
主题:关于MQClientException: No route info of this topic
日期:2018年09月27日 14点54分


你好,
目前偶尔会遇到错误:
MQClientException: No route info of this topic
我的场景如下:
服务器启动命令:
nohup sh bin/mqnamesrv &nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true &
Console看到的配置如下:
我在Console上也能成功手动发送消息,但是通过代码就会报错。。
代码如下:
public class AsyncProducer {
    public static void main(
        String[] args) throws MQClientException, InterruptedException, UnsupportedEncodingException {

        DefaultMQProducer producer = new DefaultMQProducer("Jodie_Daily_test");
        producer.setNamesrvAddr("120.92.213.192:9876");
        producer.start();
//        producer.setRetryTimesWhenSendAsyncFailed(0); // for test retry

        for (int i = 0; i < 1; i++) {
            try {
                final int index = i;
                Message msg = new Message("Jodie_topic_1023",
                    "TagA",
                    "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();
                        System.out.println("Send failed...");
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("Send failed.");
            }
        }
        producer.shutdown();
    }
}请问下,什么原因??



631521383@qq.com