I am very sorry for not understanding this properly.
Please accept my apologies if am wasting your time.

I am totally missing something here.
Below is the change I had made (Hopeing that this is what you meant by
saying Mutate the old exchange).

I am using StringBuilder so that the process os faster and also helps not
creating many String objects.

1. when I use String.class all works fine until am running out of heapspace.
2. If I use StringBuilder, I get the following nullPointer.
3. Looks like there is no converter type to conver from String to
StringBuilder.


2012-04-30 10:34:38,087 INFO  [Camel (camel-1) thread #2 -
seda://streamQueue] ipdr.GlobalAggrStratergy -  is oldExchange null:
Exchange[null] AND is newExchange null: Exchange[null]
2012-04-30 10:34:38,087 INFO  [Camel (camel-1) thread #2 -
seda://streamQueue] ipdr.GlobalAggrStratergy - Aggregate old orders: null
2012-04-30 10:34:38,087 INFO  [Camel (camel-1) thread #2 -
seda://streamQueue] ipdr.GlobalAggrStratergy - Aggregate new order: null
2012-04-30 10:34:38,087 ERROR [Camel (camel-1) thread #2 -
seda://streamQueue] ipdr.GlobalAggrStratergy - Error aggregating
java.lang.NullPointerException
        at
com.vzw.fp.ipdr.GlobalAggrStratergy.aggregate(GlobalAggrStratergy.java:26)



        @Override
        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
                try{
                        log.info(" is oldExchange null: "+oldExchange+" AND is 
newExchange null:
"+newExchange);
                if (oldExchange == null) {
                        return newExchange;
                } else { 
                    log.info("Aggregate old orders: " +
oldExchange.getIn().getBody(StringBuilder.class));
                    log.info("Aggregate new order: " +
newExchange.getIn().getBody(StringBuilder.class));
                        oldExchange.getIn().setBody(
                                        
oldExchange.getIn().getBody(StringBuilder.class).
                                        
append(newExchange.getIn().getBody(StringBuilder.class)+"\n")); 
                        counter++;
                }
                }catch(Exception ex){
                        log.error("Error aggregating", ex);
                }
                oldExchange.setProperty(Exchange.CONTENT_LENGTH, counter);
                if(counter >= 50000)
                        counter = 0;
                oldExchange.getIn().setHeader(Exchange.FILE_NAME_ONLY,
newExchange.getProperty(Exchange.FILE_NAME_ONLY));
        return oldExchange;
        }

--
View this message in context: 
http://camel.465427.n5.nabble.com/Java-heap-space-issue-with-Aggregation-tp5670608p5676110.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to