java110-bean/src/main/java/com/java110/dto/logSystemError/LogSystemErrorDto.java
@@ -19,6 +19,7 @@ public static final String ERR_TYPE_JOB = "JOB"; public static final String ERR_TYPE_OWE_FEE = "OWE_FEE"; public static final String ERR_TYPE_NOTICE = "NOTICE"; public static final String ERR_TYPE_CMD = "CMD"; public static final String ERR_TYPE_ACCOUNT = "ACCOUNT"; private String msg; java110-core/src/main/java/com/java110/core/event/cmd/ServiceCmdEventPublishing.java
@@ -3,19 +3,21 @@ import com.alibaba.fastjson.JSONObject; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.center.DataFlowListenerOrderComparator; import com.java110.core.factory.GenerateCodeFactory; import com.java110.core.log.LoggerFactory; import com.java110.dto.CmdListenerDto; import com.java110.dto.logSystemError.LogSystemErrorDto; import com.java110.po.logSystemError.LogSystemErrorPo; import com.java110.utils.constant.CommonConstant; import com.java110.utils.constant.ResponseConstant; import com.java110.utils.exception.BusinessException; import com.java110.utils.exception.CmdException; import com.java110.utils.exception.ListenerExecuteException; import com.java110.utils.factory.ApplicationContextFactory; import com.java110.utils.log.LoggerEngine; import com.java110.utils.util.Assert; import com.java110.utils.util.ExceptionUtil; import org.slf4j.Logger; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -147,7 +149,7 @@ * @param event * @param asyn A 表示异步处理 */ public static void multicastEvent(String serviceCode, final CmdEvent event, String asyn) throws ParseException { public static void multicastEvent(String serviceCode, final CmdEvent event, String asyn) throws Exception { List<ServiceCmdListener> listeners = getListeners(serviceCode); //这里判断 serviceCode + httpMethod 的侦听,如果没有注册直接报错。 if (listeners == null || listeners.size() == 0) { @@ -164,7 +166,7 @@ public void run() { try { invokeListener(listener, event); } catch (ParseException e) { } catch (Exception e) { e.printStackTrace(); } } @@ -196,7 +198,7 @@ * @since 4.1 */ @SuppressWarnings({"unchecked", "rawtypes"}) protected static void invokeListener(ServiceCmdListener listener, CmdEvent event) throws ParseException { protected static void invokeListener(ServiceCmdListener listener, CmdEvent event) throws Exception { try { // //这里处理业务逻辑数据 ICmdDataFlowContext dataFlowContext = event.getCmdDataFlowContext(); @@ -211,8 +213,8 @@ //logger.debug("API服务 --- 返回报文信息:{}", dataFlowContext.getResponseEntity()); // listener.cmd(event); } catch (CmdException | ParseException e) { LoggerEngine.error("发布侦听失败", e); } catch (Throwable e) { LoggerEngine.error("发布侦听失败" + e); throw e; } } java110-service/src/main/java/com/java110/service/api/CmdApi.java
@@ -1,22 +1,17 @@ package com.java110.service.api; import com.java110.core.base.controller.BaseController; import com.java110.core.factory.DataTransactionFactory; import com.java110.core.trace.Java110TraceLog; import com.java110.service.context.DataQuery; import com.java110.service.context.DataQueryFactory; import com.java110.core.factory.GenerateCodeFactory; import com.java110.core.log.LoggerFactory; import com.java110.dto.logSystemError.LogSystemErrorDto; import com.java110.po.logSystemError.LogSystemErrorPo; import com.java110.service.smo.ICmdServiceSMO; import com.java110.service.smo.IQueryServiceSMO; import com.java110.service.smo.ISaveSystemErrorSMO; import com.java110.utils.constant.CommonConstant; import com.java110.utils.constant.ResponseConstant; import com.java110.utils.util.Assert; import com.java110.vo.ResultVo; import io.swagger.annotations.Api; import com.java110.utils.util.ExceptionUtil; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import com.java110.core.log.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -42,6 +37,9 @@ @Autowired private ICmdServiceSMO cmdServiceSMOImpl; @Autowired ISaveSystemErrorSMO saveSystemErrorSMOImpl; @RequestMapping(path = "/{service:.+}", method = RequestMethod.POST) public ResponseEntity<String> service(@PathVariable String service, @@ -57,6 +55,11 @@ logger.debug("api:{} 请求报文为:{},header信息为:{}", service, postInfo, headers); responseEntity = cmdServiceSMOImpl.cmd(postInfo, headers); } catch (Throwable e) { LogSystemErrorPo logSystemErrorPo = new LogSystemErrorPo(); logSystemErrorPo.setErrId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_errId)); logSystemErrorPo.setErrType(LogSystemErrorDto.ERR_TYPE_CMD); logSystemErrorPo.setMsg(ExceptionUtil.getStackTrace(e)); saveSystemErrorSMOImpl.saveLog(logSystemErrorPo); logger.error("请求post 方法[" + service + "]失败:" + postInfo, e); responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } @@ -97,6 +100,7 @@ logger.debug("cmd:{} 返回信息为:{}", action, responseEntity); return responseEntity; } /** * 获取请求信息 *