1ST QUESTION:
I'm not able to really understand the difference between enrich()
and pollEnrich()
. Maybe the terms Camel uses are not so great.
I read here: http://camel.apache.org/content-enricher.html
Content enrichment using the enrich DSL element
Camel comes with two flavors of content enricher in the DSL
- enrich
- pollEnrich
enrich uses a Producer to obtain the additional data. It is usually used for Request Reply messaging, for instance to invoke an external web service. pollEnrich on the other hand uses a Polling Consumer to obtain the additional data. It is usually used for Event Message messaging, for instance to read a file or download a FTP file.
I don't understand what the difference is. They both seem to get the additional data (Web service response, FTP file) by consuming it. So why do they say getting the Web service response is done by a "producer"?
2ND QUESTION:
In the "Camel in action" book p. 72 they say:
Enrich and pollEnrich can’t access information in the current exchange
Neither enrich nor pollEnrich can leverage any information from the current exchange. This means, for example, that you can’t store a filename header on the exchange for pollEnrich to use to select a particular file. This may change in the future if the Camel team can find a solution.
However they give a code example similar to the following, for implementing an aggregation strategy:
public class ExampleAggregationStrategy implements AggregationStrategy {
public Exchange aggregate(Exchange original, Exchange resource) {
Object originalBody = original.getIn().getBody();
Object resourceResponse = resource.getIn().getBody();
Object mergeResult = ... // combine original body and resource response
if (original.getPattern().isOutCapable()) {
original.getOut().setBody(mergeResult);
} else {
original.getIn().setBody(mergeResult);
}
return original;
}
}
In this example I see that they have access to the Exchange original
, is it not the "current exchange"? If not, then what exchange does the "original exchange" represent?
And what do they mean by the "current exchange"?