I am creating zip files in Camel using the ZipAggregationStrategy
and need to set the output filename based on a custom property set in an invoking exchange. However, the exchange that I receive after my zip aggregation contains none of my properties.
My general flow is:
- Processor which sets custom properties on the exchange (dynamic, based off database query)
- Bean which produces
List
of zip file contents - Camel
aggregator
usingZipAggregationStrategy
, based off the example in the Camel documentation.
After step 3., I wish to dynamically name the zip based off properties I set on the exchange in step 1., but the exchange only contains Camel properties (CamelFileExchangeFile
with the path to the zip file, etc.) because a new exchange is being created in aggregate()
:
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
File zipFile;
Exchange answer = oldExchange;
// ...
DefaultEndpoint endpoint = (DefaultEndpoint) newExchange.getFromEndpoint();
answer = endpoint.createExchange();
answer.addOnCompletion(new DeleteZipFileOnCompletion(zipFile));
// ...
genericFile.bindToExchange(answer);
// ...
return answer;
}