lideyin 5 жил өмнө
parent
commit
f5e77ba5ed

+ 5 - 0
examcloud-core-oe-face-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/face/service/impl/BaiduFaceLivenessWorker.java

@@ -13,6 +13,7 @@ import cn.com.qmth.examcloud.core.oe.common.base.Constants;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamCaptureQueueEntity;
 import cn.com.qmth.examcloud.core.oe.student.face.service.ExamCaptureService;
 import cn.com.qmth.examcloud.web.support.SpringContextHolder;
+import org.apache.logging.log4j.ThreadContext;
 
 /**
  * 百度活体检测工作线程
@@ -24,6 +25,8 @@ public class BaiduFaceLivenessWorker implements Worker<ExamCaptureQueueEntity> {
 
 	@Override
 	public void process(WorkerController controller, ExamCaptureQueueEntity element) {
+		ThreadContext.put("TRACE_ID", "Q_" + element.getId());
+		ThreadContext.put("CALLER", "BAIDU_WORKER");
 		ExamCaptureProcessStatisticController.increaseFaceLivenessDetectCount();
 		if (captureLog.isDebugEnabled()) {
 			captureLog.debug("[BAIDU_FACELIVENESS_WORKER.] 图片处理数量+1,count= "
@@ -53,6 +56,8 @@ public class BaiduFaceLivenessWorker implements Worker<ExamCaptureQueueEntity> {
 			examCaptureService.disposeBaiDuFaceLivenessFaild(element);
 			captureLog.error("[BAIDU_FACELIVENESS_WORKER.] 系统异常 " + e.getMessage(), e);
 			Util.sleep(TimeUnit.MICROSECONDS, 50);
+		}finally {
+			ThreadContext.clearAll();
 		}
 	}
 }

+ 7 - 0
examcloud-core-oe-face-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/face/service/impl/FacePPCompareWorker.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.oe.student.face.service.impl;
 
 import java.util.concurrent.TimeUnit;
 
+import cn.com.qmth.examcloud.commons.util.ThreadLocalUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -13,6 +14,7 @@ import cn.com.qmth.examcloud.core.oe.common.base.Constants;
 import cn.com.qmth.examcloud.core.oe.common.entity.ExamCaptureQueueEntity;
 import cn.com.qmth.examcloud.core.oe.student.face.service.ExamCaptureService;
 import cn.com.qmth.examcloud.web.support.SpringContextHolder;
+import org.apache.logging.log4j.ThreadContext;
 
 /**
  * face++人脸比对工作线程
@@ -24,6 +26,9 @@ public class FacePPCompareWorker implements Worker<ExamCaptureQueueEntity> {
 
     @Override
     public void process(WorkerController controller, ExamCaptureQueueEntity element) {
+
+        ThreadContext.put("TRACE_ID", "Q_" + element.getId());
+        ThreadContext.put("CALLER", "FACEPP_WORKER");
         // 图片处理数量+1
         ExamCaptureProcessStatisticController.increaseFaceCompareCount();
         if (captureLog.isDebugEnabled()) {
@@ -56,6 +61,8 @@ public class FacePPCompareWorker implements Worker<ExamCaptureQueueEntity> {
             captureLog.error("[FACEPP_COMPARE_WORKER.] 系统异常 " + e.getMessage() +
                     ",failedCount=" + ExamCaptureProcessStatisticController.getFaceCompareFailedCount(), e);
             Util.sleep(TimeUnit.MICROSECONDS, 50);
+        } finally {
+            ThreadContext.clearAll();
         }
     }
 }