diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseParamDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseParamDTO.java index 9ad8df6cf4..8b400beb45 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseParamDTO.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/mq/MqBaseParamDTO.java @@ -14,5 +14,4 @@ import java.io.Serializable; public class MqBaseParamDTO implements Serializable { private String appId; private String token; - private String requestUrl; } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java index e1b96f7eed..ac6a2d440c 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/SendMqMsgUtils.java @@ -29,6 +29,8 @@ import java.util.Map; @Component public class SendMqMsgUtils { private static MqConfig mqConfig; + private static String requestUrl; + /** * desc:发送mq消息(如果失败重试1次) @@ -39,22 +41,23 @@ public class SendMqMsgUtils { if (mqConfig == null) { mqConfig = SpringContextUtils.getBean(MqConfig.class); } - log.info("sendMsg param:{}", JSON.toJSONString(msg)); + if (requestUrl == null){ + requestUrl = mqConfig.getHost().concat(MqMethodPathEnum.SEND_MSG.getCode()); + } try { ValidatorUtils.validateEntity(msg, DefaultGroup.class); } catch (ValidateException e) { return new Result().error(e.getMsg()); } msg.setAppId(mqConfig.getAppId()); - msg.setRequestUrl(mqConfig.getHost().concat(MqMethodPathEnum.SEND_MSG.getCode())); msg.setToken(mqConfig.getToken()); try { int retryTime = 0; Result result = null; - log.info("sendMsg url:{},param:{}", msg.getRequestUrl(), JSON.toJSONString(msg)); + log.info("sendMsg url:{},param:{}", requestUrl, JSON.toJSONString(msg)); do { + result = HttpClientManager.getInstance().sendPostByHttps(requestUrl, JSON.toJSONString(msg)); retryTime++; - result = HttpClientManager.getInstance().sendPostByHttps(msg.getRequestUrl(), JSON.toJSONString(msg)); log.info("sendMsg retryTime:{},result:{}", retryTime, JSON.toJSONString(result)); } while ((!result.success()) && retryTime < 2);