camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abkrt <tharang...@gmail.com>
Subject Re: Is apache-camel supports nested route
Date Mon, 03 Mar 2014 08:01:45 GMT
Thank you very Robert Simmons for you valuable reply.

Still I have one issue, with above solution it will create multiple files
based on split size. How can I avoid this and encrypt into single file. For
that I had used "onCompletion" mechanism.

I enhanced the initial design with your feedback. But the encryption route
is getting the original file as the input, are there any mechanism to
redirect the generated output file as the input for encryption. 
       
from("file:/home/rt40207/camel_test/gcb/request?include=.*.csv&noop=true")
            .setProperty("outputFile",
simple("${header.CamelFileName}.${exchangeId}"))
            .onCompletion()
                .split().tokenize("\n", 5)
                .log("splitted body processed & written to file
${property.outputFile}.csv")
                .process(new RequestProcessor())
               
.to("file:/home/rt40207/camel_test/gcb/temp?fileName=${property.outputFile}.csv&fileExist=Append")
            .end()
            .marshal().pgp(keyFileName, keyUserid)
            .log("PGP encrypted written to file ${property.outputFile}.pgp")
           
.to("file:/home/rt40207/camel_test/gcb/response?fileName=${property.outputFile}.pgp");


Note:
RequestProcessor:
public class RequestProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
    String body = exchange.getIn().getBody(String.class); 
    String[] split = body.split("\n");
    StringBuilder output = new StringBuilder();

    // TODO begin trx

    for (String input : split) {
        if (input.startsWith("InputHeader")) {
            output.append("OutputHeader").append(input.substring(11) + ",");
        } else {
            // TODO process here
            output.append("\n").append(input).append(",DONE");
        }
    }

    // TODO commit trx

    DefaultMessage message = new DefaultMessage();
    message.setBody(output.toString());
    message.setHeader(Exchange.FILE_NAME, "output" +
exchange.getIn().getHeader(Exchange.FILE_NAME, String.class).substring(5));

    exchange.setOut(message);
}



--
View this message in context: http://camel.465427.n5.nabble.com/Is-apache-camel-supports-nested-route-tp5748061p5748229.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message