From a0b094442943c7cdf9d0523012835c75b6b6c97f Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 26 Apr 2021 10:32:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=A9=E7=9F=AD=E5=8F=82=E6=95=B0=20?= =?UTF-8?q?=E5=8E=BB=E6=8E=89url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/dto/form/mq/MqBaseParamDTO.java | 1 - .../com/epmet/commons/tools/utils/SendMqMsgUtils.java | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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);