Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to configure any TaskExecutor through ChannelRegistration #32081

Closed
uumarov opened this issue Jan 22, 2024 · 5 comments
Closed
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement
Milestone

Comments

@uumarov
Copy link

uumarov commented Jan 22, 2024

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

public TaskExecutorRegistration taskExecutor(@Nullable ThreadPoolTaskExecutor taskExecutor) {

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 22, 2024
@snicoll
Copy link
Member

snicoll commented Jan 23, 2024

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.

@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 23, 2024
@snicoll snicoll added this to the 6.x Backlog milestone Jan 23, 2024
@snicoll snicoll added the in: messaging Issues in messaging modules (jms, messaging) label Jan 23, 2024
@rstoyanchev
Copy link
Contributor

@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.

@rstoyanchev rstoyanchev changed the title Make it possible to set SimpleAsyncTaskExecutor for a channel through ChannelRegistration.taskExecutor(taskExecutor) Make it possible to configure any TaskExecutor through ChannelRegistration Jan 23, 2024
@snicoll snicoll self-assigned this Jan 24, 2024
@snicoll snicoll modified the milestones: 6.x Backlog, 6.1.x Jan 24, 2024
@jhoeller
Copy link
Contributor

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.

snicoll added a commit to snicoll/spring-framework that referenced this issue Jan 26, 2024
This commit introduces a new method to configure an existing
TaskExecutor in ChannelRegistration. Contrary to
TaskExecutorRegistration, a ThreadPoolTaskExecutor is not necessary,
and it can't be further configured.

Closes spring-projectsgh-32081
snicoll added a commit to snicoll/spring-framework that referenced this issue Jan 26, 2024
This commit introduces a new method to configure an existing
TaskExecutor in ChannelRegistration. Contrary to
TaskExecutorRegistration, a ThreadPoolTaskExecutor is not necessary,
and it can't be further configured. This includes the thread name
prefix.

Closes spring-projectsgh-32081
snicoll added a commit to snicoll/spring-framework that referenced this issue Jan 26, 2024
This commit introduces a new method to configure an existing
TaskExecutor in ChannelRegistration. Contrary to
TaskExecutorRegistration, a ThreadPoolTaskExecutor is not necessary,
and it can't be further configured. This includes the thread name
prefix.

Closes spring-projectsgh-32081
@snicoll snicoll modified the milestones: 6.1.x, 6.1.4 Jan 26, 2024
@snicoll
Copy link
Member

snicoll commented Jan 26, 2024

@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 spring-projects/spring-boot#39314 for updates.

@uumarov
Copy link
Author

uumarov commented Jan 26, 2024

@snicoll thanks so much 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants