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; } }