I have tried that approach. It was pretty intuitive and made sense. The problem came when I had two routes from the same source (e.g., a log), one portion of which I wanted to route to one topic, the other part going to another topic. It appeared that, using the DSL with two routes, one message would go to one route (and get resolved properly), then the next would go to the next route (and not get resolved properly).
So, graphically: Source 1 --> Xpath 1 --> Process A --> Sink 1 Source 1 --> Xpath 2 --> Process A --> Sink 2 It seemed that message 1 hit the first route and ended up in the right place. Message 2, which should have been resolved by the first route, went to the second route and did not proceed (no match on the xpath filter). My conclusion, drawn without getting Trace to work, was that I needed a recipientlist, so that each message was presented to each route). That I could not do with DSL, as each "recipient" would be a pipeline, not a simple endpoint, and would require assembly within the result list loop. I am probably missing something. At any rate I do not yet have a scenario that works. Thanks for your help, Jim Bower James.Strachan wrote: > > 2009/2/25 jbower1950 <jim.bo...@gmail.com>: >> >> After working through Camel-Spring-ActiveMQ configuration and a DSL >> approach >> I am still struggling with the pieces necessary to achieve dynamic, >> data-driven routing for JMS as follows. >> >> Each "source" (ActiveMQ topic or queue) may have 0-n routes, each defined >> below: >> >> 1. Optional xpath expression for filtering >> 2. Optional processes >> 3. forwarding of the message to a destination (a different queue or >> topic) >> >> The recipientlist pattern is appropriate. However, it does not seem >> possible >> to use the DSL to assemble the route in pieces, as each recipient must be >> a >> pipeline of [xpath filter] [0-n processes] and an endpoint. The pieces >> are >> contained in a JPA result set, so I cannot piece the route together with >> DSL >> (have to loop to get the syntax. >> >> I have tried a processor with a producer template, but it does not seem >> to >> be reliable. >> >> Any hints? > > If I understand what you're saying - you're doing a JPA query to find > all the xpath expressions and processes to execute and you want to > create a route for each combination right? > > So something like this... > > public class MyRouteBuilder { > // inject JPA resources and whatever else you need with IoC > > public void configure() { > List<Foo> foos = ... // some query > for (Foo foo : foos) { > String u = foo.getFromEndpointUri(); > String xp = foo.getXPath(); > Class type = foo.getBeanType(); // or processor type > > // lets add a route from the uri and filter to the given > processor > from(u).filter().xpath(xp).bean(type); > } > } > > i.e. you can use the Java DSL within any regular Java code (loops, > conditional branches and whatnot) plus you can dependency inject your > RouteBuilder with whatever resources it needs (like JPA stuff) > > -- > James > ------- > http://macstrac.blogspot.com/ > > Open Source Integration > http://fusesource.com/ > > -- View this message in context: http://www.nabble.com/Re%3A-Data-driven-routing-tp22214166p22216427.html Sent from the Camel Development mailing list archive at Nabble.com.