I'm new to spring integration using DSL and have difficulty in extracting payload within http handler, to dynamically construct the URI. The integration flow below is triggered by AccountList Gateway and it adds the customer id value to the message on invocation on channel "accountListFlow.input". And the payload contains just '123766123' and thats the customer id passed.
Thereafter the message is enriched with header and then passed downstream to handler.
I require customer id to be extracted in the handler to dynamically construct the URI. I tried generic handler and cast payload to String but fails saying can't cast lambda object. Any help here how to extract the payload as a whole which is the customer id when constructing the URI, please ?
@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"));
}