Hi, 
    I am using an aggregator to add ";" inbetween the message that is
tokenized by "\n". But the end result does not show ';' at the end every
line.. what am I doing wrong..

Here is route config...
                <route>
                        <from uri="file:{{splitInBox}}" />
                        <log message="spliting the message using tokenizer(\n) 
from splitInBox to
splitOutBox. filename ${header.CamelFileName}" />
                        <split streaming="true" 
strategyRef="splitNewLineStrategy" >
                                <tokenize token="\n"/>
                                <to uri="file:{{splitOutBox}}" />
                        </split>
                        <log message="Split completed" />
                        
                </route>


Here is the AggregationStrategy implemention.

public class SplitLineStrategy implements AggregationStrategy {

        private static Logger log = Logger.getLogger(SplitLineStrategy.class);
        
    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
        // put order together in old exchange by adding the order from new
exchange

        if (oldExchange == null) {
            // the first time we aggregate we only have the new exchange,
            // so we just return it
            return newExchange;
        }

        String orders = oldExchange.getIn().getBody(String.class) + "\n";
        String newLine = newExchange.getIn().getBody(String.class);

        log.debug("Aggregate old orders: " + orders);
        log.debug("Aggregate new order: " + newLine);

        // put orders together separating by semi colon
        orders = orders + ";" +newLine;
        // put combined order back on old to preserve it
        oldExchange.getIn().setBody(orders);
        
        log.info(" aggregator returns " + orders);
        
        // return old as this is the one that has all the orders gathered
until now
        return oldExchange;
    }
}


Any help will be great.. 

Thanks a lot.



--
View this message in context: 
http://camel.465427.n5.nabble.com/AggregationStrategy-not-writing-to-end-result-tp5728317.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to