Skip to content

Commit

Permalink
feat: add DelegatingSecurityContextAsyncTaskExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
webatspeed committed Nov 3, 2022
1 parent c8c52ff commit e543453
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/de/caritas/cob/messageservice/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.task.DelegatingSecurityContextAsyncTaskExecutor;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.web.client.RestTemplate;

Expand Down Expand Up @@ -34,4 +37,20 @@ public LocalValidatorFactoryBean validator(MessageSource messageSource) {
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}

@Bean
public TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(15);
executor.setThreadNamePrefix("default_task_executor_thread");
executor.initialize();

return executor;
}

@Bean
public DelegatingSecurityContextAsyncTaskExecutor taskExecutor(ThreadPoolTaskExecutor delegate) {
return new DelegatingSecurityContextAsyncTaskExecutor(delegate);
}
}

0 comments on commit e543453

Please sign in to comment.