INT-4488: Require @EnablePublisher

JIRA: https://jira.spring.io/browse/INT-4488

Since `PublisherAnnotationBeanPostProcessor` is quite expensive
(1.5x the CPU used by `MessagingAnnotationPostProcessor` in a simple
application)

* So not register a `PublisherAnnotationBeanPostProcessor` by default.
The `@EnablePublisher` has to be presented on the `@Configuration`
to allow the `@Publisher` AOP
* Change the `<int:annotation-config>` to require a new
`<int:enable-publisher>` sub-element for similar purpose - do not
register `PublisherAnnotationBeanPostProcessor` by default
This commit is contained in:
Artem Bilan
2018-06-26 13:01:55 -04:00
committed by Gary Russell
parent 13510df575
commit 69af967c78
9 changed files with 118 additions and 60 deletions

View File

@@ -15,6 +15,8 @@ Spring Integration provides two approaches: XML and Annotation-driven.
==== Annotation-driven approach via @Publisher annotation
The annotation-driven approach allows you to annotate any method with the `@Publisher` annotation, specifying a 'channel' attribute.
Starting with _version 5.1_, to switch this functionality on, the `@EnablePublisher` annotation must be provided on some `@Configuration` class.
See <<configuration-enable-integration>> for more information.
The Message will be constructed from the return value of the method invocation and sent to a channel specified by the 'channel' attribute.
To further manage message structure, you can also use a combination of both `@Payload` and `@Header` annotations.
@@ -105,10 +107,24 @@ As with most other annotation-driven features in Spring, you will need to regist
You can instead use namespace support for a more concise configuration:
[source,xml]
----
<int:annotation-config default-publisher-channel="defaultChannel"/>
<int:annotation-config>
<int:enable-publisher default-publisher-channel="defaultChannel"/>
</int:annotation-config>
----
Similar to other Spring annotations (@Component, @Scheduled, etc.), `@Publisher` can also be used as a meta-annotation.
For Java & Annotation Spring configuration, the `@EnablePublisher` annotation must be used:
[source,java]
----
@Configuration
@EnableIntegration
@EnablePublisher("defaultChannel")
public class IntegrationConfiguration {
...
}
----
Similar to other Spring annotations (`@Component`, `@Scheduled`, etc.), `@Publisher` can also be used as a meta-annotation.
That means you can define your own annotations that will be treated in the same way as the `@Publisher` itself.
[source,java]

View File

@@ -51,7 +51,20 @@ Starting with _version 5.0.5_, generated bean names for the components in an `In
See <<java-dsl-flows>> for more information.
==== AMQP Changes
==== Aggregator Changes
An aggregator now expires the group immediately, if the `groupTimeout` is evaluated to a negative value.
Only `null` is considered as a signal do nothing for the current message.
See <<aggregator>> for more information.
==== @Publisher annotation changes
Starting with _version 5.1, the `@Publisher` AOP functionality has to be turned on explicitly via `@EnablePublisher` or via `<int:enable-publisher>` sub-element on the `<int:annotation-config>`.
See <<publisher-annotation>> for more information.
=== AMQP Changes
`ID` and `Timestamp` header mapping changes in the `DefaultAmqpHeaderMapper`.
See the note near the bottom of <<amqp-message-headers>> for more information.
@@ -59,15 +72,8 @@ See the note near the bottom of <<amqp-message-headers>> for more information.
The `contentType` header is no longer incorrectly mapped as an entry in the general headers map.
See <<amqp-content-type>> for more information.
==== JDBC Changes
=== JDBC Changes
A confusing `max-rows-per-poll` property on the JDBC Inbound Channel Adapter and JDBC Outbound Gateway has been deprecated in favor newly introduced `max-rows` property.
See <<jdbc>> for more information.
==== Aggregator Changes
An aggregator now expires the group immediately, if the `groupTimeout` is evaluated to a negative value.
Only `null` is considered as a signal do nothing for the current message.
See <<aggregator>> for more information.