using aggregator - camel 2.6.0

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

using aggregator - camel 2.6.0

greendaycriss
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
Reply | Threaded
Open this post in threaded view
|

Re: using aggregator - camel 2.6.0

hekonsek
>    "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
Reply | Threaded
Open this post in threaded view
|

Re: using aggregator - camel 2.6.0

greendaycriss
Hello Henryk,
thank you for you're time

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


Best Regards,
   Cristianpom.xml