Affect: Spring Boot 3.2.2, spring-messaging-6.1.3
Make it possible to set SimpleAsyncTaskExecutor
for a channel through ChannelRegistration.taskExecutor(taskExecutor)
, not only ThreadPoolTaskExecutor
, to support Java 21 virtual threads. And it might be worth making the default use of SimpleAsyncTaskExecutor
as channel's TaskExecutor when spring.threads.virtual.enabled=true
in Spring Boot 3.2
https://github.com/spring-projects/spring-framework/blob/6bd7f0231dcc47e8099000dea301157788fd5b15/spring-messaging/src/main/java/org/springframework/messaging/simp/config/ChannelRegistration.java#L54
Comment From: snicoll
Thanks for the suggestion.
Things have changed quite a bit since ChannelRegistration
was designed. It's backed by TaskExecutorRegistration
that is thread pool based since the registration can customize a number of things such as pool size and what not. Looking at the code, the customization seems to be used when creating an instance behind the scenes for you was an option.
@rstoyanchev I wonder if we couldn't simplify all that and allow the registration of an already-defined task executor so that SimpleAsyncTaskExecutor
can be provided by Spring Boot when virtual threads are enabled.
Comment From: rstoyanchev
@snicoll, it seems I overlooked this in the changes for 6.1 to enable virtual threads. We need to provide a way to pass an externally prepared TaskExecutor
through an additional method on ChannelRegistration
.
Comment From: jhoeller
Avoiding another overloaded taskExecutor
method (which would be ambiguous for taskExecutor(null)
calls then), we could introduce a void executor(Executor)
method. We don't need to declare our TaskExecutor
interface there in any case, we accept java.util.concurrent.Executor
(which TaskExecutor
extends) in many other places as well.
Comment From: snicoll
@uumarov thanks for the report. This is now fixed and I've submitted an issue in Spring Boot to get an update to the auto-configuration. Please watch https://github.com/spring-projects/spring-boot/issues/39314 for updates.
Comment From: uumarov
@snicoll thanks so much 👍