瀏覽代碼

无请求时sleep

weijianghai 1 月之前
父節點
當前提交
9e60b5e31c
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/main/java/com/nokia/dingtalk_api/service/RequestLogService.java

+ 3 - 0
src/main/java/com/nokia/dingtalk_api/service/RequestLogService.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.TimeUnit;
 
 @RequiredArgsConstructor
 @Slf4j
@@ -32,6 +33,8 @@ public class RequestLogService {
                     RequestLogPo requestLogPo = QUEUE.poll();
                     if (requestLogPo != null) {
                         iRequestLogService.save(requestLogPo);
+                    } else {
+                        TimeUnit.SECONDS.sleep(1);
                     }
                 } catch (Exception e) {
                     log.error(e.getMessage(), e);