add-log mq-日志记录
parent
4ef537536d
commit
91f52699d4
|
@ -148,4 +148,11 @@ public class PageData extends HashMap<Object, Object> implements Map<Object, Obj
|
|||
return map.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PageData{" +
|
||||
"map=" + map +
|
||||
", request=" + request +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,14 +49,15 @@ public class DockSendMessageServiceImpl implements DockSendMessageService {
|
|||
|
||||
@Override
|
||||
public void sendMessage(TenCorpDto tenCorpDto) {
|
||||
PageData productionPD = tenCorpDto.getPd();
|
||||
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId() == null ? "" : tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "DockSendMessageServiceImpl.sendMessage(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark());
|
||||
productionPD.putAll(tenCorpDto.getPd());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME() == null ? "" : tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark() == null ? "" : tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
try {
|
||||
PageData log = tenCorpDto.getPd();
|
||||
mqMessageLogMapper.save(log);
|
||||
|
@ -84,15 +85,15 @@ public class DockSendMessageServiceImpl implements DockSendMessageService {
|
|||
|
||||
@Override
|
||||
public void sendMessagePicture(TenCorpDto tenCorpDto) {
|
||||
PageData productionPD = tenCorpDto.getPd();
|
||||
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId() == null ? "" : tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "DockSendMessageServiceImpl.sendMessagePicture(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark());
|
||||
productionPD.putAll(tenCorpDto.getPd());
|
||||
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME() == null ? "" : tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark() == null ? "" : tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
try {
|
||||
PageData log = tenCorpDto.getPd();
|
||||
log.put("MESSAGE_LOG_ID", Warden.get32UUID());
|
||||
|
@ -122,16 +123,15 @@ public class DockSendMessageServiceImpl implements DockSendMessageService {
|
|||
|
||||
@Override
|
||||
public void sendMessagePictureDelete(TenCorpDto tenCorpDto) {
|
||||
PageData productionPD = tenCorpDto.getPd();
|
||||
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId() == null ? "" : tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "DockSendMessageServiceImpl.sendMessagePictureDelete(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData());
|
||||
productionPD.putAll(tenCorpDto.getPd());
|
||||
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME() == null ? "" : tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark() == null ? "" : tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
try {
|
||||
PageData log = tenCorpDto.getPd();
|
||||
log.put("MESSAGE_LOG_ID", Warden.get32UUID());
|
||||
|
@ -161,15 +161,15 @@ public class DockSendMessageServiceImpl implements DockSendMessageService {
|
|||
|
||||
@Override
|
||||
public void SendDelayQueue(TenCorpDto tenCorpDto) {
|
||||
PageData productionPD = tenCorpDto.getPd();
|
||||
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId() == null ? "" : tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "DockSendMessageServiceImpl.SendDelayQueue(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData());
|
||||
productionPD.putAll(tenCorpDto.getPd());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME() == null ? "" : tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark() == null ? "" : tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
PageData log = tenCorpDto.getPd();
|
||||
log.put("MESSAGE_LOG_ID", Warden.get32UUID());
|
||||
try {
|
||||
|
@ -209,16 +209,14 @@ public class DockSendMessageServiceImpl implements DockSendMessageService {
|
|||
public void SendDelayQueue(String message) {
|
||||
TenCorpDto tenCorpDto = JSONObject.parseObject(message,TenCorpDto.class);
|
||||
|
||||
PageData productionPD = tenCorpDto.getPd();
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId() == null ? "" : tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "DockSendMessageServiceImpl.SendDelayQueue(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData());
|
||||
productionPD.putAll(tenCorpDto.getPd());
|
||||
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME() == null ? "" : tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark() == null ? "" : tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
try {
|
||||
PageData log = tenCorpDto.getPd();
|
||||
log.put("CREATE_TIME", DateUtil.getTime());
|
||||
|
|
|
@ -5,9 +5,12 @@ import com.zcloud.dto.TenCorpDto;
|
|||
import com.zcloud.entity.PageData;
|
||||
import com.zcloud.mapper.datasource.mq.MqErrorMessageLogMapper;
|
||||
import com.zcloud.mapper.datasource.mq.MqMessageLogMapper;
|
||||
import com.zcloud.mapper.datasource.mq.MqProductionErrorLogMapper;
|
||||
import com.zcloud.mapper.datasource.mq.MqProductionLogMapper;
|
||||
import com.zcloud.service.mq.LogService;
|
||||
import com.zcloud.service.mq.SendMessageService;
|
||||
import com.zcloud.util.DateUtil;
|
||||
import com.zcloud.util.StackTraceUtils;
|
||||
import com.zcloud.util.Warden;
|
||||
import com.zcloud.util.mq.MqUtil;
|
||||
import org.apache.rocketmq.client.producer.SendResult;
|
||||
|
@ -37,7 +40,22 @@ public class SendMessageServiceImpl implements SendMessageService {
|
|||
@Resource
|
||||
private MqMessageLogMapper mqMessageLogMapper;
|
||||
|
||||
public void sendMessage(TenCorpDto tenCorpDto) throws Exception {
|
||||
@Resource
|
||||
MqProductionErrorLogMapper mqProductionErrorLogMapper;
|
||||
|
||||
@Resource
|
||||
MqProductionLogMapper mqProductionLogMapper;
|
||||
|
||||
public void sendMessage(TenCorpDto tenCorpDto) {
|
||||
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId() == null ? "" : tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "SendMessageServiceImpl.sendMessage(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME() == null ? "" : tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark() == null ? "" : tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
try {
|
||||
PageData log = tenCorpDto.getPd();
|
||||
log.put("MESSAGE_LOG_ID", Warden.get32UUID());
|
||||
|
@ -48,6 +66,9 @@ public class SendMessageServiceImpl implements SendMessageService {
|
|||
if (!sendResult.getSendStatus().equals(SendStatus.SEND_OK)) {
|
||||
throw new RuntimeException("产品入栈失败");
|
||||
}
|
||||
productionPD.put("SUCCESS",'1');
|
||||
productionPD.put("ERROR_MESSAGE","SUCCESS");
|
||||
mqProductionLogMapper.save(productionPD);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
PageData log = tenCorpDto.getPd();
|
||||
|
@ -56,11 +77,23 @@ public class SendMessageServiceImpl implements SendMessageService {
|
|||
log.put("TYPE", "0");
|
||||
log.put("TIME", DateUtil.getTime());
|
||||
mqErrorMessageLogMapper.save(log);
|
||||
productionPD.put("SUCCESS",'0');
|
||||
productionPD.put("ERROR_MESSAGE", StackTraceUtils.printStackTraceToString(e));
|
||||
mqProductionErrorLogMapper.save(productionPD);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SendDelayQueue(TenCorpDto tenCorpDto) {
|
||||
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId() == null ? "" : tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "SendMessageServiceImpl.sendMessage(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME() == null ? "" : tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark() == null ? "" : tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
PageData log = tenCorpDto.getPd();
|
||||
log.put("MESSAGE_LOG_ID", Warden.get32UUID());
|
||||
try {
|
||||
|
@ -80,6 +113,9 @@ public class SendMessageServiceImpl implements SendMessageService {
|
|||
if (!sendResult.getSendStatus().equals(SendStatus.SEND_OK)) {
|
||||
throw new RuntimeException("产品入栈失败");
|
||||
}
|
||||
productionPD.put("SUCCESS",'1');
|
||||
productionPD.put("ERROR_MESSAGE","SUCCESS");
|
||||
mqProductionLogMapper.save(productionPD);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.put("ERROR_MESSAGE", e.getMessage());
|
||||
|
@ -87,12 +123,24 @@ public class SendMessageServiceImpl implements SendMessageService {
|
|||
log.put("TYPE", "0");
|
||||
log.put("TIME", DateUtil.getTime());
|
||||
mqErrorMessageLogMapper.save(log);
|
||||
productionPD.put("SUCCESS",'0');
|
||||
productionPD.put("ERROR_MESSAGE", StackTraceUtils.printStackTraceToString(e));
|
||||
mqProductionErrorLogMapper.save(productionPD);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SendDelayQueue(String message) {
|
||||
TenCorpDto tenCorpDto = JSONObject.parseObject(message,TenCorpDto.class);
|
||||
|
||||
PageData productionPD = new PageData();
|
||||
productionPD.put("PRODUCTION_ID", Warden.get32UUID());
|
||||
productionPD.put("MESSAGE_LOG_ID", tenCorpDto.getMessageLogId());
|
||||
productionPD.put("PRODUCTION_TYPE", "SendMessageServiceImpl.SendDelayQueue(TenCorpDto tenCorpDto)");
|
||||
productionPD.put("PRODUCTION_TIME", DateUtil.getTime());
|
||||
productionPD.put("CREATE_TIME", tenCorpDto.getCREATE_TIME());
|
||||
productionPD.put("MARK", tenCorpDto.getMark());
|
||||
productionPD.put("DATA", tenCorpDto.getData() == null ? "" : tenCorpDto.getData().toString());
|
||||
try {
|
||||
PageData log = tenCorpDto.getPd();
|
||||
log.put("CREATE_TIME", DateUtil.getTime());
|
||||
|
@ -110,20 +158,17 @@ public class SendMessageServiceImpl implements SendMessageService {
|
|||
if (!sendResult.getSendStatus().equals(SendStatus.SEND_OK)) {
|
||||
throw new RuntimeException("产品入栈失败");
|
||||
}
|
||||
productionPD.put("SUCCESS",'1');
|
||||
productionPD.put("ERROR_MESSAGE","SUCCESS");
|
||||
mqProductionLogMapper.save(productionPD);
|
||||
} catch (Exception e) {
|
||||
productionPD.put("SUCCESS",'0');
|
||||
productionPD.put("ERROR_MESSAGE", StackTraceUtils.printStackTraceToString(e));
|
||||
mqProductionErrorLogMapper.save(productionPD);
|
||||
PageData log = tenCorpDto.getPd();
|
||||
logService.saveErrorMessage(log,e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println(MqUtil.analysisTime("2023-06-30 14:30:00:000"));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zcloud.mapper.datasource.mq.MqProductionErrorLogMapper">
|
||||
|
||||
<insert id="save">
|
||||
INSERT INTO
|
||||
<sql id="tableName">
|
||||
`qa-czks-prevention`.`mq_production_error_log`
|
||||
(`PRODUCTION_ID`, `MARK`, `DATA`, `MESSAGE_LOG_ID`, `SUCCESS`, `CREATE_TIME`, `PRODUCTION_TIME`, `PRODUCTION_TYPE`, `ERROR_MESSAGE`)
|
||||
VALUES (#{PRODUCTION_ID}, #{MARK}, #{DATA}, #{MESSAGE_LOG_ID}, #{SUCCESS}, #{CREATE_TIME}, #{PRODUCTION_TIME},#{PRODUCTION_TYPE}, #{ERROR_MESSAGE})
|
||||
</sql>
|
||||
<sql id="Field2">
|
||||
PRODUCTION_ID,
|
||||
MARK,
|
||||
DATA,
|
||||
MESSAGE_LOG_ID,
|
||||
SUCCESS,
|
||||
CREATE_TIME,
|
||||
PRODUCTION_TIME,
|
||||
PRODUCTION_TYPE,
|
||||
ERROR_MESSAGE
|
||||
</sql>
|
||||
<sql id="FieldValue">
|
||||
#{PRODUCTION_ID},
|
||||
#{MARK},
|
||||
#{DATA},
|
||||
#{MESSAGE_LOG_ID},
|
||||
#{SUCCESS},
|
||||
#{CREATE_TIME},
|
||||
#{PRODUCTION_TIME},
|
||||
#{PRODUCTION_TYPE},
|
||||
#{ERROR_MESSAGE}
|
||||
</sql>
|
||||
<insert id="save" parameterType="pd">
|
||||
insert into
|
||||
<include refid="tableName"></include>
|
||||
(
|
||||
<include refid="Field2"></include>
|
||||
) values (
|
||||
<include refid="FieldValue"></include>
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -1,12 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zcloud.mapper.datasource.mq.MqProductionLogMapper">
|
||||
|
||||
<insert id="save">
|
||||
INSERT INTO
|
||||
<sql id="tableName">
|
||||
`qa-czks-prevention`.`mq_production_log`
|
||||
(`PRODUCTION_ID`, `MARK`, `DATA`, `MESSAGE_LOG_ID`, `SUCCESS`, `CREATE_TIME`, `PRODUCTION_TIME`, `PRODUCTION_TYPE`, `ERROR_MESSAGE`)
|
||||
VALUES (#{PRODUCTION_ID}, #{MARK}, #{DATA}, #{MESSAGE_LOG_ID}, #{SUCCESS}, #{CREATE_TIME}, #{PRODUCTION_TIME},#{PRODUCTION_TYPE}, #{ERROR_MESSAGE})
|
||||
</sql>
|
||||
<sql id="Field2">
|
||||
PRODUCTION_ID,
|
||||
MARK,
|
||||
DATA,
|
||||
MESSAGE_LOG_ID,
|
||||
SUCCESS,
|
||||
CREATE_TIME,
|
||||
PRODUCTION_TIME,
|
||||
PRODUCTION_TYPE,
|
||||
ERROR_MESSAGE
|
||||
</sql>
|
||||
<sql id="FieldValue">
|
||||
#{PRODUCTION_ID},
|
||||
#{MARK},
|
||||
#{DATA},
|
||||
#{MESSAGE_LOG_ID},
|
||||
#{SUCCESS},
|
||||
#{CREATE_TIME},
|
||||
#{PRODUCTION_TIME},
|
||||
#{PRODUCTION_TYPE},
|
||||
#{ERROR_MESSAGE}
|
||||
</sql>
|
||||
<insert id="save" parameterType="pd">
|
||||
insert into
|
||||
<include refid="tableName"></include>
|
||||
(
|
||||
<include refid="Field2"></include>
|
||||
) values (
|
||||
<include refid="FieldValue"></include>
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue