On Tue, Mar 3, 2009 at 9:56 AM, Martin Krasser <[email protected]> wrote: > ... just updated the enricher documentation with an example aggregation > strategy. > > Martin Thanks a lot.
> > Peter Maas schrieb: >> >> On Mar 3, 2009, at 8:10 , Claus Ibsen wrote: >> >>> On Tue, Mar 3, 2009 at 7:56 AM, Peter Maas <[email protected]> wrote: >>>> >>>> I think you've solved my problem. I was looking at the 'in' message of >>>> the >>>> resource exchange, whereas I should be looking at the 'out' message. >>>> And, >>>> btw, yes the CinemaQueryAssembler is thread-safe, I actually think all >>>> code >>>> should be threadsafe ;) >>> >>> Yeah if we could just got some basic annotations in the JDK, eg >>> @ThreadSafe then you could document it like that :) >>> >>> Maybe we need to improve the wiki for using the enricher to state you >>> should check the OUT for the response. >>> http://camel.apache.org/content-enricher.html >> >> Yeah, I actually think the documentation of the content-enricher is quite >> sparse, a simple example AggregationStrategy might help a lot: >> >> >> public class ProgramMerger implements AggregationStrategy { >> >> public Exchange aggregate(Exchange original, Exchange resource) { >> >> Document org = original.getIn().getBody(Document.class); >> Document additional = resource.getOut().getBody(Document.class); >> >> // create the new 'enriched' message >> Document result = ...; >> original.getOut().setBody(result); >> return original; >> } >> >> } >> >> >> >>>> >>>> On Tue, Mar 3, 2009 at 7:02 AM, Martin Krasser >>>> <[email protected]>wrote: >>>> >>>>> Hi Peter, >>>>> >>>>> the route looks good to me. >>>>> >>>>> * The in-messages of the original exchange and the resource exchange >>>>> are >>>>> always identical. The out-message of the resource exchange will contain >>>>> the >>>>> result from 'direct:enrichMovie'. >>>>> * What message exchange pattern do you use when you test (print the >>>>> contents of) the 'direct:enrichMovie' route? >>>>> * Is the CinemaQueryAssembler thread-safe? You're doing parallel >>>>> processing >>>>> of split messages. >>>>> >>>>> Martin >>>>> >>>>> Peter Maas schrieb: >>>>> >>>>> Hi list, >>>>>> >>>>>> I'm developing a proof-of-concept application using Camel 2.0. >>>>>> Everything >>>>>> seems to work just find... except for the content-enricher. Both the >>>>>> resource exchange passed to my AggregationStrategy look identical. >>>>>> Whilst if >>>>>> I print the contents of the resource route I the the correct xml in >>>>>> the >>>>>> exchange after calling the http service. My routes look like this: >>>>>> >>>>>> // split messages when received from the incoming mq >>>>>> // enrich if move. Always stor in database >>>>>> from("activemq:topic:incomingVPROGuide") >>>>>> >>>>>> .split(vpro.xpath("//vpro:program")).parallelProcessing(true) >>>>>> .choice() >>>>>> .when(vpro.xpath("/vpro:progr...@ismovie = 'true']")) >>>>>> .enrich("direct:enrichMovie", new ProgramMerger()) >>>>>> .to("direct:save") >>>>>> .otherwise().to("direct:save"); >>>>>> // the generic save route >>>>>> from("direct:save") >>>>>> .setHeader("xmldb.resource.name", >>>>>> vpro.xpath("//vpro:program/@id", String.class)) >>>>>> .process(sanitize("xmldb.resource.name")) >>>>>> .to("xmldb:/programs"); >>>>>> // route to retrieve data from external >>>>>> // rest service >>>>>> from("direct:enrichMovie") >>>>>> .setHeader("title", >>>>>> vpro.xpath("/vpro:program/vpro:title[1]/text()", String.class)) >>>>>> .setHeader("director", vpro.xpath("//vpro:pers...@urn = >>>>>> 'urn:mpeg:mpeg7:cs:RoleCS:2001:DIRECTOR' and >>>>>> 1]/vpro:familyName/text()", >>>>>> String.class)) >>>>>> .setHeader("year", vpro.xpath("//vpro:year[1]/text()", >>>>>> String.class)) >>>>>> .process(new CinemaQueryAssembler()) >>>>>> .to("http://cinema.test.vpro.nl/api/1/rest/movie/find.xml"); >>>>>> >>>>>> The xmldb producer is a patched version of the camel-extra project. >>>>>> Everything works fine, apart from the enricher... >>>>>> >>>>>> Any hints? >>>>>> >>>>>> kind regards, >>>>>> >>>>>> Peter Maas >>>>>> >>>>> >>>>> >>>> >>> >>> >>> >>> -- >>> Claus Ibsen >>> Apache Camel Committer >>> >>> Open Source Integration: http://fusesource.com >>> Blog: http://davsclaus.blogspot.com/ >> >> > > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/
