You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@rocketmq.apache.org by "631521383@qq.com" <63...@qq.com> on 2018/09/27 06:54:06 UTC
关于MQClientException: No route info of this topic
你好,
目前偶尔会遇到错误:
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