-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Open
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triagedtype: enhancementA general enhancementA general enhancement
Description
As far as I understand when using Virtual threads you should not use Thread pools like this:
@Configuration
class ServiceExecutorConfig : AsyncConfigurer {
override fun getAsyncExecutor(): Executor {
val taskExecutor = ThreadPoolTaskExecutor().apply {
corePoolSize = 15
maxPoolSize = 50
setQueueCapacity(100)
initialize()
}
return DelegatingSecurityContextAsyncTaskExecutor(taskExecutor)
}
}
But instead something like:
@Configuration
@EnableAsync
class AsyncConfig(
private val builder: SimpleAsyncTaskExecutorBuilder
) {
@Bean(name = ["secExecutor"])
fun secExecutor(): AsyncTaskExecutor {
// With spring.threads.virtual.enabled=true this builder creates
// a SimpleAsyncTaskExecutor that uses a *new virtual thread per task*.
val delegate = builder
.threadNamePrefix("async-")
.build()
return DelegatingSecurityContextAsyncTaskExecutor(delegate)
}
}
I'm trying to find good official docs on how to handle this, the first results are blogs recommending the ThreadPoolTaskExecutor approach.
I also find this, which does not cover a simple way of making Spring security work with Async out of the box:
https://docs.spring.io/spring-security/reference/features/integrations/concurrency.html
I'm not sure if this is something that it would make sense if the framework just solved with reasonable defaults?
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageAn issue we've not yet triagedAn issue we've not yet triagedtype: enhancementA general enhancementA general enhancement