ソースを参照

update 线程注入优化

ct 4 日 前
コミット
e6a98c3a53

+ 3 - 2
fs-ipad-task/src/main/java/com/fs/framework/config/ThreadPoolConfig.java

@@ -8,6 +8,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -89,7 +90,7 @@ public class ThreadPoolConfig
     }
 
     @Bean(name = "sopRatingExecutor")
-    public Executor sopRatingExecutor() {
+    public ExecutorService sopRatingExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(16); // 根据需求调整
         executor.setMaxPoolSize(32);  // 根据需求调整
@@ -97,6 +98,6 @@ public class ThreadPoolConfig
         executor.setThreadNamePrefix("SopRating-");
         executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
         executor.initialize();
-        return executor;
+        return executor.getThreadPoolExecutor();
     }
 }

+ 2 - 0
fs-qw-task/src/main/java/com/fs/app/taskService/impl/QwExternalContactRatingMoreSevenDaysServiceImpl.java

@@ -20,6 +20,7 @@ import com.fs.voice.utils.StringUtil;
 import com.google.common.util.concurrent.AtomicDouble;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
@@ -63,6 +64,7 @@ public class QwExternalContactRatingMoreSevenDaysServiceImpl implements QwExtern
     private ISopUserLogsInfoService iSopUserLogsInfoService;
 
     @Autowired
+    @Qualifier("sopRatingExecutor")
     private ExecutorService sopRatingExecutor;  // 自定义线程池
 
     // 任务队列

+ 2 - 0
fs-qw-task/src/main/java/com/fs/app/taskService/impl/QwExternalContactRatingServiceImpl.java

@@ -20,6 +20,7 @@ import com.fs.voice.utils.StringUtil;
 import com.google.common.util.concurrent.AtomicDouble;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
@@ -66,6 +67,7 @@ public class QwExternalContactRatingServiceImpl implements QwExternalContactRati
     private ISopUserLogsInfoService iSopUserLogsInfoService;
 
     @Autowired
+    @Qualifier("sopRatingExecutor")
     private ExecutorService sopRatingExecutor;  // 自定义线程池
 
     // 任务队列

+ 2 - 0
fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopUserLogsInfoByIsDaysNotStudyImpl.java

@@ -14,6 +14,7 @@ import com.fs.system.service.ISysConfigService;
 import com.fs.voice.utils.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
@@ -46,6 +47,7 @@ public class SopUserLogsInfoByIsDaysNotStudyImpl implements SopUserLogsInfoByIsD
     private ISopUserLogsService iSopUserLogsService;
 
     @Autowired
+    @Qualifier("sopRatingExecutor")
     private ExecutorService sopRatingExecutor;  // 自定义线程池
 
     // 任务队列

+ 3 - 2
fs-qw-task/src/main/java/com/fs/framework/config/ThreadPoolConfig.java

@@ -10,6 +10,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
 
 import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -102,7 +103,7 @@ public class ThreadPoolConfig
     }
 
     @Bean(name = "sopRatingExecutor")
-    public Executor sopRatingExecutor() {
+    public ExecutorService sopRatingExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(16); // 根据需求调整
         executor.setMaxPoolSize(32);  // 根据需求调整
@@ -110,6 +111,6 @@ public class ThreadPoolConfig
         executor.setThreadNamePrefix("SopRating-");
         executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
         executor.initialize();
-        return executor;
+        return executor.getThreadPoolExecutor();
     }
 }