From 3229773d6e228eef24b0adf9f83b1483b139166d Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 15 Jul 2021 13:49:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=96=B9=E6=B3=95=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/io/metersphere/Application.java | 2 -- .../src/main/java/io/metersphere/config/AsyncConfig.java | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/Application.java b/backend/src/main/java/io/metersphere/Application.java index fa5857c542..202977b8ff 100644 --- a/backend/src/main/java/io/metersphere/Application.java +++ b/backend/src/main/java/io/metersphere/Application.java @@ -10,7 +10,6 @@ import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.context.annotation.PropertySource; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication(exclude = { @@ -24,7 +23,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; JmeterProperties.class }) @EnableScheduling -@EnableAsync(proxyTargetClass = true) //@PropertySource(value = {"file:c:\\opt\\metersphere\\conf\\metersphere.properties"}, encoding = "UTF-8", ignoreResourceNotFound = true) @PropertySource(value = {"file:/opt/metersphere/conf/metersphere.properties"}, encoding = "UTF-8", ignoreResourceNotFound = true) public class Application { diff --git a/backend/src/main/java/io/metersphere/config/AsyncConfig.java b/backend/src/main/java/io/metersphere/config/AsyncConfig.java index c30ca8ee41..5fb72ebacc 100644 --- a/backend/src/main/java/io/metersphere/config/AsyncConfig.java +++ b/backend/src/main/java/io/metersphere/config/AsyncConfig.java @@ -6,6 +6,8 @@ import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import java.util.concurrent.ThreadPoolExecutor; + @EnableAsync(proxyTargetClass = true) @Configuration public class AsyncConfig { @@ -13,9 +15,9 @@ public class AsyncConfig { @Bean public AsyncTaskExecutor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setThreadNamePrefix("Async-Executor"); - executor.setCorePoolSize(5); - executor.setMaxPoolSize(10); + executor.setThreadNamePrefix("Async-Executor-"); + executor.setCorePoolSize(10); + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); return executor; } }