camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Bettiol <>
Subject Problem with my first aggregate Route (newbie to Camel)
Date Sun, 28 Nov 2010 20:39:34 GMT
Hi guys,

I'm new to apache Camel. It sound really great.

I was trying to build my first application. I got a file with entries of
different type and I want to generate a new file with only a subset of the
lines (in the final version I will have to build up a POJO and send it using

The problem is that when I try to aggregate the lines the output file
contains only the last not filtered row

Thank you for your support :)


Here is the code


public class Test {

 private DefaultCamelContext camel;

 public static void main(String[] args) throws Exception{

 new Test();


 public Test() throws Exception{

 camel = new DefaultCamelContext();

 camel.addRoutes(new RouteBuilder() {

 public void configure() { from(

  .split(body().tokenize("\n"), new
TVCEOrderAggregateStrategy()).filter(newPredicate() {


  public boolean matches(Exchange exchange) {

   String content =exchange.getIn().getBody(String.class);

   if(content.startsWith("vnboltes") || content.startsWith("vnbolcas"))

   return true;

   return true;

   //keep everything for test












   public class TVCEOrderAggregateStrategy implements AggregationStrategy{

     public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {

        if (oldExchange == null) {

            return newExchange;


        String oldBody = oldExchange.getIn().getBody(String.class);

        String newBody = newExchange.getIn().getBody(String.class);

        String concatBody = oldBody.concat(newBody);


        return oldExchange;



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message