You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by greendaycriss <gr...@yahoo.com> on 2012/05/29 15:29:14 UTC

using aggregator - camel 2.6.0

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.

Re: using aggregator - camel 2.6.0

Posted by greendaycriss <gr...@yahoo.com>.
Hello Henryk, 
thank you for you're time

attached is my pom configuration, maybe you figure out from this 


Best Regards, 
   Cristian http://camel.465427.n5.nabble.com/file/n5713742/pom.xml pom.xml 

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

Re: using aggregator - camel 2.6.0

Posted by Henryk Konsek <he...@gmail.com>.
>    "Cannot find class
> [org.apache.camel.processor.aggregate.AggregationStrategy]"
> ...
>  <osgi:reference id="aggregatorStrategyService"
> interface="org.apache.camel.processor.aggregate.AggregationStrategy"
> bean-name="aggregatorStrategy"/>

The most probably source of your problems is that you're got a wrong
configuration of BND Maven plugin [1]. This is common problem related
to the Blueprint support. I'm guessing that you're using it since you
wrote that you're using Maven for the project.

I could help you if send me minimal Maven project containing your
invalid configuration (so I can reproduce the bug).

Kind regards.

[1] http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com