Commit a44a3640 by Future

消息推送转异步mq

parent c722cbb3
...@@ -146,9 +146,8 @@ public class NormalChatAction { ...@@ -146,9 +146,8 @@ public class NormalChatAction {
sendMsgForOnline(imClientReceiver.getId(), imMessageOnlineSend); sendMsgForOnline(imClientReceiver.getId(), imMessageOnlineSend);
// 异步推送系统通知消息 // 异步推送系统通知消息
// systemPush.push(data.getPush(), imClientReceiver, imApplication);
PushDTO pushDTO = mqSender.buildPushDto(data.getPush(), imClientReceiver, imApplication); PushDTO pushDTO = mqSender.buildPushDto(data.getPush(), imClientReceiver, imApplication);
mqSender.synSend(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO); mqSender.sendAsync(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO);
} }
// 响应发送方消息id等信息 // 响应发送方消息id等信息
......
...@@ -70,7 +70,7 @@ public class FriendEventSender { ...@@ -70,7 +70,7 @@ public class FriendEventSender {
pushVO.setTitle(FRIEND_APPLY_TITLE); pushVO.setTitle(FRIEND_APPLY_TITLE);
pushVO.setSubTitle(FRIEND_APPLY_TITLE_SUB); pushVO.setSubTitle(FRIEND_APPLY_TITLE_SUB);
PushDTO pushDTO = mqSender.buildPushDto(pushVO, receiveClient, app); PushDTO pushDTO = mqSender.buildPushDto(pushVO, receiveClient, app);
mqSender.synSend(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO); mqSender.sendAsync(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO);
} }
public void sendFriendApproveEventMsg(ImClient claimerClient, ImClient receiveClient, boolean isAgree, String rejectRemark) { public void sendFriendApproveEventMsg(ImClient claimerClient, ImClient receiveClient, boolean isAgree, String rejectRemark) {
...@@ -98,6 +98,6 @@ public class FriendEventSender { ...@@ -98,6 +98,6 @@ public class FriendEventSender {
pushVO.setTitle(FRIEND_APPROVE_TITLE); pushVO.setTitle(FRIEND_APPROVE_TITLE);
pushVO.setSubTitle(isAgree? FRIEND_APPROVE_TITLE_AGREE : FRIEND_APPROVE_TITLE_REJECT); pushVO.setSubTitle(isAgree? FRIEND_APPROVE_TITLE_AGREE : FRIEND_APPROVE_TITLE_REJECT);
PushDTO pushDTO = mqSender.buildPushDto(pushVO, receiveClient, app); PushDTO pushDTO = mqSender.buildPushDto(pushVO, receiveClient, app);
mqSender.synSend(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO); mqSender.sendAsync(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO);
} }
} }
...@@ -47,6 +47,17 @@ public class MqSender { ...@@ -47,6 +47,17 @@ public class MqSender {
log.info("mq同步推送topic: {} tag: {} 返回结果: {}", topic, tag, JSON.toJSONString(sendResult)); log.info("mq同步推送topic: {} tag: {} 返回结果: {}", topic, tag, JSON.toJSONString(sendResult));
return sendResult; return sendResult;
} }
/**
* mq异步推送方法
* @param topic
* @param tag
* @param pushDTO
* @return
*/
public void sendAsync(String topic, String tag, PushDTO pushDTO) {
log.info("mq异步推送topic: {} tag: {} 推送内容: {}", topic, tag, JSON.toJSONString(pushDTO));
rocketMqProducerService.sendAsyncDefault(topic, tag, JSON.toJSONString(pushDTO));
}
public PushDTO buildPushDto(PushVO pushVO, ImClient imClientReceiver, ImApplication imApplication) { public PushDTO buildPushDto(PushVO pushVO, ImClient imClientReceiver, ImApplication imApplication) {
......
...@@ -190,8 +190,8 @@ public class RocketMqProducerService implements SendCallback { ...@@ -190,8 +190,8 @@ public class RocketMqProducerService implements SendCallback {
@Override @Override
public void onSuccess(final SendResult sendResult) { public void onSuccess(final SendResult sendResult) {
// 消费发送成功 // 消费发送成功
LOGGER.info("send message success. topic=" + sendResult.getMessageQueue().getTopic() + LOGGER.info("send message success. topic={} msgId={}",
", msgId=" + sendResult.getMsgId()); sendResult.getMessageQueue().getTopic(), sendResult.getMsgId());
} }
...@@ -215,8 +215,8 @@ public class RocketMqProducerService implements SendCallback { ...@@ -215,8 +215,8 @@ public class RocketMqProducerService implements SendCallback {
@Override @Override
public void onSuccess(SendResult sendResult) { public void onSuccess(SendResult sendResult) {
LOGGER.info("send message success. topic=" + sendResult.getMessageQueue().getTopic() LOGGER.info("send message success. topic={} msgId={}",
+ ", msgId=" + sendResult.getMsgId()); sendResult.getMessageQueue().getTopic(), sendResult.getMsgId());
} }
@Override @Override
...@@ -233,6 +233,6 @@ public class RocketMqProducerService implements SendCallback { ...@@ -233,6 +233,6 @@ public class RocketMqProducerService implements SendCallback {
} else { } else {
LOGGER.error("send message failed. =" + e); LOGGER.error("send message failed. =" + e);
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment