-
Notifications
You must be signed in to change notification settings - Fork 626
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
@RabbitListener use SimpleAsyncTaskExecutor crete the same name thread,when has many SimpleMessageListenerContainer #905
Comments
You currently need to create a different container factory for each listener and inject a different I will treat this issue as a new feature request to add an |
I have found a much simpler way to fix this. |
Fixes spring-projects#905 Default container thread names are based on the bean name. `@RabbitListener` containers are not beans; use `getListenerId()` instead (which falls back to bean name for other containers). **cherry-pick to all supported branches**
In the mean time; here is a simple work-around... spring.rabbitmq.listener.simple.auto-startup=false @SpringBootApplication
public class Rgh905Application {
public static void main(String[] args) {
SpringApplication.run(Rgh905Application.class, args);
}
@RabbitListener(id = "listen1", queues = "foo")
public void listen(String in) {
System.out.println(in + ":" + Thread.currentThread().getName());
}
@Bean
public ApplicationRunner runner1(RabbitTemplate template) {
return args -> template.convertAndSend("foo", "bar");
}
@Bean
public ApplicationRunner runner2(RabbitListenerEndpointRegistry registry) {
return args -> {
registry.getListenerContainers().stream()
.map(c -> (AbstractMessageListenerContainer) c)
.forEach(c -> {
c.setTaskExecutor(new SimpleAsyncTaskExecutor(c.getListenerId() + "-"));
});
registry.start();
};
}
} result
|
Fixes #905 Default container thread names are based on the bean name. `@RabbitListener` containers are not beans; use `getListenerId()` instead (which falls back to bean name for other containers). **cherry-pick to all supported branches**
Fixes #905 Default container thread names are based on the bean name. `@RabbitListener` containers are not beans; use `getListenerId()` instead (which falls back to bean name for other containers). **cherry-pick to all supported branches** (cherry picked from commit 5f4c60a) # Conflicts: # spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/EnableRabbitIntegrationTests.java
Fixes #905 Default container thread names are based on the bean name. `@RabbitListener` containers are not beans; use `getListenerId()` instead (which falls back to bean name for other containers). **cherry-pick to all supported branches** (cherry picked from commit 5f4c60a) # Conflicts: # spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/EnableRabbitIntegrationTests.java # Conflicts: # spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java
- resolve new possible null pointer dereference - if test are run on a host that resolves localhost to an IPv6 address, the behavior of bad credentials and invalid vHost tests changes
Affects Version(s): 2.1.3.RELEASE
Question
when we use the @RabbitListener ,for create the container,there is a question 。The All Thread name would be same。Because they use the below code to create。
RabbitListenerContainerFactory#createListenerContainer(org.springframework.amqp.rabbit.listener.RabbitListenerEndpoint)
But actually,we want the different SimpleAsyncTaskExecutor's thread has its own name,like the below picture. They always name like 'SimpleAsyncTaskExecutor-1',but we want 'specialSimpleAsyncTaskExecutor-1''
Just you use the @bean to create the SimpleMessageListenerContainer ,the SimpleAsyncTaskExecutor's thread can be name the thread with different name。
we want to name is different ,because we want to analyze the dump file。
The text was updated successfully, but these errors were encountered: