Skip to content

Conversation

artembilan
Copy link
Member

Fixes #3923

Currently, the @MessagingGateway interfaces can be scanned or created explicitly as @Bean definition for AnnotationGatewayProxyFactoryBean

  • Implement a GatewayProxyBeanDefinitionPostProcessor which is invoked before instantiation attempt on the BeanDefinition
  • Verify @Import for @MessagingGateway interface in the GatewayInterfaceTests

Fixes spring-projects#3923

Currently, the `@MessagingGateway` interfaces can be scanned or created
explicitly as `@Bean` definition for `AnnotationGatewayProxyFactoryBean`

* Implement a `GatewayProxyBeanDefinitionPostProcessor` which is invoked
before instantiation attempt on the `BeanDefinition`
* Verify `@Import` for `@MessagingGateway` interface in the `GatewayInterfaceTests`
@artembilan
Copy link
Member Author

With this InstantiationAwareBeanPostProcessor feature it looks like we don't need a MessagingGatewayRegistrar to be used for a @IntegrationComponentScan: we just simply can rely on a standard AnnotatedBeanDefinition registration against an interface and and delegate to this post-processor to let the AnnotationGatewayProxyFactoryBean to do the trick with annotation attributes processing.
But this is going to be a different story already after merging this one and naming PR.

@chrylis
Copy link

chrylis commented Oct 28, 2022

Very interesting! Will this functionality make it back to 5.x, or will it be 6.x only? (The re-baseline from Java 11 to Java 17 will be a hassle if required.)

@artembilan
Copy link
Member Author

Well, I'm a bit reluctant to introduce any breaking changes into maintenance versions.
More over this is not a bug, but a new feature: we never advertised an @Import for @MessagingGateway.
As a workaround it is simply enough to add that GatewayProxyInstantiationPostProcessor as a static bean into your own configuration.

@garyrussell garyrussell merged commit 511cb76 into spring-projects:main Oct 31, 2022
@chrylis
Copy link

chrylis commented Nov 1, 2022

Thanks for this! We'll be stuck on 5.x for a while, but I can continue using the proof-of-concept I have until we overhaul to Java 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support @Importing gateway interfaces
3 participants