From 83426618f24a25d9cd1e5ff5f97bbc1a5d8f36ce Mon Sep 17 00:00:00 2001 From: RXS Date: Tue, 29 Aug 2023 15:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elink/esua/epdc/config/AsyncConfig.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/config/AsyncConfig.java 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; + } +}