In my use case I need to make 2 REST calls to fetch a list of items based on departmentId. I need to merge the 2 lists and process them.
I am using the scatterGather pattern, i can see that the fetchRoles & fetchGroups are being called but i dont see "Aggregated List:" is printed at the end. Can some one help me what is wrong in the code
@Bean
public IntegrationFlow processDomainFileFlow() {
return IntegrationFlows
.from("receiverChannel")
.scatterGather(scatterer -> scatterer
.applySequence(true)
.recipientFlow(fetchRoles())
.recipientFlow(fetchGroups()))
.log(INFO, CATEGORY, m -> "Aggregated List: " + m.getPayload())
.get();
}
@Bean
public IntegrationFlow fetchRoles() {
return IntegrationFlows.from("fetch.roles")
.handle(outboundGateway( someServiceUrl + "/{departmentId}/roles")
.uriVariable("departmentId", m -> m.getHeaders().get("departmentId"))
.httpMethod(HttpMethod.GET)
.expectedResponseType(Item[].class))
.get();
}
@Bean
public IntegrationFlow fetchGroups() {
return IntegrationFlows.from("fetch.groups")
.handle(outboundGateway(someServiceUrl + "/{departmentId}/groups")
.uriVariable("departmentId", m -> m.getHeaders().get("departmentId"))
.httpMethod(HttpMethod.GET)
.expectedResponseType(Item[].class))
.get();
}
>handle((p, h) -> p.stream().flatMap(m -> Arrays.asList(m).stream()).collect((Collectors.toList())))` in order to merge the 2 responses.
– nagendra Oct 18 '18 at 13:23