瀏覽代碼

调整逻辑

Levi 3 年之前
父節點
當前提交
01265e3972

+ 3 - 3
src/main/java/com/ebei/screen/common/task/ScreenTask.java

@@ -48,15 +48,15 @@ public class ScreenTask {
     /**
      * 每3秒处理6条数据
      */
-    @Scheduled(cron = "*/3 * * * * ?")
+    @Scheduled(cron = "*/5 * * * * ?")
     public void exec() {
         try {
             log.info("开始处理数据 开始时间:{}", DateUtil.now());
             // 获取10条进行处理
-            boolean result = parkSystemService.taskExec(6);
+            boolean result = parkSystemService.taskExec(10);
             log.info("数据处理结束 结束时间:{} 处理结果:{}", DateUtil.now(), result);
         } catch (Exception e) {
-            log.info("定时任务执行出现错误:{}", e);
+            log.error("定时任务执行出现错误:", e);
         }
     }
 

+ 2 - 2
src/main/java/com/ebei/screen/common/util/RunnableUtils.java

@@ -7,7 +7,7 @@ import java.util.function.Supplier;
 
 @Slf4j
 public class RunnableUtils {
-    private static final int IN_USE_SIZE = 40;
+    private static final int IN_USE_SIZE = 100;
     private static final ExecutorService service = createPoolExecutor();
 
     public static void start(Running run) {
@@ -37,7 +37,7 @@ public class RunnableUtils {
     }
 
     private static ExecutorService createPoolExecutor() {
-        return new ThreadPoolExecutor(IN_USE_SIZE, IN_USE_SIZE, 60L, TimeUnit.SECONDS, new SynchronousQueue());
+        return new ThreadPoolExecutor(IN_USE_SIZE, IN_USE_SIZE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), new ThreadPoolExecutor.CallerRunsPolicy());
     }
 
 }

+ 2 - 0
src/main/java/com/ebei/screen/service/impl/ParkSystemServiceImpl.java

@@ -113,6 +113,7 @@ public class ParkSystemServiceImpl implements ParkSystemService {
                 try {
                     xx = mongoTemplate.findById(x, JSONObject.class, "parkQueue");
                     if (xx == null) {
+                        log.info("没有找到对应的数据:{}", x);
                         return;
                     }
                     Instant start = Instant.now();
@@ -141,6 +142,7 @@ public class ParkSystemServiceImpl implements ParkSystemService {
                     mongoTemplate.remove(xx, "parkQueue");
                     log.info("执行队列出现异常:{} 参数:{}", e, xx);
                 } finally {
+                    log.info("countDown扣减:{} 成功", x);
                     countDownLatch.countDown();
                 }
             }));

+ 1 - 0
src/main/resources/application-prod.yml

@@ -12,6 +12,7 @@ spring:
       port: 27017
       username: eaglescreen
       password: yibeitech@2019
+      authentication-database: eaglescreen
   redis:
     host: 192.168.77.25
     port: 6379