Expose more reflection hints (#3951)

* Expose more reflection hints

* Bring back `@Reflective` on `Pausable` - for possible end-user usage
* Add `ReactiveMessageHandler` hint since its method is used reflectively
in the `IntegrationRSocketMessageHandler`
* Add `@Reflective` on the `ServerRSocketMessageHandler.handleConnectionSetup()`
since it is used reflectively for a `registerHandlerMethod()`
* Add `KafkaRuntimeHints` to expose `Pausable` contract on Kafka inbound endpoints
for SpEL invocation via Control Bus
* Document native images support

* Fix language in docs

Co-authored-by: Gary Russell <grussell@vmware.com>

Co-authored-by: Gary Russell <grussell@vmware.com>
This commit is contained in:
Artem Bilan
2022-11-18 11:26:46 -05:00
committed by GitHub
parent 18a87eaf2a
commit 3c40b01915
10 changed files with 136 additions and 2 deletions

View File

@@ -41,6 +41,8 @@ include::./system-management.adoc[]
include::./reactive-streams.adoc[]
include::./native-aot.adoc[]
include::./endpoint-summary.adoc[]
include::./amqp.adoc[]

View File

@@ -28,6 +28,7 @@ Welcome to the Spring Integration reference documentation!
<<./kotlin-dsl.adoc#kotlin-dsl,Kotlin DSL>> :: Details about Kotlin DSL for EIP
<<./system-management.adoc#system-management-chapter,System Management>> :: Message store, control bus, integration graph, metrics, JMX
<<./reactive-streams.adoc#reactive-streams,Reactive Streams Support>> :: Details about Reactive Streams support: message channels, channel adapters etc.
<<./native-aot.adoc#native-images-support,Native Images Support>> :: GraalVM native images and Spring AOT support
[horizontal]
**Integration Endpoints** ::

View File

@@ -0,0 +1,57 @@
[[native-images-support]]
=== Native Images Support
Starting with version 6.0, GraalVM compilation of Spring Integration applications to native images is supported by https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#aot[Spring AOT] native hints.
For most common use cases, such as endpoint definitions with `@Bean` methods, Java DSL configuration with lambdas and `@MessagingGateway` interface scanning (importing), the framework provides respective reflection, proxy and serialization hints.
If configuration uses messaging annotations (`@ServiceActivator`, `@Splitter` etc.) on POJO methods, or POJO methods are used with the `IntegrationFlowBuilder.handle(Object service, String methodName)` API, they have to be also marked with a `@Reflective` annotation since they are invoked by the framework reflectively.
IMPORTANT: XML configuration is not supported for native images.
As stated before, service interfaces with the `@MessagingGateway` annotation, when they are scanned by the `@IntegrationComponentScan` or used in an `@Import` annotation, are processed by the framework and the respective proxy hint is exposed into the AOT contribution.
When gateways are declared using the `IntegrationFlow.from(Class<?> serviceInterface)` API, the proxy configured for such interfaces have to be exposed manually:
====
[source,java]
----
@Configuration
@EnableIntegration
@ImportRuntimeHints(GatewayRuntimeHints.class)
public class IntegrationConfiguration {
@Bean
IntegrationFlow someFlow() {
return IntegrationFlow.from(SomeGateway)
// ...
.get();
}
public interface SomeGateway {
void doSomething(Object payload);
}
private static class GatewayRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.proxies().registerJdkProxy(
AopProxyUtils.completeJdkProxyInterfaces(SomeGateway));
}
}
}
----
====
NOTE: The `IntegrationFlow` content is not processed during the AOT processing phase.
Therefore, some hints, such as the one mentioned above for a gateway proxy, must be provided by the target application.
Of course, configuration is just a piece of an integration solution.
The most important part is data transferring over the network as well as persistent storage.
That's where serialization comes handy for many use-cases.
Spring Integration exposes serialization hints into a native image configuration for these types used by the framework internally: `String`, `Number`, `Long`, `Date`, `ArrayList`, `HashMap`, `Properties`, `Hashtable`, `Exception`, `UUID`, `GenericMessage`, `ErrorMessage`, `MessageHeaders`, `AdviceMessage`, `MutableMessage`, `MutableMessageHeaders`, `MessageGroupMetadata`, `MessageHolder`, `MessageMetadata`, `MessageHistory`, `MessageHistory.Entry`, `DelayHandler.DelayedMessageWrapper`.
For user specific data, mostly present as a message payload, the serialization hint must be exposed manually via a `RuntimeHintsRegistrar` implementation, as is shown above for a gateway proxy, and the respective `RuntimeHints.serialization().registerType()` API.
NOTE: It is recommended that native integration applications are developed with Spring Boot, using its respective build tools.

View File

@@ -52,7 +52,7 @@ The Java DSL (see `org.springframework.integration.smb.dsl.Smb` factory) also ha
An `SmbStreamingMessageSource` and `SmbOutboundGateway` implementation are introduced.
See <<./smb.adoc#smb,SMB Support>> for more information.
[[x6.0-jdbc]]
[[x6.0-postgres]]
==== PostgreSQL Push Notification
A `PostgresSubscribableChannel` allows to receive push notifications via `PostgresChannelMessageTableSubscriber` upon new messages add to the `JdbcChannelMessageStore`.
@@ -98,6 +98,12 @@ Kotlin Coroutines support has been introduced to the framework.
See <<./kotlin-functions.adoc#kotlin-coroutines,Kotlin Coroutines>> for more information.
[[x6.0-aot]]
==== Native Images
Support for creating GraalVM native images is provided.
See <<./native-aot.adoc#native-images-support,Native Images Support>> for more information.
[[x6.0-general]]
=== General Changes
@@ -160,6 +166,7 @@ The `spring-integration-gemfire` module has been removed altogether since there
The `#cookies` variable for expression evaluation context, exposed in the `HttpRequestHandlingEndpointSupport`, is now a `MultiValueMap` to carry all the values for cookies set by the client.
See <<./http.adoc#http,HTTP Support>> for more information.
[[x6.0-kafka]]
=== Apache Kafka Changes
When providing a `RetryTemplate` on the inbound gateway or message-driven channel adapter, if an `errorChannel` is also provided, an `ErrorMessageSendingRecoverer` is automatically configured.
@@ -168,24 +175,28 @@ In addition, the new `KafkaErrorMessageSendingRecoverer` is provided; this can b
See <<./kafka.adoc#kafka,Spring for Apache Kafka Support>> for more information.
[[x6.0-jdbc]]
=== JDBC Changes
The `DefaultLockRepository` can now be supplied with a `PlatformTransactionManager` instead of relying on the primary bean from the application context.
See <<./jdbc.adoc#jdbc-lock-registry,JDBC Lock Registry>> for more information.
[[x6.0-tcp]]
=== TCP/IP Changes
The `lookupHost` property of the `AbstractConnectionFactory` and `DatagramPacketMessageMapper` is now set to `false` by default to avoid delays in the environments where DNS is not configured.
See <<./ip.adoc#ip,TCP and UDP Support>> for more information.
[[x6.0-jms]]
=== JMS Changes
The `JmsOutboundGateway` now creates a `TemporaryTopic` instead of `TemporaryQueue` if `replyPubSubDomain` option is set to `true`.
See <<./jms.adoc#jms,JMS Support>> for more information.
[[x6.0-security]]
=== Security Changes
The `ChannelSecurityInterceptor` and its annotation `@SecuredChannel` and XML `<secured-channels>` configurations have been deprecated in favor of `AuthorizationChannelInterceptor`.