GH-3920: Support @Primary on @MessagingGateway (#3924)

* GH-3920: Support @Primary on @MessagingGateway

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

Any Spring `@Component` can also be marked with a `@Primary`.
The `@MessagingGateway` for proxying interfaces has no difference with
a standard `@Component` definition

* Modify `MessagingGatewayRegistrar` to obtain a `@Primary` marked
from the `importingClassMetadata` and pass it to the target `BeanDefinition`
* Verify the `@Primary` effect in the `GatewayInterfaceTests`
* Document this improvement

* * Fix Checkstyle violations
This commit is contained in:
Artem Bilan
2022-10-24 13:08:15 -04:00
committed by GitHub
parent 1c4a474f53
commit d9545c11a5
4 changed files with 64 additions and 4 deletions

View File

@@ -317,6 +317,8 @@ See also <<./configuration.adoc#annotations,Annotation Support>>.
Along with the `@MessagingGateway` annotation you can mark a service interface with the `@Profile` annotation to avoid the bean creation, if such a profile is not active.
Starting with version 6.0, an interface with the `@MessagingGateway` can also be marked with a `@Primary` annotation for respective configuration logic as its possible with any Spring `@Component` definition.
NOTE: If you have no XML configuration, the `@EnableIntegration` annotation is required on at least one `@Configuration` class.
See <<./overview.adoc#configuration-enable-integration,Configuration and `@EnableIntegration`>> for more information.

View File

@@ -85,6 +85,7 @@ See <<./cassandra.adoc#cassandra,Apache Cassandra Support>> for more information
Kotlin Coroutines support has been introduced to the framework.
See <<./kotlin-functions.adoc#kotlin-coroutines,Kotlin Coroutines>> for more information.
[[x6.0-general]]
=== General Changes
@@ -109,9 +110,11 @@ See <<./dsl.adoc#java-dsl,Java DSL>> for more information.
The `org.springframework.util.concurrent.ListenableFuture` has been deprecated starting with Spring Framework `6.0`.
All Spring Integration async API has been migrated to the `CompletableFuture`.
Also Messaging Gateway interface method can now return `Future<Void>` and `Mono<Void>` with a proper asynchronous execution of the downstream flow.
The Messaging Gateway interface method can now return `Future<Void>` and `Mono<Void>` with a proper asynchronous execution of the downstream flow.
See <<./gateway.adoc#async-gateway, Asynchronous Gateway>> for more information.
Alongside with a `@MessagingGateway` annotation the interface can also be marked with a `@Primary`.
See <<./gateway.adoc#gateway, Messaging Gateway>> for more information.
The `integrationGlobalProperties` bean is now declared by the framework as an instance of `org.springframework.integration.context.IntegrationProperties` instead of the previously deprecated `java.util.Properties`.