此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1! |
此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1! |
在Spring Integration中抽象为一等公民时,集成流的组成总是被假定的。
流中任何端点的输入通道都可用于从任何其他端点发送消息,而不仅仅是从将此通道作为输出的端点发送消息。
此外,有了协定、Content Enricher 组件、复合端点(如 ,现在有了 bean)(例如),在较短的可重用部件之间分配业务逻辑就足够简单了。
最终的作文所需要的只是关于发送到或接收到或接收的知识。MessageChannel
@MessagingGateway
<chain>
IntegrationFlow
IntegrationFlowAdapter
MessageChannel
从版本开始,为了从最终用户那里抽象更多并隐藏实现细节,引入了工厂方法,以允许从现有流程的输出启动电流:5.5.4
MessageChannel
IntegrationFlow
from(IntegrationFlow)
IntegrationFlow
@Bean
IntegrationFlow templateSourceFlow() {
return IntegrationFlow.fromSupplier(() -> "test data")
.channel("sourceChannel")
.get();
}
@Bean
IntegrationFlow compositionMainFlow(IntegrationFlow templateSourceFlow) {
return IntegrationFlow.from(templateSourceFlow)
.<String, String>transform(String::toUpperCase)
.channel(c -> c.queue("compositionMainFlowResult"))
.get();
}
另一方面,添加了一个终端运算符,以在其他一些流的输入通道上继续电流:IntegrationFlowDefinition
to(IntegrationFlow)
@Bean
IntegrationFlow mainFlow(IntegrationFlow otherFlow) {
return f -> f
.<String, String>transform(String::toUpperCase)
.to(otherFlow);
}
@Bean
IntegrationFlow otherFlow() {
return f -> f
.<String, String>transform(p -> p + " from other flow")
.channel(c -> c.queue("otherFlowResultChannel"));
}
使用现有的 EIP 方法可以简单地实现流程中间的组合。
通过这种方式,我们可以通过从更简单、可重用的逻辑块组成流来构建任何复杂的流。
例如,您可以添加一个 Bean 库作为依赖项,只需将其配置类导入到最终项目中并为您的定义自动连接就足够了。gateway(IntegrationFlow)
IntegrationFlow
IntegrationFlow