Skip to content

Commit 9f7b65b

Browse files
garyrussellartembilan
authored andcommitted
GH-905: Fix @RabbitListener Thread Names
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
1 parent 1fc6fc1 commit 9f7b65b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/EnableRabbitIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public static void tearDown() {
214214

215215
@Test
216216
public void autoDeclare() {
217-
assertEquals("FOO", rabbitTemplate.convertSendAndReceive("auto.exch", "auto.rk", "foo"));
217+
assertEquals("FOOthreadNamer-1", rabbitTemplate.convertSendAndReceive("auto.exch", "auto.rk", "foo"));
218218
}
219219

220220
@Test
@@ -660,13 +660,13 @@ public String testAnnotationInheritance(String foo) {
660660

661661
public static class MyService {
662662

663-
@RabbitListener(bindings = @QueueBinding(
663+
@RabbitListener(id = "threadNamer", bindings = @QueueBinding(
664664
value = @Queue(value = "auto.declare", autoDelete = "true"),
665665
exchange = @Exchange(value = "auto.exch", autoDelete = "true"),
666666
key = "auto.rk")
667667
)
668668
public String handleWithDeclare(String foo) {
669-
return foo.toUpperCase();
669+
return foo.toUpperCase() + Thread.currentThread().getName();
670670
}
671671

672672
@RabbitListener(bindings = @QueueBinding(

0 commit comments

Comments
 (0)