Hello. 
   
    i am trying to use the aggregator pattern in a route
    and i get this error: 
    "Cannot find class
[org.apache.camel.processor.aggregate.AggregationStrategy]"
    i also added camel-core dependency in pom.xml :

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>2.6.0</version>
        </dependency>

    this is an example implementation of the aggregator strategy that i use

    package de.edigrid.util.servicemix;

import org.apache.log4j.Logger;
import org.apache.camel.Exchange;
import org.apache.camel.processor.aggregate.AggregationStrategy;
import org.springframework.stereotype.Component;

@Component
public class MyAggregationStrategy implements AggregationStrategy {

    Logger logger = Logger.getLogger(MyAggregationStrategy.class.getName());

    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
        if (oldExchange == null) {
            return newExchange;
        }
        String body1 = oldExchange.getIn().getBody(String.class);
        String body2 = newExchange.getIn().getBody(String.class);

        oldExchange.getIn().setBody(body1 + body2);

        logger.info("Aggregation current state for "+
oldExchange.getIn().getHeader("CamelFileName") +": "+ oldExchange.getIn());
        return oldExchange;
    }
}

    the service-bundle config:

<bean id="aggregatorStrategy"
class="de.edigrid.util.servicemix.MyAggregationStrategy" autowire="byName"/>
        <osgi:service id="aggregatorStrategyService" ref="aggregatorStrategy"
interface="org.apache.camel.processor.aggregate.AggregationStrategy" />

    this is the route:

<beans ...>
  <classpath>
    <library>osgi:org.springframework.osgi.core</library>
    <library>osgi:org.milyn.smooks.osgi</library>
  </classpath>
  ...
  <osgi:reference id="aggregatorStrategyService"
interface="org.apache.camel.processor.aggregate.AggregationStrategy"
bean-name="aggregatorStrategy"/>
  
  <camelContext xmlns="http://camel.apache.org/schema/spring";
id="camelContext">    
    <route id="TEST">
      <from uri="file://"/>
      
      <aggregate strategyRef="aggregatorStrategy">
        <correlationExpression>
          <simple>1</simple>
        </correlationExpression>
        <to uri="direct://SPLITTER"/>
      </aggregate>            
    </route>
    
    <route id="TEST2">
      <from uri="direct://SPLITTER"/>
      
      <to uri="file://"/>
    </route>
  </camelContext>
  
</beans>

Can anyone please help ?

Thank you, 
Cristian

--
View this message in context: 
http://camel.465427.n5.nabble.com/using-aggregator-camel-2-6-0-tp5713692.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to