|
@@ -44,25 +44,31 @@ public class ExamReserveMQConsumer implements RocketMQListener<MessageExt> {
|
|
|
public void onMessage(MessageExt message) {
|
|
|
ApplyRecordCacheBean queueBean = JsonHelper.toObj(message.getBody(), ApplyRecordCacheBean.class);
|
|
|
if (queueBean == null) {
|
|
|
- log.warn("【考生预约队列】MQ消息转换失败!msgId:{} queueOffset:{}", message.getMsgId(), message.getQueueOffset());
|
|
|
+ log.warn("【考生预约队列】MQ消息转换失败!queueOffset:{} msgId:{}", message.getQueueOffset(), message.getMsgId());
|
|
|
throw new RuntimeException("MQ消息转换失败!");
|
|
|
}
|
|
|
- log.info("【考生预约队列】MQ消息消费!msgId:{} bizId:{}", message.getMsgId(), queueBean.getBizId());
|
|
|
|
|
|
ApplyRecordCacheBean cacheBean = applyTaskCacheService.getStudentApplyRecord(queueBean.getStudentId(),
|
|
|
queueBean.getExamSiteId(), queueBean.getTimePeriodId());
|
|
|
+
|
|
|
final ApplyRecordCacheBean bean;
|
|
|
if (cacheBean == null) {
|
|
|
- log.warn("【考生预约队列】队列对应的缓存记录不存在!bizId:{} {}_{}_{}_{}", queueBean.getBizId(),
|
|
|
- queueBean.getStudentId(), queueBean.getExamSiteId(), queueBean.getTimePeriodId(), queueBean.getCancel());
|
|
|
+ log.warn("【考生预约队列】MQ队列元素对应的缓存记录不存在!bizId:{} msgId:{}", queueBean.getBizId(), message.getMsgId());
|
|
|
+
|
|
|
// 若缓存数据不存在,则采用队列数据持久化
|
|
|
bean = queueBean;
|
|
|
} else {
|
|
|
if (cacheBean.getBizId() != null && cacheBean.getBizId() >= queueBean.getBizId()) {
|
|
|
+ log.info("【考生预约队列】MQ消息消费!bizId:{} cacheBizId:{} msgId:{}", queueBean.getBizId(),
|
|
|
+ cacheBean.getBizId(), message.getMsgId());
|
|
|
+
|
|
|
// 默认采用最新预约缓存数据持久化(极端情况下队列消息顺序异常)
|
|
|
bean = cacheBean;
|
|
|
} else {
|
|
|
- // 其它情况采用队列数据持久化
|
|
|
+ log.warn("【考生预约队列】缓存中的队列业务流水号无效!bizId:{} cacheBizId:{} msgId:{}", queueBean.getBizId(),
|
|
|
+ cacheBean.getBizId(), message.getMsgId());
|
|
|
+
|
|
|
+ // 其它情况,采用队列数据持久化
|
|
|
bean = queueBean;
|
|
|
}
|
|
|
}
|
|
@@ -77,7 +83,7 @@ public class ExamReserveMQConsumer implements RocketMQListener<MessageExt> {
|
|
|
wrapper.eq(StudentApplyEntity::getStudentId, bean.getStudentId());
|
|
|
StudentApplyEntity data = studentApplyService.getOne(wrapper);
|
|
|
|
|
|
- String msg = String.format("%s_%s_%s_%s", bean.getStudentId(), bean.getExamSiteId(), bean.getTimePeriodId(), bean.getCancel());
|
|
|
+ String logContent = String.format("%s_%s_%s_%s", bean.getStudentId(), bean.getExamSiteId(), bean.getTimePeriodId(), bean.getCancel());
|
|
|
if (data != null) {
|
|
|
// 存在预约记录,则更新
|
|
|
data.setCancel(bean.getCancel());
|
|
@@ -90,7 +96,7 @@ public class ExamReserveMQConsumer implements RocketMQListener<MessageExt> {
|
|
|
updateWrapper.set(StudentApplyEntity::getUpdateTime, bean.getOperateTime());
|
|
|
updateWrapper.eq(StudentApplyEntity::getId, data.getId());
|
|
|
studentApplyService.update(updateWrapper);
|
|
|
- log.warn("【考生预约】DB更新!id:{} {}", data.getId(), msg);
|
|
|
+ log.warn("【考生预约】DB更新!{} dbId:{} bizId:{}", logContent, data.getId(), bean.getBizId());
|
|
|
} else {
|
|
|
// 不存在预约记录,则新增
|
|
|
data = new StudentApplyEntity();
|
|
@@ -102,7 +108,7 @@ public class ExamReserveMQConsumer implements RocketMQListener<MessageExt> {
|
|
|
data.setCreateTime(bean.getOperateTime());
|
|
|
data.setUpdateTime(bean.getOperateTime());
|
|
|
studentApplyService.save(data);
|
|
|
- log.warn("【考生预约】DB新增!id:{} {}", data.getId(), msg);
|
|
|
+ log.warn("【考生预约】DB新增!{} dbId:{} bizId:{}", logContent, data.getId(), bean.getBizId());
|
|
|
}
|
|
|
|
|
|
if (data.getCancel()) {
|