提交 d853f32d authored 作者: scc's avatar scc

ll

上级 49caa2b1
...@@ -43,7 +43,12 @@ public class MqMessageController { ...@@ -43,7 +43,12 @@ public class MqMessageController {
public List<SendResult> sendSyncMessage(@RequestParam("id") int id, @RequestParam("count") int count) throws UnsupportedEncodingException, MQBrokerException, RemotingException, InterruptedException, MQClientException { public List<SendResult> sendSyncMessage(@RequestParam("id") int id, @RequestParam("count") int count) throws UnsupportedEncodingException, MQBrokerException, RemotingException, InterruptedException, MQClientException {
List<SendResult> results = new ArrayList<>(); List<SendResult> results = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
SendResult result = rocketMQTemplate.syncSend(xcRocketMq2.getTopicString(), "Hello RocketMQ 同步发送消息"+i); org.apache.rocketmq.common.message.Message message = new org.apache.rocketmq.common.message.Message();
message.setBody("Hello RocketMQ 同步发送消息".getBytes());
message.setKeys("scc-keys");
message.setTags("scc-tags"+i);
message.setTopic("scc-test");
SendResult result = rocketMQTemplate.syncSend("scc-test:tags-scc", message);
results.add(result); results.add(result);
} }
return results; return results;
...@@ -86,7 +91,8 @@ public class MqMessageController { ...@@ -86,7 +91,8 @@ public class MqMessageController {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
// 创建消息,并指定Topic,Tag和消息体 // 创建消息,并指定Topic,Tag和消息体
// 发送单向消息,没有任何返回结果 // 发送单向消息,没有任何返回结果
rocketMQTemplate.sendOneWay(xcRocketMq2.getTopicString(), "发送单向消息"+i); rocketMQTemplate.sendOneWayOrderly("scc-test","发送单项消息+keys","single_key");
//rocketMQTemplate.sendOneWay("scc-test", "发送单向消息"+i);
} }
return "单向发送消息成功"; return "单向发送消息成功";
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论