赞
踩
nohup sh bin/mqnamesrv &
nohup sh bin/mqbroker -n localhost:9876 &
public static void main(String[] args) throws Exception{ DefaultMQProducer producer = new DefaultMQProducer("product_group_test"); //(1) // 初始化一个producer并设置Producer group name // 设置NameServer地址 producer.setNamesrvAddr("127.0.0.1:9876"); //(2) // 启动producer producer.start(); System.out.println("启动成功"); // for (int i = 0; i < 10; i++) { // 创建一条消息,并指定topic、tag、body等信息,tag可以理解成标签,对消息进行再归类,RocketMQ可以在消费端对tag进行过滤 Message msg = new Message("TopicTest", null, ("Hello RocketMQ").getBytes(RemotingHelper.DEFAULT_CHARSET) ); //(3) // 利用producer进行发送,并同步等待发送结果 System.out.println("准备发送"); SendResult sendResult = producer.send(msg); //(4) System.out.printf("%s%n", sendResult); // } }
Exception in thread "main" org.apache.rocketmq.client.exception.MQClientException: Send [3] times, still failed, cost [168]ms, Topic: TopicTest
Caused by: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to 0.0.1.1:10911 failed
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。