package cc.mrbird.febs.server.system.configure;
|
|
import cc.mrbird.febs.common.core.entity.constant.FebsConstant;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
/**
|
* @author MrBird
|
*/
|
@Configuration
|
public class FebsWebConfigure {
|
|
/**
|
* 注册异步线程池
|
*/
|
@Bean(FebsConstant.ASYNC_POOL)
|
public ThreadPoolTaskExecutor asyncThreadPoolTaskExecutor() {
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
executor.setCorePoolSize(5);
|
executor.setMaxPoolSize(20);
|
executor.setQueueCapacity(100);
|
executor.setKeepAliveSeconds(30);
|
executor.setThreadNamePrefix("Febs-Async-Thread");
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
executor.setAwaitTerminationSeconds(60);
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
executor.initialize();
|
return executor;
|
}
|
}
|