Ole
Ole

Reputation: 46890

Configuring a thread pool for Spring Boot asynchronous TaskExecutors?

I'm going through this tutorial which explains the difference between using a Callable and a DeferredResult with the servlet 3.0 spec and Spring. For Callables spring manages the thread, so I presume then that we need to configure a thread pool? How is this configured for Spring Boot?

Upvotes: 2

Views: 3011

Answers (1)

Mikita Harbacheuski
Mikita Harbacheuski

Reputation: 2253

WebMvcConfigurationSupport.configureAsyncSupport() is used to set up async request processing. AsyncSupportConfigurer provides configuration for all controller methods returning Callable and DeferredResult. The underlying thread pool can be configured through AsyncSupportConfigurer.setTaskExecutor() using appropriate AsyncTaskExecutor implementation (ThreadPoolTaskExecutor for example). It's also possible to update this configuration on per-request basis by returning WebAsyncTask instead for Callable. Linked javadocs describe all of it in more detail.

Upvotes: 3

Related Questions