对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

所有 EIP 方法都有一个变体,该变体应用 lambda 参数来提供实例选项:、、 和其他。 它们中的每一个都有通用参数,因此它允许您在上下文中配置端点甚至端点,如以下示例所示:IntegrationFlowBuilderAbstractEndpointSmartLifecyclePollerMetadatarequest-handler-advice-chainMessageHandlerSpring中文文档

@Bean
public IntegrationFlow flow2() {
    return IntegrationFlow.from(this.inputChannel)
                .transformWith(t -> t
                              .transformer(new PayloadSerializingTransformer())
                              .autoStartup(false)
                              .id("payloadSerializingTransformer"))
                .transformWith(t -> t
                              .transformer((Integer p) -> p * 2)
                              .advice(expressionAdvice()))
                .get();
}

此外,还提供了一种方法,允许您使用给定的 Bean 名称(而不是生成的 Bean 名称)注册终端节点 Bean。EndpointSpecid()Spring中文文档

如果 被引用为 bean,那么如果 DSL 定义中存在该方法,则任何现有配置都将被覆盖:MessageHandleradviceChain.advice()Spring中文文档

@Bean
public TcpOutboundGateway tcpOut() {
    TcpOutboundGateway gateway = new TcpOutboundGateway();
    gateway.setConnectionFactory(cf());
    gateway.setAdviceChain(Collections.singletonList(fooAdvice()));
    return gateway;
}

@Bean
public IntegrationFlow clientTcpFlow() {
    return f -> f
        .handle(tcpOut(), e -> e.advice(testAdvice()))
        .transform(Transformers.objectToString());
}

它们不会被合并,在这种情况下只使用 bean。testAdvice()Spring中文文档