【发布时间】:2017-05-11 17:22:24
【问题描述】:
我是使用 DSL 进行 Spring 集成的新手,在 在 http 处理程序中提取有效负载,以动态构造 URI。 下面的集成流程由 AccountList Gateway 触发,它添加了 在通道上调用消息的客户 ID 值 “accountListFlow.input”。有效载荷仅包含“123766123” 这就是传递的客户 ID。
此后消息用标题丰富,然后传递 下游到处理程序。
我需要在处理程序中提取客户 ID 以动态构建 URI。我尝试了通用处理程序并将有效负载转换为字符串,但未能说不能转换 lambda 对象。任何帮助在这里如何 提取作为一个整体的有效载荷,这是客户ID 请构造 URI?
@MessagingGateway
public interface AccountList {
@Gateway(requestChannel = "accountListFlow.input")
List<String> accountListFlow(String customerId);
}
@Bean
public IntegrationFlow accountListFlow() {
return flow -> flow.publishSubscribeChannel(s -> s.applySequence(true)
.subscribe(f -> f
.enrichHeaders(h -> h.header("X-CUST-IP-Id","145.26.54.24"))
.handle((o, map) ->
Http.outboundGateway("http://get-customers-product-holdings-gb-hbeu-v3-v3-cert.cf.wgdc-drn-01.cloud.uk/api/customers/"+(String)o+"/product-holdings?categoryCode=cc,cbs,sd")
.httpMethod(HttpMethod.GET)
.mappedRequestHeaders("X-CUST-IP-Id")
.expectedResponseType(String.class)
.extractPayload(true)).channel("aggregateAccount.input"));
}
【问题讨论】:
标签: lambda spring-integration dsl