build: 启用异步机制
This commit is contained in:
parent
fdbd90c8a0
commit
fc63fa5bc1
|
@ -0,0 +1,21 @@
|
|||
package io.metersphere.system.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
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)
|
||||
public class AsyncConfig {
|
||||
|
||||
@Bean
|
||||
public AsyncTaskExecutor asyncTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setThreadNamePrefix("Async-Executor-");
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
return executor;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue