5 changed files with 102 additions and 1 deletions
@ -0,0 +1,17 @@ |
|||
package com.epmet.commons.rocketmq.messages; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* desc:项目变动通知消息实体类 |
|||
* @author liujianjun |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
public class ProjectChangedMQMsg implements Serializable { |
|||
|
|||
private String customerId; |
|||
} |
@ -0,0 +1,69 @@ |
|||
package com.epmet.send; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; |
|||
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 sendProjectChangedMqMsg(ProjectChangedMQMsg msgContent) { |
|||
try { |
|||
SystemMsgFormDTO systemMsgFormDTO = new SystemMsgFormDTO(); |
|||
systemMsgFormDTO.setMessageType(SystemMessageType.PROJECT_CHANGED); |
|||
systemMsgFormDTO.setContent(msgContent); |
|||
Result sendMsgResult = null; |
|||
log.info("sendProjectChangedMqMsg param:{}",msgContent); |
|||
int retryTime = 0; |
|||
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