From 38f29e38fcc668171dc05c53d40a36b895c86102 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: 星期四, 10 十月 2024 13:34:28 +0800
Subject: [PATCH] init
---
ard-work/src/main/java/com/ruoyi/alarm/config/AsyncConfiguration.java | 66 ++++++++++++++++++++++-----------
1 files changed, 44 insertions(+), 22 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 bba963a..95838d8 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
@@ -4,6 +4,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -19,7 +20,7 @@
**/
@Configuration
@EnableAsync
-public class AsyncConfiguration {
+public class AsyncConfiguration{
@Value("${ThreadPoolTask.corePoolSize}")
Integer corePoolSize;
@Value("${ThreadPoolTask.maxPoolSize}")
@@ -50,27 +51,6 @@
executor.initialize();
return executor;
}
- @Bean("loginExecutor")
- public Executor loginExecutor(){
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
- //閰嶇疆鏍稿績绾跨▼鏁�
- executor.setCorePoolSize(corePoolSize);
- //閰嶇疆鏈�澶х嚎绋嬫暟
- executor.setMaxPoolSize(maxPoolSize);
- //閰嶇疆闃熷垪澶у皬
- executor.setQueueCapacity(queueCapacity);
- //绾跨▼鐨勫悕绉板墠缂�
- executor.setThreadNamePrefix("loginExecutor-");
- //绾跨▼娲昏穬鏃堕棿锛堢锛�
- executor.setKeepAliveSeconds(keepAliveSeconds);
- //绛夊緟鎵�鏈変换鍔$粨鏉熷悗鍐嶅叧闂嚎绋嬫睜
- executor.setWaitForTasksToCompleteOnShutdown(true);
- //璁剧疆鎷掔粷绛栫暐
- executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
- //鎵ц鍒濆鍖�
- executor.initialize();
- return executor;
- }
@Bean("guideExecutor")
public Executor guideExecutor(){
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
@@ -92,4 +72,46 @@
executor.initialize();
return executor;
}
+ @Bean("globalExecutor")
+ public Executor globalExecutor(){
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ //閰嶇疆鏍稿績绾跨▼鏁�
+ executor.setCorePoolSize(corePoolSize);
+ //閰嶇疆鏈�澶х嚎绋嬫暟
+ executor.setMaxPoolSize(maxPoolSize);
+ //閰嶇疆闃熷垪澶у皬
+ executor.setQueueCapacity(queueCapacity);
+ //绾跨▼鐨勫悕绉板墠缂�
+ executor.setThreadNamePrefix("globalExecutor-");
+ //绾跨▼娲昏穬鏃堕棿锛堢锛�
+ executor.setKeepAliveSeconds(keepAliveSeconds);
+ //绛夊緟鎵�鏈変换鍔$粨鏉熷悗鍐嶅叧闂嚎绋嬫睜
+ executor.setWaitForTasksToCompleteOnShutdown(true);
+ //璁剧疆鎷掔粷绛栫暐
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+ //鎵ц鍒濆鍖�
+ executor.initialize();
+ return executor;
+ }
+ @Bean("msgExecutor")
+ public Executor msgExecutor(){
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ //閰嶇疆鏍稿績绾跨▼鏁�
+ executor.setCorePoolSize(corePoolSize);
+ //閰嶇疆鏈�澶х嚎绋嬫暟
+ executor.setMaxPoolSize(maxPoolSize);
+ //閰嶇疆闃熷垪澶у皬
+ executor.setQueueCapacity(queueCapacity);
+ //绾跨▼鐨勫悕绉板墠缂�
+ executor.setThreadNamePrefix("msgExecutor-");
+ //绾跨▼娲昏穬鏃堕棿锛堢锛�
+ executor.setKeepAliveSeconds(keepAliveSeconds);
+ //绛夊緟鎵�鏈変换鍔$粨鏉熷悗鍐嶅叧闂嚎绋嬫睜
+ executor.setWaitForTasksToCompleteOnShutdown(true);
+ //璁剧疆鎷掔粷绛栫暐
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+ //鎵ц鍒濆鍖�
+ executor.initialize();
+ return executor;
+ }
}
--
Gitblit v1.9.3