Skip to content

Commit a2293d2

Browse files
authored
make async config configurable (#9)
1 parent 3a70248 commit a2293d2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

rest-api/src/main/java/life/qbic/data_download/rest/config/AsyncDownloadConfig.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@
1919
@EnableAsync
2020
public class AsyncDownloadConfig implements AsyncConfigurer {
2121

22+
@Value("${spring.async.threadpool.core-size}")
23+
private int corePoolSize;
24+
@Value("${spring.async.threadpool.max-size}")
25+
private int maxPoolSize;
26+
@Value("${spring.async.threadpool.queue-capacity}")
27+
private int queueCapacity;
28+
2229
@Override
2330
@Bean("taskExecutor")
2431
public AsyncTaskExecutor getAsyncExecutor() {
2532
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
26-
threadPoolTaskExecutor.setCorePoolSize(2);
27-
threadPoolTaskExecutor.setMaxPoolSize(5);
28-
threadPoolTaskExecutor.setQueueCapacity(200);
33+
threadPoolTaskExecutor.setCorePoolSize(corePoolSize);
34+
threadPoolTaskExecutor.setMaxPoolSize(maxPoolSize);
35+
threadPoolTaskExecutor.setQueueCapacity(queueCapacity);
2936
threadPoolTaskExecutor.setThreadNamePrefix("download - ");
3037
threadPoolTaskExecutor.initialize();
3138
return threadPoolTaskExecutor;

rest-api/src/main/resources/application.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ server.tomcat.remoteip.protocol-header=x-forwarded-proto
5959
spring.mvc.async.request-timeout=2d
6060
# the timeout of a session
6161
spring.session.timeout=2d
62+
63+
spring.async.threadpool.core-size=${ASYNC_CORE_SIZE:2}
64+
spring.async.threadpool.max-size=${ASYNC_MAX_SIZE:5}
65+
spring.async.threadpool.queue-capacity=${ASYNC_QUEUE_SIZE:2}

0 commit comments

Comments
 (0)