diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/config/AsyncConfig.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/config/AsyncConfig.java new file mode 100644 index 000000000..32f72d7b1 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/config/AsyncConfig.java @@ -0,0 +1,22 @@ +package com.elink.esua.epdc.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.core.task.AsyncTaskExecutor; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +public class AsyncConfig { + + private static final int MAX_POOL_SIZE = 100; + + private static final int CORE_POOL_SIZE = 50; + + @Bean("asyncTaskExecutor") + public AsyncTaskExecutor asyncTaskExecutor() { + ThreadPoolTaskExecutor asyncTaskExecutor = new ThreadPoolTaskExecutor(); + asyncTaskExecutor.setMaxPoolSize(MAX_POOL_SIZE); + asyncTaskExecutor.setCorePoolSize(CORE_POOL_SIZE); + asyncTaskExecutor.setThreadNamePrefix("async-task-thread-pool-"); + asyncTaskExecutor.initialize(); + return asyncTaskExecutor; + } +}