【问题标题】:How can I create http:inbound-gateway with JAVA DSL config?如何使用 JAVA DSL 配置创建 http:inbound-gateway?
【发布时间】:2016-07-18 14:21:31
【问题描述】:
我有以下带有 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"
/>
【问题讨论】:
标签:
java
spring
spring-integration
【解决方案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();
}