RocketMQ 部署成功了 但是使用实例代码发送消息失败
/** * 下面这段代码表明一个Producer对象可以发送多个topic,多个tag的消息。 * 注意:send方法是同步调用,只要不抛异常就标识成功。但是发送成功也可会有多种状态,<br> * 例如消息写入Master成功,但是Slave不成功,这种情况消息属于成功,但是对于个别应用如果对消息可靠性要求极高,<br> * 需要对这种情况做处理。另外,消息可能会存在发送失败的情况,失败重试由应用来处理。 */ producer.setNamesrvAddr("127.0.0.1:10911"); producer.setInstanceName("Producer1"); /** * Producer对象在使用之前必须要调用start初始化,初始化一次即可<br> * 注意:切记不可以在每次发送消息时,都调用start方法 */ producer.start(); for (int i = 0; i < 2; i++) { try { { Message msg1 = new Message("TopicTest1",// topic "TagA",// tag ("Hello RocketMQ-1 " + i).getBytes()// body ); SendResult sendResult1 = producer.send(msg1); System.out.println(sendResult1); } { Message msg2 = new Message("TopicTest2",// topic "TagB",// tag "OrderID0034",// key ("Hello RocketMq-2 " + i).getBytes());// body SendResult sendResult2 = producer.send(msg2); System.out.println(sendResult2); } { Message msg3 = new Message("TopicTest3",// topic "TagC",// tag "OrderID061",// key ("Hello RocketMq-3 " + i).getBytes());// body SendResult sendResult3 = producer.send(msg3); System.out.println(sendResult3); } } catch (Exception e) { e.printStackTrace(); Thread.sleep(1000); } }
出错消息
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. com.alibaba.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest1 See https://github.com/alibaba/RocketMQ/issues/264 for further details. at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:570) at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:972) at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:109) at com.alibaba.rocketmq.example.simple.Producer.main(Producer.java:60) com.alibaba.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest1 See https://github.com/alibaba/RocketMQ/issues/264 for further details. at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:570) at com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:972) at com.alibaba.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:109) at com.alibaba.rocketmq.example.simple.Producer.main(Producer.java:60)
borker状态
C:UsersAdministrator>mqadmin borkerStats -b 127.0.0.1:10911 The sub command 'borkerStats' not exist. C:UsersAdministrator>mqadmin brokerStats -b 127.0.0.1:10911 bootTimestamp : 1402984296248 brokerVersion : 54 brokerVersionDesc : V3_1_4_SNAPSHOT commitLogDiskRatio : 0.382574807031888 commitLogMaxOffset : 0 commitLogMinOffset : -1 consumeQueueDiskRatio : 0.382574807031888 dispatchMaxBuffer : 0 getFoundTps : 0.0 0.0 0.0 getMessageEntireTimeMax : 0 getMissTps : 0.0 0.0 0.0 getTotalTps : 0.0 0.0 0.0 getTransferedTps : 0.0 0.0 0.0 msgGetTotalTodayMorning : 0 msgGetTotalTodayNow : 0 msgGetTotalYesterdayMorning : 0 msgPutTotalTodayMorning : 0 msgPutTotalTodayNow : 0 msgPutTotalYesterdayMorning : 0 putMessageAverageSize : 0.0 putMessageDistributeTime : 0(0.0%) 0(0.0%) 0(0.0%) 0(0.0%) 0(0.0%) 0(0.0%) 0(0.0%) putMessageEntireTimeMax : 0 putMessageSizeTotal : 0 putMessageTimesTotal : 1 putTps : 0.0 0.0 0.0 runtime : [ 0 days, 0 hours, 13 minutes, 20 seconds ] sendThreadPoolQueueCapacity : 100000 sendThreadPoolQueueSize : 0
mqadmin topicRoute -n "192.168.1.78:10911" -t topicTest
C:UsersAdministrator>mqadmin topicRoute -n "192.168.1.78:10911" -t topicTest com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException: wait response on the channel <192.168.1.78:10911> timeout, 3000(ms) at com.alibaba.rocketmq.remoting.netty.NettyRemotingAbstract.invokeSyncI mpl(NettyRemotingAbstract.java:384) at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(Ne ttyRemotingClient.java:609) at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFro mNameServer(MQClientAPIImpl.java:1427) at com.alibaba.rocketmq.tools.admin.DefaultMQAdminExtImpl.examineTopicRo uteInfo(DefaultMQAdminExtImpl.java:236) at com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt.examineTopicRouteI nfo(DefaultMQAdminExt.java:179) at com.alibaba.rocketmq.tools.command.topic.TopicRouteSubCommand.execute (TopicRouteSubCommand.java:67) at com.alibaba.rocketmq.tools.command.MQAdminStartup.main(MQAdminStartup .java:151) C:UsersAdministrator>mqadmin topicRoute -n "192.168.1.78:10911;127.0.0.1:10911 " -t topicTest com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException: wait response on the channel <192.168.1.78:10911> timeout, 3000(ms) at com.alibaba.rocketmq.remoting.netty.NettyRemotingAbstract.invokeSyncI mpl(NettyRemotingAbstract.java:384) at com.alibaba.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(Ne ttyRemotingClient.java:609) at com.alibaba.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFro mNameServer(MQClientAPIImpl.java:1427) at com.alibaba.rocketmq.tools.admin.DefaultMQAdminExtImpl.examineTopicRo uteInfo(DefaultMQAdminExtImpl.java:236) at com.alibaba.rocketmq.tools.admin.DefaultMQAdminExt.examineTopicRouteI nfo(DefaultMQAdminExt.java:179) at com.alibaba.rocketmq.tools.command.topic.TopicRouteSubCommand.execute (TopicRouteSubCommand.java:67) at com.alibaba.rocketmq.tools.command.MQAdminStartup.main(MQAdminStartup .java:151)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
环境变量端口应配置为 9876