GH-2708: Make messaging annotations as repeatable

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

There are some requests to use the same service method for different input channels

* Make all the messaging annotations as `@Repeatable` with their
respective container annotations
* Modify `MessagingAnnotationPostProcessor` logic to deal with the mentioned repeatable
requirements
This commit is contained in:
Artem Bilan
2022-04-18 17:07:39 -04:00
committed by Gary Russell
parent f54d4b3d75
commit 97ab596841
24 changed files with 454 additions and 40 deletions

View File

@@ -301,7 +301,7 @@ public class ThingService {
----
====
You can also use the `@Headers` annotation to provide all of the message headers as a `Map`, as the following example shows:
You can also use the `@Headers` annotation to provide all the message headers as a `Map`, as the following example shows:
====
[source,java]
@@ -354,7 +354,7 @@ The `MessageHandler` instances (`MessageSource` instances) are also eligible to
Starting with version 4.0, all messaging annotations provide `SmartLifecycle` options (`autoStartup` and `phase`) to allow endpoint lifecycle control on application context initialization.
They default to `true` and `0`, respectively.
To change the state of an endpoint (such as ` start()` or `stop()`), you can obtain a reference to the endpoint bean by using the `BeanFactory` (or autowiring) and invoke the methods.
To change the state of an endpoint (such as `start()` or `stop()`), you can obtain a reference to the endpoint bean by using the `BeanFactory` (or autowiring) and invoke the methods.
Alternatively, you can send a command message to the `Control Bus` (see <<./control-bus.adoc#control-bus,Control Bus>>).
For these purposes, you should use the `beanName` mentioned earlier in the preceding paragraph.
@@ -380,6 +380,18 @@ Thing1 dependsOnSPCA(@Qualifier("someInboundAdapter") @Lazy SourcePollingChannel
====
=====
Starting with version 6.0, all the messaging annotations are `@Repeatable` now, so several of the same type can be declared on the same service method with the meaning to create as many endpoints as those annotations are repeated:
====
[source, java]
----
@Transformer(inputChannel = "inputChannel1", outputChannel = "outputChannel1")
@Transformer(inputChannel = "inputChannel2", outputChannel = "outputChannel2")
public String transform(String input) {
return input.toUpperCase();
}
----
====
[[configuration-using-poller-annotation]]
==== Using the `@Poller` Annotation

View File

@@ -26,8 +26,10 @@ See <<./graphql.adoc#graphql,GraphQL Support>> for more information.
[[x6.0-general]]
=== General Changes
The messaging annotations don't require a poller attribute as an array of @Poller any more.
See <<./configuration.adoc#configuration-using-poller-annotation,Using the @Poller Annotation>> for more information.
The messaging annotations are now `@Repeatable` and the same type can be declared several times on the same service method.
The messaging annotations don't require a `poller` attribute as an array of `@Poller` anymore.
See <<./configuration.adoc#annotations,Annotation Support>> for more information.
[[x6.0-http]]
=== HTTP Changes