Browse Source

发送微信订阅消息接口,增加try-catch和计时

master
wxz 5 years ago
parent
commit
f060b2656a
  1. 14
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java

14
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java

@ -17,6 +17,7 @@
package com.epmet.controller;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -26,6 +27,8 @@ import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.WxMsgAuthInfoResultDTO;
import com.epmet.service.WxmpMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -43,6 +46,8 @@ import java.util.concurrent.ExecutorService;
@RequestMapping("wxmpmessage")
public class WxmpMessageController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WxmpMessageService wxmpMessageService;
@ -79,7 +84,14 @@ public class WxmpMessageController {
ValidatorUtils.validateEntity(wxSubscribeMessageFormDTO);
}
executorService.execute(() -> {
wxmpMessageService.sendWxSubscribeMessage(msgList);
try {
long startTs = System.currentTimeMillis();
wxmpMessageService.sendWxSubscribeMessage(msgList);
long endTs = System.currentTimeMillis();
logger.info("异步发送消息成功,执行时长:{}", endTs - startTs);
} catch (Exception e) {
logger.error("异步发送消息失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e));
}
});
return new Result();
}

Loading…
Cancel
Save