From c3b04f92b4c196644a80a912a601b5c29194f71b Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期六, 05 八月 2023 09:37:52 +0800
Subject: [PATCH] 增加线程池配置信息 修改雷达数据最近一次引导从redis获取

---
 ard-work/src/main/java/com/ruoyi/alarm/config/AsyncConfiguration.java |   42 ++++++++++++++++--------------------------
 1 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/ard-work/src/main/java/com/ruoyi/alarm/config/AsyncConfiguration.java b/ard-work/src/main/java/com/ruoyi/alarm/config/AsyncConfiguration.java
index 4052c82..f3b8be4 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/config/AsyncConfiguration.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/config/AsyncConfiguration.java
@@ -1,11 +1,14 @@
 package com.ruoyi.alarm.config;
 
+import com.google.errorprone.annotations.Var;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
 
 /**
  * @ClassName: AsyncConfiguration
@@ -17,44 +20,31 @@
 @Configuration
 @EnableAsync(proxyTargetClass = true)
 public class AsyncConfiguration {
-    @Bean("loginExecutor")
-    public Executor executor(){
-        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        //閰嶇疆鏍稿績绾跨▼鏁�
-        executor.setCorePoolSize(15);
-        //閰嶇疆鏈�澶х嚎绋嬫暟
-        executor.setMaxPoolSize(30);
-        //閰嶇疆闃熷垪澶у皬
-        executor.setQueueCapacity(1000);
-        //绾跨▼鐨勫悕绉板墠缂�
-        executor.setThreadNamePrefix("loginExecutor-");
-        //绾跨▼娲昏穬鏃堕棿锛堢锛�
-        //executor.setKeepAliveSeconds(60);
-        //绛夊緟鎵�鏈変换鍔$粨鏉熷悗鍐嶅叧闂嚎绋嬫睜
-        executor.setWaitForTasksToCompleteOnShutdown(true);
-        //璁剧疆鎷掔粷绛栫暐
-        //executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-        //鎵ц鍒濆鍖�
-        executor.initialize();
-        return executor;
-    }
+    @Value("${ThreadPoolTask.corePoolSize}")
+    Integer corePoolSize;
+    @Value("${ThreadPoolTask.maxPoolSize}")
+    Integer maxPoolSize;
+    @Value("${ThreadPoolTask.keepAliveSeconds}")
+    Integer keepAliveSeconds;
+    @Value("${ThreadPoolTask.queueCapacity}")
+    Integer queueCapacity;
     @Bean("alarmExecutor")
     public Executor alarmExecutor(){
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         //閰嶇疆鏍稿績绾跨▼鏁�
-        executor.setCorePoolSize(15);
+        executor.setCorePoolSize(corePoolSize);
         //閰嶇疆鏈�澶х嚎绋嬫暟
-        executor.setMaxPoolSize(30);
+        executor.setMaxPoolSize(maxPoolSize);
         //閰嶇疆闃熷垪澶у皬
-        executor.setQueueCapacity(1000);
+        executor.setQueueCapacity(queueCapacity);
         //绾跨▼鐨勫悕绉板墠缂�
         executor.setThreadNamePrefix("alarmExecutor-");
         //绾跨▼娲昏穬鏃堕棿锛堢锛�
-        //executor.setKeepAliveSeconds(60);
+        executor.setKeepAliveSeconds(keepAliveSeconds);
         //绛夊緟鎵�鏈変换鍔$粨鏉熷悗鍐嶅叧闂嚎绋嬫睜
         executor.setWaitForTasksToCompleteOnShutdown(true);
         //璁剧疆鎷掔粷绛栫暐
-        //executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
         //鎵ц鍒濆鍖�
         executor.initialize();
         return executor;

--
Gitblit v1.9.3