GH-905: Fix @RabbitListener Thread Names

Fixes https://github.com/spring-projects/spring-amqp/issues/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 5f4c60a969)

# 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
This commit is contained in:
Gary Russell
2019-02-15 17:41:17 -05:00
committed by Artem Bilan
parent 1fc6fc1f0d
commit 9f7b65ba27

View File

@@ -214,7 +214,7 @@ public class EnableRabbitIntegrationTests {
@Test
public void autoDeclare() {
assertEquals("FOO", rabbitTemplate.convertSendAndReceive("auto.exch", "auto.rk", "foo"));
assertEquals("FOOthreadNamer-1", rabbitTemplate.convertSendAndReceive("auto.exch", "auto.rk", "foo"));
}
@Test
@@ -660,13 +660,13 @@ public class EnableRabbitIntegrationTests {
public static class MyService {
@RabbitListener(bindings = @QueueBinding(
@RabbitListener(id = "threadNamer", bindings = @QueueBinding(
value = @Queue(value = "auto.declare", autoDelete = "true"),
exchange = @Exchange(value = "auto.exch", autoDelete = "true"),
key = "auto.rk")
)
public String handleWithDeclare(String foo) {
return foo.toUpperCase();
return foo.toUpperCase() + Thread.currentThread().getName();
}
@RabbitListener(bindings = @QueueBinding(