in aggregate-dist/src/main/java/org/apache/camel/example/Application.java [214:228]
public void run(Exchange exchange) {
CamelContext context = exchange.getContext();
try (ProducerTemplate template = context.createProducerTemplate()) {
template.setThreadedAsyncMode(false);
Endpoint endpoint = context.getEndpoint("direct:aggregator");
Integer item;
while ((item = inputQueue.poll()) != null) {
template.sendBodyAndHeader(endpoint, item, CID_HEADER, correlationId);
}
template.stop();
} catch (IOException e) {
LOG.error("Error during execution");
}
latch.countDown();
}