7 changed files with 111 additions and 13 deletions
@ -0,0 +1,68 @@ |
|||
package com.epmet.send; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.constant.SystemMessageType; |
|||
import com.epmet.dto.form.SystemMsgFormDTO; |
|||
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
|
|||
/** |
|||
* desc: 发送mq消息直接到rocketMq 系统 |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2021/4/23 2:39 下午 |
|||
* @versio: 1.0 |
|||
*/ |
|||
@Slf4j |
|||
public class SendMqMsgUtil { |
|||
private static final SendMqMsgUtil INSTANCE = new SendMqMsgUtil(); |
|||
|
|||
private SendMqMsgUtil() { |
|||
|
|||
} |
|||
|
|||
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|||
|
|||
public static SendMqMsgUtil build() { |
|||
return INSTANCE; |
|||
} |
|||
|
|||
public SendMqMsgUtil openFeignClient(EpmetMessageOpenFeignClient epmetMessageOpenFeignClient) { |
|||
this.epmetMessageOpenFeignClient = epmetMessageOpenFeignClient; |
|||
return this; |
|||
} |
|||
|
|||
/** |
|||
* desc: 发送小组成就消息,计算小组成就 |
|||
* |
|||
* @param msgContent |
|||
* @return boolean |
|||
* @author LiuJanJun |
|||
* @date 2021/4/23 3:01 下午 |
|||
* @remark 失败重试1次 |
|||
*/ |
|||
public boolean sendGroupAchievementMqMsg(GroupAchievementMQMsg msgContent) { |
|||
try { |
|||
SystemMsgFormDTO systemMsgFormDTO = new SystemMsgFormDTO(); |
|||
systemMsgFormDTO.setMessageType(SystemMessageType.GROUP_ACHIEVEMENT); |
|||
systemMsgFormDTO.setContent(msgContent); |
|||
Result sendMsgResult = null; |
|||
int retryTime = 1; |
|||
do { |
|||
sendMsgResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(systemMsgFormDTO); |
|||
} while ((sendMsgResult == null || !sendMsgResult.success()) && retryTime++ < NumConstant.TWO); |
|||
|
|||
if (sendMsgResult != null && sendMsgResult.success()) { |
|||
return true; |
|||
} |
|||
log.error("发送(小组成就)系统消息到message服务失败:{},msg:{}", JSON.toJSONString(sendMsgResult), JSON.toJSONString(systemMsgFormDTO)); |
|||
} catch (Exception e) { |
|||
log.error("sendMqMsg exception", e); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue