Apache Camel Route:
from("file:/tmp/test?include=.*.csv").process(new Processor() {
public void process(Exchange exchange) throws Exception {
// set output file name
exchange.setProperty("outputFile",
exchange.getIn().getHeader(Exchange.FILE_NAME, String.class) + ".tmp." +
exchange.getExchangeId());
}
}).onCompletion().split().tokenize("\n", 100).process(new
RequestProcessor()).to("direct:response").end().process(new Processor() {
public void process(Exchange exchange) throws Exception {
final String outputFile = exchange.getProperty("outputFile",
String.class);
// add new rout to encrypt
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file:/tmp/test/output?fileName=" +
outputFile).marshal().pgp(keyFileName,
keyUserid).to("file:/tmp/test/output?fileName=" + outputFile + ".pgp");
}
});
context.start();
Thread.sleep(5000);
context.stop();
}
});
from("direct:response").to("file:/tmp/test/output?fileName=${header.outputFile}&fileExist=Append");
Above route is processing big file splitting into chunk (for batch
processing) and generate output file with results. once generated the output
file I need to encrypt. So I added NEW route inside a processor on
onCompletion file split/process route. It works but I feel it is not a good
design (since involve TWO context and need context shutdown explicitly).
Can you anyone suggest me the proper way to fire the encryption route.
--
View this message in context:
http://camel.465427.n5.nabble.com/Is-apache-camel-supports-nested-route-tp5748061.html
Sent from the Camel - Users mailing list archive at Nabble.com.