我有以下具有XML配置的HTTP入站网关。如何在Spring Integration中使用JAVA 8 DSL配置创建相同的内容?

<int-http:inbound-gateway id="testGateWay"
    supported-methods="GET"
    request-channel="testRequestChannel"
    reply-channel="testResponseChannel"
    path="/services/normalization"
/>

最佳答案

从版本1.1开始,Spring Integration Java DSL提供了HTTP名称空间工厂。因此,您可以按照HttpTests中的现有示例进行操作:

@Bean
public IntegrationFlow httpInternalServiceFlow() {
    return IntegrationFlows
            .from(Http.inboundGateway("/service/internal")
                    .requestMapping(r -> r.params("name"))
                    .payloadExpression("#requestParams.name"))
            .channel(transformSecuredChannel())
            .<List<String>, String>transform(p -> p.get(0).toUpperCase())
            .get();
}

08-06 13:36