|
此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring Integration 6.5.1! |
原生映像支持
从版本 6.0 开始,Spring AOT 本机提示支持 GraalVM 将 Spring Integration 应用程序编译为本机映像。
对于最常见的用例,例如使用@Bean方法、带有 lambda 的 Java DSL 配置和@MessagingGateway接口扫描(导入),框架提供相应的反射、代理和序列化提示。
如果配置使用消息传递注释 (@ServiceActivator,@Splitter等等)on POJO 方法,或者 POJO 方法与IntegrationFlowBuilder.handle(Object service, String methodName)API,它们还必须用@Reflective注释,因为它们是由框架反射性调用的。
| 本机映像不支持 XML 配置。 |
如前所述,服务接口与@MessagingGateway注释,当它们被@IntegrationComponentScan或用于@Import注释,由框架处理,相应的代理提示将暴露到 AOT 贡献中。
当使用IntegrationFlow.from(Class<?> serviceInterface)API,必须手动公开为此类接口配置的代理:
@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));
}
}
}
这IntegrationFlow在 AOT 处理阶段不会处理内容。
因此,目标应用程序必须提供一些提示,例如上面提到的网关代理提示。 |
当然,配置只是集成解决方案的一部分。
最重要的部分是通过网络传输数据以及持久存储。
这就是序列化在许多用例中派上用场的地方。
Spring Integration将序列化提示公开到框架内部使用的这些类型的本机映像配置中:String,Number,Long,Date,ArrayList,HashMap,Properties,Hashtable,Exception,UUID,GenericMessage,ErrorMessage,MessageHeaders,AdviceMessage,MutableMessage,MutableMessageHeaders,MessageGroupMetadata,MessageHolder,MessageMetadata,MessageHistory,MessageHistory.Entry,DelayHandler.DelayedMessageWrapper.
对于特定于用户的数据(主要作为消息有效负载存在),必须通过RuntimeHintsRegistrar实现,如上所示,对于网关代理,以及相应的RuntimeHints.serialization().registerType()应用程序接口。
| 建议使用 Spring Boot 使用其各自的构建工具开发本机集成应用程序。 |