GH-8654: Fix bean deps for messaging annotations (#8657)

Fixes https://github.com/spring-projects/spring-integration/issues/8654

Spring Framework has an ability to start dependant beans automatically
when we start the current one.

The `AbstractMethodAnnotationPostProcessor` is missing a bean dependency
registration causing errors in target applications when Messaging Annotations configuration is used.

* Add `registerDependentBean()` into an `AbstractMethodAnnotationPostProcessor` when we generate
and register a `ConsumerEndpointFactoryBean`
* Change one of the `ClientManagerBackToBackTests` configuration to rely on a `@ServiceActivator`
for `Mqttv5PahoMessageHandler` bean to ensure that change in the `AbstractMethodAnnotationPostProcessor`
has a proper effect

**Cherry-pick to `6.1.x` & `6.0.x`**
This commit is contained in:
Artem Bilan
2023-06-26 14:59:55 -04:00
committed by Gary Russell
parent 6f97cfa4cc
commit 2b724c8a5d
2 changed files with 5 additions and 2 deletions

View File

@@ -271,6 +271,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
String endpointBeanName =
generateHandlerBeanName(beanName, mergedAnnotations)
.replaceFirst("\\.(handler|source)$", "");
this.beanFactory.registerDependentBean(beanName, endpointBeanName);
this.definitionRegistry.registerBeanDefinition(endpointBeanName, endpointBeanDefinition);
}