From 723499fff0c4ec73397d83abab306ee646ee4bfd Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 18 Feb 2019 12:03:19 -0500 Subject: [PATCH] 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 5f4c60a969e42b9b89b6dbb758b62ebfe970f295) --- .../rabbit/listener/SimpleMessageListenerContainer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java index 14c97c76..42222b38 100644 --- a/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java +++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -797,8 +797,8 @@ public class SimpleMessageListenerContainer extends AbstractMessageListenerConta if (!this.isExposeListenerChannel() && this.transactionManager != null) { logger.warn("exposeListenerChannel=false is ignored when using a TransactionManager"); } - if (!this.taskExecutorSet && StringUtils.hasText(this.getBeanName())) { - this.taskExecutor = new SimpleAsyncTaskExecutor(this.getBeanName() + "-"); + if (!this.taskExecutorSet && StringUtils.hasText(getListenerId())) { + this.taskExecutor = new SimpleAsyncTaskExecutor(getListenerId() + "-"); this.taskExecutorSet = true; } initializeProxy();