From 70079bd0772207e88414176f5ca9edb3dd4bd236 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期四, 21 十一月 2024 08:56:05 +0800
Subject: [PATCH] 并发采集

---
 iailab-framework/iailab-common-web/src/main/java/com/iailab/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/iailab-framework/iailab-common-web/src/main/java/com/iailab/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java b/iailab-framework/iailab-common-web/src/main/java/com/iailab/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java
index 3fc2814..87055ce 100644
--- a/iailab-framework/iailab-common-web/src/main/java/com/iailab/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java
+++ b/iailab-framework/iailab-common-web/src/main/java/com/iailab/framework/apilog/core/service/ApiErrorLogFrameworkServiceImpl.java
@@ -3,6 +3,7 @@
 import com.iailab.module.infra.api.logger.ApiErrorLogApi;
 import com.iailab.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Async;
 
 /**
@@ -13,6 +14,7 @@
  * @author iailab
  */
 @RequiredArgsConstructor
+@Slf4j
 public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkService {
 
     private final ApiErrorLogApi apiErrorLogApi;
@@ -20,7 +22,12 @@
     @Override
     @Async
     public void createApiErrorLog(ApiErrorLogCreateReqDTO reqDTO) {
-        apiErrorLogApi.createApiErrorLog(reqDTO);
+        try {
+            apiErrorLogApi.createApiErrorLog(reqDTO);
+        } catch (Throwable ex) {
+            // 由于 @Async 异步调用,这里打印下日志,更容易跟进
+            log.error("[createApiErrorLog][url({}) log({}) 发生异常]", reqDTO.getRequestUrl(), reqDTO, ex);
+        }
     }
 
 }

--
Gitblit v1.9.3