提交 5e5dedc7 作者: obcy

【异常修复】

上级 4df1ff37
......@@ -23,6 +23,7 @@ import com.zzsn.event.util.RedisUtil;
import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*;
import com.zzsn.event.xxljob.entity.XxlJobInfo;
import com.zzsn.event.xxljob.service.IXxlJobInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -209,13 +210,31 @@ public class EventManageController {
@GetMapping("/enable")
public Result<?> enable(@RequestParam String eventId) {
eventService.updateStatus(eventId, 1);
//异步导致的异常修复(修改和查询使用同一个线程)
Event event = eventService.getById(eventId);
CompletableFuture.runAsync(() -> {
Event event = eventService.getById(eventId);
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
configurationMessageService.bindInfoSourceSend(event.getId());
configurationMessageService.bindKeyWordsSend(event.getId());
configurationMessageService.subjectEnterpriseSourceSync(event.getId());
configurationMessageService.subjectPolicySourceSync(event.getId());
try {
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
} catch (Exception e) {
log.error("事件分析调度失败{}", e.getMessage(), e);
}
try {
configurationMessageService.bindInfoSourceSend(event.getId());
configurationMessageService.bindKeyWordsSend(event.getId());
configurationMessageService.subjectEnterpriseSourceSync(event.getId());
configurationMessageService.subjectPolicySourceSync(event.getId());
} catch (Exception e) {
log.error("通知采集失败{}", e.getMessage(), e);
}
try {
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, event.getEventCode())
.set(XxlJobInfo::getTriggerStatus, 1));
} catch (Exception e) {
log.error("修改xxlJob状态失败{}", e.getMessage(), e);
}
try {
String res = caiJiCenterHttpService.subjectStatusEdit(event.getStatus(), event.getId());
cn.hutool.json.JSONObject entries = JSONUtil.parseObj(res);
......@@ -241,6 +260,17 @@ public class EventManageController {
@GetMapping("/disable")
public Result<?> disable(@RequestParam String eventId) {
eventService.updateStatus(eventId, 0);
try {
String res = caiJiCenterHttpService.subjectStatusEdit(0, eventId);
cn.hutool.json.JSONObject entries = JSONUtil.parseObj(res);
//获取code状态码
Integer code = entries.getInt("code");
if (cn.hutool.core.util.ObjectUtil.isEmpty(code) || code != 200) {
log.error("专题状态同步采集失败{}", res);
}
} catch (Exception e) {
log.error("专题状态同步采集失败{}", e.getMessage(), e);
}
return Result.OK();
}
......
......@@ -504,13 +504,6 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
updateWrapper.set(Event::getFirstOpenTime, new Date());
}
this.update(updateWrapper);
CompletableFuture.runAsync(() -> {
iXxlJobInfoService.update(Wrappers.<XxlJobInfo>lambdaUpdate().eq(XxlJobInfo::getInfoSourceCode, event.getEventCode())
.set(XxlJobInfo::getTriggerStatus, status));
if (1 == status) {
kafkaTemplate.send(EVENT_MODEL_KAFKA_CHANNEL, event.getEventCode());
}
});
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论