|
@@ -171,6 +171,27 @@ public class RocketMQProducer {
|
|
}
|
|
}
|
|
Message message = messageBuilder.build();
|
|
Message message = messageBuilder.build();
|
|
rocketMQTemplate.sendOneWay(topic, message);
|
|
rocketMQTemplate.sendOneWay(topic, message);
|
|
|
|
+ log.info("MQ推送成功---topic:{},tag:{},key:{},msg:{}",topic,tag,key, JSONObject.toJSONString(body));
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 顺序消费 (计算场景使用)
|
|
|
|
+ * @param topic 主题名
|
|
|
|
+ * @param body 消息体
|
|
|
|
+ * hashKey 1 为计算推送消息
|
|
|
|
+ */
|
|
|
|
+ public void sendInOrder(String topic, Object body){
|
|
|
|
+ this.sendInOrder(topic,"1",body);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 顺序消费 计算场景使用)
|
|
|
|
+ * @param topic 主题名
|
|
|
|
+ * @param hashKey: 队列key,保证报到同一个队列中 ( number )
|
|
|
|
+ * @param body 消息体
|
|
|
|
+ */
|
|
|
|
+ public void sendInOrder(String topic, String hashKey, Object body){
|
|
|
|
+ log.info("MQ推送消息---topic:{},hashKey:{},msg:{}",topic,hashKey, JSONObject.toJSONString(body));
|
|
|
|
+ rocketMQTemplate.syncSendOrderly(topic,body,hashKey);
|
|
|
|
+ log.info("MQ推送成功---topic:{},hashKey:{},msg:{}",topic,hashKey, JSONObject.toJSONString(body));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|