ruoyi-admin/src/main/resources/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/enums/ThreadPoolRejectedPolicy.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/ThreadPoolProperties.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ruoyi-admin/src/main/resources/application.yml
@@ -256,20 +256,10 @@ thread-pool: # æ¯å¦å¼å¯çº¿ç¨æ± enabled: false # æ ¸å¿çº¿ç¨æ± å¤§å° corePoolSize: 8 # æå¤§å¯å建ççº¿ç¨æ° maxPoolSize: 16 # éåæå¤§é¿åº¦ queueCapacity: 128 # çº¿ç¨æ± ç»´æ¤çº¿ç¨æå 许çç©ºé²æ¶é´ keepAliveSeconds: 300 # çº¿ç¨æ± 对æç»ä»»å¡(æ 线ç¨å¯ç¨)çå¤ççç¥ # CALLER_RUNS_POLICY è°ç¨æ¹æ§è¡ # DISCARD_OLDEST_POLICY æ¾å¼ææ§ç # DISCARD_POLICY ä¸¢å¼ # ABORT_POLICY 䏿¢ rejectedExecutionHandler: CALLER_RUNS_POLICY --- # redisson ç¼åé ç½® redisson: ruoyi-common/src/main/java/com/ruoyi/common/enums/ThreadPoolRejectedPolicy.java
ÎļþÒÑɾ³ý ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java
@@ -1,7 +1,6 @@ package com.ruoyi.framework.config; import com.ruoyi.common.utils.Threads; import com.ruoyi.common.utils.reflect.ReflectUtils; import com.ruoyi.framework.config.properties.ThreadPoolProperties; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -10,7 +9,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; @@ -23,6 +21,11 @@ @Configuration public class ThreadPoolConfig { /** * æ ¸å¿çº¿ç¨æ° = cpu æ ¸å¿æ° + 1 */ private final int core = Runtime.getRuntime().availableProcessors() + 1; @Autowired private ThreadPoolProperties threadPoolProperties; @@ -30,12 +33,11 @@ @ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true") public ThreadPoolTaskExecutor threadPoolTaskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setMaxPoolSize(threadPoolProperties.getMaxPoolSize()); executor.setCorePoolSize(threadPoolProperties.getCorePoolSize()); executor.setMaxPoolSize(core); executor.setCorePoolSize(core * 2); executor.setQueueCapacity(threadPoolProperties.getQueueCapacity()); executor.setKeepAliveSeconds(threadPoolProperties.getKeepAliveSeconds()); RejectedExecutionHandler handler = ReflectUtils.newInstance(threadPoolProperties.getRejectedExecutionHandler().getClazz()); executor.setRejectedExecutionHandler(handler); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); return executor; } @@ -44,7 +46,7 @@ */ @Bean(name = "scheduledExecutorService") protected ScheduledExecutorService scheduledExecutorService() { return new ScheduledThreadPoolExecutor(threadPoolProperties.getCorePoolSize(), return new ScheduledThreadPoolExecutor(core, new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build(), new ThreadPoolExecutor.CallerRunsPolicy()) { @Override ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/ThreadPoolProperties.java
@@ -1,6 +1,5 @@ package com.ruoyi.framework.config.properties; import com.ruoyi.common.enums.ThreadPoolRejectedPolicy; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -21,16 +20,6 @@ private boolean enabled; /** * æ ¸å¿çº¿ç¨æ± å¤§å° */ private int corePoolSize; /** * æå¤§å¯å建ççº¿ç¨æ° */ private int maxPoolSize; /** * éåæå¤§é¿åº¦ */ private int queueCapacity; @@ -39,10 +28,5 @@ * çº¿ç¨æ± ç»´æ¤çº¿ç¨æå 许çç©ºé²æ¶é´ */ private int keepAliveSeconds; /** * çº¿ç¨æ± 对æç»ä»»å¡(æ 线ç¨å¯ç¨)çå¤ççç¥ */ private ThreadPoolRejectedPolicy rejectedExecutionHandler; }