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

[feature-request] Auto-configure Rabbit message listener container to use a virtual thread based executor #3040

Closed
ferblaca opened this issue Nov 14, 2024 · 0 comments
Assignees
Milestone

Comments

@ferblaca
Copy link
Contributor

Describe the feature request
Based on spring-projects/spring-boot#36387, when virtual threads are enabled, auto-configure Rabbit Message listener container (AbstractMessageListenerContainer) to use a virtual thread based executor.

Currently, enabling virtual threads does not automatically configure the executor as virtual threads. To achieve this behavior a ListenerContainerCustomizer can be configured as follows:

@ConditionalOnEnabledVirtualThreads
public class RabbitMQListenerContainerConfiguration {

  @Bean
  public ListenerContainerCustomizer<MessageListenerContainer> threadingListenerContainerCustomizer() {
    return (container, destination, group) -> {
      if (container instanceof final AbstractMessageListenerContainer listenerContainer) {
        final SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(destination + "-" + group);
        executor.setVirtualThreads(true);
        listenerContainer.setTaskExecutor(executor);
      }
    };
  }
}

But it would be nice not to have to do this for every RabbitMQ binder configured and have it automatically configured with SCS.

Version of the framework
Spring Boot 3.3.5
Spring Cloud 2023.0.3

@artembilan artembilan self-assigned this Nov 14, 2024
@artembilan artembilan added this to the 4.2.0 milestone Nov 14, 2024
artembilan added a commit to artembilan/spring-cloud-stream that referenced this issue Nov 14, 2024
Fixes: spring-cloud#3040

This change adds out-of-the-box `ListenerContainerCustomizer<AbstractMessageListenerContainer>`
to set `VirtualThreadTaskExecutor` into an `AbstractMessageListenerContainer` created by the binder
when `Threading.VIRTUAL` condition is met
@olegz olegz closed this as completed in a9fe0c2 Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants