I have used the below spring configuration to combine results from publish subscribe channel using aggregator. But the aggregator populates response only from the first service activator in the publish subscribe channel and it does not wait for the response from the other service activators. How should i modify my configuration to make the aggregator wait for response from all 4 service activators?
<int:bridge id="ValidationsBridge" input-channel="RequestChannel" output-channel="bridgeOutputChannel"></int:bridge>
<int:publish-subscribe-channel id="bridgeOutputChannel" apply-sequence="true" />
<int:service-activator input-channel="bridgeOutputChannel" output-channel="aggregatorInput"
method="populateResponse1" ref="WebServiceImpl" >
</int:service-activator>
<int:service-activator input-channel="bridgeOutputChannel" method="populateResponse2" ref="WebServiceImpl" output-channel="aggregatorInput"
>
</int:service-activator>
<int:service-activator input-channel="bridgeOutputChannel" method="populateResponse3" ref="WebServiceImpl" output-channel="aggregatorInput"
>
</int:service-activator>
<int:service-activator input-channel="bridgeOutputChannel" method="populateResponse4" ref="WebServiceImpl" output-channel="aggregatorInput"
>
</int:service-activator>
<task:executor id="executor" pool-size="4" keep-alive="20"/>
<int:aggregator input-channel="aggregatorInput" output-channel="aggregatorOutput" ref="vehicleAggregator" method="populateResponse"
></int:aggregator>
<int:service-activator id="processorServiceActivator" input-channel="aggregatorOutput" ref="Processor" method="mapResponse" output-channel="ResponseChannel"/>
<int:channel id="bridgeOutputChannel" />
<int:channel id="aggregatorInput" />
<int:channel id="aggregatorOutput" />
</beans>
Below is a snippet from my aggregator
public Message<?> populateResponse(Collection<Message<?>> message){
MessageBuilder<?> MsgBuilder =null;
MsgBuilder=MessageBuilder.withPayload(message.iterator().next().getPayload());
for (Message<?> message2 : message) {
if(null!=message2.getHeaders().get(Constants.RESPONSE1)){
MsgBuilder.setHeader(Constants.RESPONSE1, message2.getHeaders().get(Constants.RESPONSE1));
}
if(null!=message2.getHeaders().get(Constants.RESPONSE2)){
MsgBuilder.setHeader(Constants.RESPONSE2, message2.getHeaders().get(Constants.RESPONSE2));
}
}
return (Message<?>) MsgBuilder.build();
}