-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-3844: Rework messaging annotation with @Bean #3877
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
Conversation
Fixes #3844 * Make `MessagingAnnotationPostProcessor` as a `BeanDefinitionRegistryPostProcessor` to process bean definitions as early as possible and register respective messaging components at that early phase * Make bean definitions parsing logic optional for AOT and native mode since beans have bean parsed during AOT building phase * Introduce a `BeanDefinitionPropertiesMapper` for easier mapping of the annotation attributes to the target `BeanDefinition` * Remove `@Bean`-related logic from method parsing process * Change the logic for `@Bean`-based endpoint bean names: since we don't deal with methods on the bean definition phase, then method name does not make sense. It even may mislead if we `@Bean` name is based on a method by default, so we end up with duplicated word in the target endpoint bean name. Now we don't * Fix `configuration.adoc` respectively for a new endpoint bean name logic * In the end the new logic in the `AbstractMethodAnnotationPostProcessor` is similar to XML parsers: we feed annotation attributes to the `AbstractStandardMessageHandlerFactoryBean` impls
|
||
Poller poller = MessagingAnnotationUtils.resolveAttribute(annotations, "poller", Poller.class); | ||
Reactive reactive = MessagingAnnotationUtils.resolveAttribute(annotations, "reactive", Reactive.class); | ||
Assert.state(reactive == null || poller == null, "The 'poller' and 'reactive' are mutually exclusive."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either "'poller' and 'reactive' are mutually exclusive."
or "The 'poller' and 'reactive' attributes are mutually exclusive."
Also should include the bean name.
AbstractSimpleMessageHandlerFactoryBean.class) | ||
&& !RouterFactoryBean.class.isAssignableFrom(handlerBeanClass)) { | ||
|
||
applyAdviceChainIfAny(handlerBeanDefinition, annotations); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we doing this here - this will add all the advices to the handler - the CEFB (which also gets the full advice chain) selectively applies advices to the handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment exactly in that ConsumerEndpointFactoryBean.adviceChain()
:
* ARPMHs advise the handleRequestMessage method internally and already have the advice chain injected.
* So we only advise handlers that are not reply-producing.
so, we don't set an adviceChain
to the AbstractReplyProducingMessageHandler
, neither from XML parser, nor Java DSL - ConsumerEndpointSpec.doGet()
.
We may revise it though, but I guess there was a reason why you implemented that way in the XML parser day first.
Different issue either way.
For example, the `SourcePollingChannelAdapter` endpoint for the `consoleSource()` definition <<annotations_on_beans,shown earlier>> gets a bean name of `myFlowConfiguration.consoleSource.inboundChannelAdapter`. | ||
* The `AbstractEndpoint` bean name is generated with the following pattern: `[@Bean name].[decapitalizedAnnotationClassShortName]`. | ||
For example, the `SourcePollingChannelAdapter` endpoint for the `consoleSource()` definition <<annotations_on_beans,shown earlier>> gets a bean name of `consoleSource.inboundChannelAdapter`. | ||
Unlike with POJO methods the bean method name is not included into an endpoint bean name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike with POJO methods the bean method name is not included into an endpoint bean name. | |
Unlike with POJO methods, the bean method name is not included in the endpoint bean name. |
Fixes #3844
MessagingAnnotationPostProcessor
as aBeanDefinitionRegistryPostProcessor
to process bean definitions as early as possible and register respective messaging
components at that early phase
have bean parsed during AOT building phase
BeanDefinitionPropertiesMapper
for easier mappingof the annotation attributes to the target
BeanDefinition
@Bean
-related logic from method parsing process@Bean
-based endpoint bean names:since we don't deal with methods on the bean definition phase, then method name
does not make sense.
It even may mislead if we
@Bean
name is based on a method by default, so we end upwith duplicated word in the target endpoint bean name.
Now we don't
configuration.adoc
respectively for a new endpoint bean name logicAbstractMethodAnnotationPostProcessor
is similar to XML parsers: we feed annotation attributes to the
AbstractStandardMessageHandlerFactoryBean
impls