如何使用JAVA DSL配置创建http:inbound-gateway?

时间:2016-07-18 14:21:32

标签: java spring spring-integration

我有以下带有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 个答案:

答案 0 :(得分:1)

从版本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();
}