可以从提供组件的服务接口启动,如以下示例所示:IntegrationFlowGatewayProxyFactoryBeanSpring中文文档

public interface ControlBusGateway {

    void send(String command);
}

...

@Bean
public IntegrationFlow controlBusFlow() {
    return IntegrationFlow.from(ControlBusGateway.class)
            .controlBus()
            .get();
}

接口方法的所有代理都随通道一起提供,用于将消息发送到 中的下一个集成组件。 您可以使用注释标记服务接口,并使用注释标记方法。 然而,该 被忽略并被 覆盖为 . 中的下一个组件的内部通道。 否则,使用 创建此类配置是没有意义的。IntegrationFlow@MessagingGateway@GatewayrequestChannelIntegrationFlowIntegrationFlowSpring中文文档

缺省情况下,a 获取约定的 Bean 名称,例如 . 可以使用属性或重载的工厂方法更改该 ID。 此外,接口上注释中的所有属性都将应用于目标。 当注释配置不适用时,变体可用于为目标代理提供适当的选项。 此 DSL 方法从版本 5.2 开始可用。GatewayProxyFactoryBean[FLOW_BEAN_NAME.gateway]@MessagingGateway.name()IntegrationFlow.from(Class<?> serviceInterface, Consumer<GatewayProxySpec> endpointConfigurer)@MessagingGatewayGatewayProxyFactoryBeanConsumer<GatewayProxySpec>Spring中文文档

使用 Java 8,您甚至可以创建具有接口的集成网关,如以下示例所示:java.util.functionSpring中文文档

@Bean
public IntegrationFlow errorRecovererFlow() {
    return IntegrationFlow.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction"))
            .<Object>handle((p, h) -> {
                throw new RuntimeException("intentional");
            }, e -> e.advice(retryAdvice()))
            .get();
}

可以按如下方式使用:errorRecovererFlowSpring中文文档

@Autowired
@Qualifier("errorRecovererFunction")
private Function<String, String> errorRecovererFlowGateway;