diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java index 571bd9901f..746ecbdbec 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java @@ -196,26 +196,7 @@ public class ConsumerEndpointFactoryBean "Consider specifying the 'beanName' property on this ConsumerEndpointFactoryBean."); } else { - try { - if (!this.beanName.startsWith("org.springframework")) { - MessageHandler targetHandler = this.handler; - if (AopUtils.isAopProxy(targetHandler)) { - Object target = ((Advised) targetHandler).getTargetSource().getTarget(); - if (target instanceof MessageHandler) { - targetHandler = (MessageHandler) target; - } - } - if (targetHandler instanceof IntegrationObjectSupport) { - ((IntegrationObjectSupport) targetHandler).setComponentName(this.beanName); - } - } - } - catch (Exception e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Could not set component name for handler " - + this.handler + " for " + this.beanName + " :" + e.getMessage()); - } - } + populateComponentNameIfAny(); } if (!(this.handler instanceof ReactiveMessageHandlerAdapter)) { @@ -230,6 +211,29 @@ public class ConsumerEndpointFactoryBean initializeEndpoint(); } + private void populateComponentNameIfAny() { + try { + if (!this.beanName.startsWith("org.springframework")) { + MessageHandler targetHandler = this.handler; + if (AopUtils.isAopProxy(targetHandler)) { + Object target = ((Advised) targetHandler).getTargetSource().getTarget(); + if (target instanceof MessageHandler) { + targetHandler = (MessageHandler) target; + } + } + if (targetHandler instanceof IntegrationObjectSupport) { + ((IntegrationObjectSupport) targetHandler).setComponentName(this.beanName); + } + } + } + catch (Exception e) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Could not set component name for handler " + + this.handler + " for " + this.beanName + " :" + e.getMessage()); + } + } + } + private void adviceChain() { if (!CollectionUtils.isEmpty(this.adviceChain)) { /* diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/outbound/ReactiveMongoDbStoringMessageHandler.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/outbound/ReactiveMongoDbStoringMessageHandler.java index dc9603e10d..06eee23a9d 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/outbound/ReactiveMongoDbStoringMessageHandler.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/outbound/ReactiveMongoDbStoringMessageHandler.java @@ -105,9 +105,9 @@ public class ReactiveMongoDbStoringMessageHandler extends AbstractReactiveMessag super.onInit(); this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory()); if (this.mongoTemplate == null) { - ReactiveMongoTemplate mongoTemplate = new ReactiveMongoTemplate(this.mongoDbFactory, this.mongoConverter); - mongoTemplate.setApplicationContext(getApplicationContext()); - this.mongoTemplate = mongoTemplate; + ReactiveMongoTemplate template = new ReactiveMongoTemplate(this.mongoDbFactory, this.mongoConverter); + template.setApplicationContext(getApplicationContext()); + this.mongoTemplate = template; } this.initialized = true; }