Skip to content

Commit

Permalink
make async config configurable (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
KochTobi authored Jun 10, 2024
1 parent 3a70248 commit a2293d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions rest-api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit a2293d2

Please sign in to comment.