|
@@ -25,67 +25,67 @@ import java.util.List;
|
|
|
@Order(49)
|
|
|
public class ProcessFaceCompareQueueTask implements ApplicationRunner {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Autowired
|
|
|
ExamCaptureQueueRepo examCaptureQueueRepo;
|
|
|
- private static final Logger log = LoggerFactory.getLogger(ProcessFaceCompareQueueTask.class);
|
|
|
- private final Log captureLog = LogFactory.getLog("PROCESS_EXAM_CAPTURE_TASK_LOGGER");
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ProcessFaceCompareQueueTask.class);
|
|
|
+ private final Log captureLog = LogFactory.getLog("PROCESS_EXAM_CAPTURE_TASK_LOGGER");
|
|
|
|
|
|
- private void start() {
|
|
|
- ConcurrentTask concurrentTask = new ConcurrentTask();
|
|
|
- concurrentTask.setMaxActiveThreadSize(PropertyHolder.getInt("$capture.thread.maxActiveThreadSize", 100));
|
|
|
- concurrentTask.setMinThreadSize(PropertyHolder.getInt("$capture.thread.minThreadSize", 2));
|
|
|
- concurrentTask.setWorker(new FacePPCompareWorker());
|
|
|
- concurrentTask.start();
|
|
|
- //当前获取数据的批次号(默认用时间戳)
|
|
|
- String processBatchNum=String.valueOf(System.currentTimeMillis());
|
|
|
+ private void start() {
|
|
|
+ ConcurrentTask concurrentTask = new ConcurrentTask();
|
|
|
+ concurrentTask.setMaxActiveThreadSize(PropertyHolder.getInt("$capture.thread.maxActiveThreadSize", 100));
|
|
|
+ concurrentTask.setMinThreadSize(PropertyHolder.getInt("$capture.thread.minThreadSize", 2));
|
|
|
+ concurrentTask.setWorker(new FacePPCompareWorker());
|
|
|
+ concurrentTask.start();
|
|
|
+ //当前获取数据的批次号(默认用时间戳)
|
|
|
+ String processBatchNum = "A_" + System.currentTimeMillis();
|
|
|
|
|
|
- captureLog.debug("[PROCESS_FACEPP."+processBatchNum+"] 启动face++人脸比对服务...");
|
|
|
- while (true) {
|
|
|
- try {
|
|
|
- //如果队列没满,则从数据库中查数据并插入
|
|
|
- List<ExamCaptureQueueEntity> examCaptureQueueList = examCaptureQueueRepo.
|
|
|
- findNeedFaceCompareExamCaptureQueuesLimitByProcessBatchNum(PropertyHolder.getInt("$capture.queue.limit", 100),processBatchNum);
|
|
|
- //如果队列中没取到数据,则2秒钟后再取
|
|
|
- if (null == examCaptureQueueList || examCaptureQueueList.isEmpty()) {
|
|
|
- captureLog.debug("[PROCESS_FACEPP."+processBatchNum+"] 抓拍队列中没有取到数据,2秒后重试");
|
|
|
+ captureLog.debug("[PROCESS_FACEPP." + processBatchNum + "] 启动face++人脸比对服务...");
|
|
|
+ while (true) {
|
|
|
+ try {
|
|
|
+ //如果队列没满,则从数据库中查数据并插入
|
|
|
+ List<ExamCaptureQueueEntity> examCaptureQueueList = examCaptureQueueRepo.
|
|
|
+ findNeedFaceCompareExamCaptureQueuesLimitByProcessBatchNum(PropertyHolder.getInt("$capture.queue.limit", 100), processBatchNum);
|
|
|
+ //如果队列中没取到数据,则2秒钟后再取
|
|
|
+ if (null == examCaptureQueueList || examCaptureQueueList.isEmpty()) {
|
|
|
+ captureLog.debug("[PROCESS_FACEPP." + processBatchNum + "] 抓拍队列中没有取到数据,2秒后重试");
|
|
|
|
|
|
- Util.sleep(PropertyHolder.getInt("$capture.queue.read.sleepSeconds.", 2));
|
|
|
- continue;
|
|
|
- }
|
|
|
+ Util.sleep(PropertyHolder.getInt("$capture.queue.read.sleepSeconds.", 2));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- captureLog.debug("[PROCESS_FACEPP."+processBatchNum+"] 抓拍队列中的数据条数为:"+examCaptureQueueList.size());
|
|
|
+ captureLog.debug("[PROCESS_FACEPP." + processBatchNum + "] 抓拍队列中的数据条数为:" + examCaptureQueueList.size());
|
|
|
|
|
|
- for (ExamCaptureQueueEntity offeredQueueEntity : examCaptureQueueList) {
|
|
|
- while (true) {
|
|
|
- boolean offerSuccess = concurrentTask.offerElement(offeredQueueEntity);
|
|
|
- //如果向队列中添加数据成功,则更新标识
|
|
|
- if (offerSuccess) {
|
|
|
- offeredQueueEntity.setProcessBatchNum(processBatchNum);
|
|
|
- examCaptureQueueRepo.save(offeredQueueEntity);
|
|
|
+ for (ExamCaptureQueueEntity offeredQueueEntity : examCaptureQueueList) {
|
|
|
+ while (true) {
|
|
|
+ boolean offerSuccess = concurrentTask.offerElement(offeredQueueEntity);
|
|
|
+ //如果向队列中添加数据成功,则更新标识
|
|
|
+ if (offerSuccess) {
|
|
|
+ offeredQueueEntity.setProcessBatchNum(processBatchNum);
|
|
|
+ examCaptureQueueRepo.save(offeredQueueEntity);
|
|
|
|
|
|
- captureLog.debug("[PROCESS_FACEPP."+processBatchNum+"] 向工作队列中添加数据成功:fileUrl="+offeredQueueEntity.getFileUrl());
|
|
|
- break;
|
|
|
- }
|
|
|
+ captureLog.debug("[PROCESS_FACEPP." + processBatchNum + "] 向工作队列中添加数据成功:fileUrl=" + offeredQueueEntity.getFileUrl());
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- captureLog.debug("[PROCESS_FACEPP."+processBatchNum+"] 向工作队列中添加数据失败,30秒后重试:fileUrl="+offeredQueueEntity.getFileUrl());
|
|
|
+ captureLog.debug("[PROCESS_FACEPP." + processBatchNum + "] 向工作队列中添加数据失败,30秒后重试:fileUrl=" + offeredQueueEntity.getFileUrl());
|
|
|
|
|
|
- Util.sleep(PropertyHolder.getInt("$capture.queue.offer.sleepSeconds.", 30));
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("300001","启动图片队列出现异常",e);
|
|
|
+ Util.sleep(PropertyHolder.getInt("$capture.queue.offer.sleepSeconds.", 30));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("300001", "启动图片队列出现异常", e);
|
|
|
|
|
|
- captureLog.error("[PROCESS_FACEPP."+processBatchNum+"] 百度活体检测出出异常,3秒后重试",e);
|
|
|
- Util.sleep(3);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ captureLog.error("[PROCESS_FACEPP." + processBatchNum + "] 百度活体检测出出异常,3秒后重试", e);
|
|
|
+ Util.sleep(3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void run(ApplicationArguments args) {
|
|
|
- new Thread(()->{
|
|
|
- start();
|
|
|
- }).start();
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void run(ApplicationArguments args) {
|
|
|
+ new Thread(() -> {
|
|
|
+ start();
|
|
|
+ }).start();
|
|
|
+ }
|
|
|
|
|
|
}
|