diff --git a/rest-api/src/main/java/life/qbic/data_download/rest/config/AsyncDownloadConfig.java b/rest-api/src/main/java/life/qbic/data_download/rest/config/AsyncDownloadConfig.java index 6072e2d..346e49b 100644 --- a/rest-api/src/main/java/life/qbic/data_download/rest/config/AsyncDownloadConfig.java +++ b/rest-api/src/main/java/life/qbic/data_download/rest/config/AsyncDownloadConfig.java @@ -19,13 +19,20 @@ @EnableAsync public class AsyncDownloadConfig implements AsyncConfigurer { + @Value("${spring.async.threadpool.core-size}") + private int corePoolSize; + @Value("${spring.async.threadpool.max-size}") + private int maxPoolSize; + @Value("${spring.async.threadpool.queue-capacity}") + private int queueCapacity; + @Override @Bean("taskExecutor") public AsyncTaskExecutor getAsyncExecutor() { ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); - threadPoolTaskExecutor.setCorePoolSize(2); - threadPoolTaskExecutor.setMaxPoolSize(5); - threadPoolTaskExecutor.setQueueCapacity(200); + threadPoolTaskExecutor.setCorePoolSize(corePoolSize); + threadPoolTaskExecutor.setMaxPoolSize(maxPoolSize); + threadPoolTaskExecutor.setQueueCapacity(queueCapacity); threadPoolTaskExecutor.setThreadNamePrefix("download - "); threadPoolTaskExecutor.initialize(); return threadPoolTaskExecutor; diff --git a/rest-api/src/main/resources/application.properties b/rest-api/src/main/resources/application.properties index 326ae55..f804667 100644 --- a/rest-api/src/main/resources/application.properties +++ b/rest-api/src/main/resources/application.properties @@ -59,3 +59,7 @@ server.tomcat.remoteip.protocol-header=x-forwarded-proto spring.mvc.async.request-timeout=2d # the timeout of a session spring.session.timeout=2d + +spring.async.threadpool.core-size=${ASYNC_CORE_SIZE:2} +spring.async.threadpool.max-size=${ASYNC_MAX_SIZE:5} +spring.async.threadpool.queue-capacity=${ASYNC_QUEUE_SIZE:2}