-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Defer Messaging annotations process #2769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer Messaging annotations process #2769
Conversation
I'll fix test-cases when we agree with the solution. |
Please re-push with corrected commit comment |
OK. I will. Thanks. |
The approach looks good. |
The `AbstractMethodAnnotationPostProcessor` and its implementations have a `beanFactory.getBean()` call for the `@Bean` methods with Messaging annotations. This is done, actually, from the `MessagingAnnotationPostProcessor.postProcessAfterInitialization()` which might be still too early in some scenarios, like Spring Cloud Feign with its child application contexts being initialized from the `FeignClientFactoryBean`, causing a `BeanCurrentlyInCreationException` See https://stackoverflow.com/questions/54887963/beancurrentlyincreationexception-when-using-spring-integration-with-spring-cloud * Implement a `SmartInitializingSingleton` for the `MessagingAnnotationPostProcessor` and gather `Runnable` wrappers for newly introduced `postProcessMethodAndRegisterEndpointIfAny()` to be called later in the `afterSingletonsInstantiated()` when context is still in the initialization phase. All runtime-registered beans are going to be processed normally from the regular `postProcessAfterInitialization()` **Cherry-pick to 5.1.x**
9ed2b03
to
cfb6cd6
Compare
Re-pushed after rebasing, fixing tests and commit message. |
…andle all the possible `AbstractEndpoint` beans registration. See its JavaDocs for more info * Fix `AbstractCorrelatingMessageHandlerParser` and `AbstractConsumerEndpointParser` to use bean names for `outputChannel` and `discardChannel` instead of bean references. Since `MessagingAnnotationPostProcessor` now registers endpoints and beans for channels much later, than parsers, we can't rely on bean references any more there. * Fixes for failing tests which expected `outputChannel/discardChannel` bean references, when it is already just their names for late binding. * Apply some code style polishing for the affected classes. * Add `@Nullable` for `MessageSelector` parameter in the `QueueChannel.purge()`
I think we should not back-port this: too much changes and might be some kind of breaking change for some use-cases... |
The
AbstractMethodAnnotationPostProcessor
and its implementationshave a
beanFactory.getBean()
call for the@Bean
methods withMessaging annotations.
This is done, actually, from the
MessagingAnnotationPostProcessor.postProcessAfterInitialization()
which might be still too early in some scenarios, like Spring Cloud Feign
with its child application contexts being initialized from the
FeignClientFactoryBean
, causing aBeanCurrentlyInCreationException
See https://stackoverflow.com/questions/54887963/beancurrentlyincreationexception-when-using-spring-integration-with-spring-cloud
SmartInitializingSingleton
for theMessagingAnnotationPostProcessor
and gather
Runnable
wrappers for newly introducedpostProcessMethodAndRegisterEndpointIfAny()
to be called later in the
afterSingletonsInstantiated()
when context isstill in the initialization phase.
All runtime-registered beans are going to be processed normally from the
regular
postProcessAfterInitialization()