The DynamicRouter is used for telling where to route the message next. You cannot enrich or manipulate the message from within it.
In Camel 3 we would re-architect the Camel routing engine to use a different strategy than defensive copy of Exchange during routing. This open doors to let end users manipulate the exchange more easily from within the EIPs. On Wed, Mar 2, 2011 at 4:22 PM, Caza Henha <[email protected]> wrote: > > Hi All, > > > > I’m new to Camel so forgive me if I am missing something > obvious. Basically I have quite a basic route that is using a dynamic router. > Where I am having problems is setting either properties or headers of the > Exchange, as when progressing to the next endpoint/route they disappear. > >From the logging I presume this is because a new Exchange is being created, > however if properties are set > on the original route (File) they seem to be persisted. For example below the > “id” > property persists throughout all the routes, however the property (and the > header) > that I set within the “check” method disappear altogether even within > the alert endpoint. How should I be doing this, I’ve even tried using > @OutHeaders but still “bar” does not appear even in “seda:alert” log. Any > help is appreciated as I guess I'm doing something wrong. > > > > > Caza > > > > public class Manager { > > …. > > Public String check(Exchange > exchange, @Property("id") UUID id, @Header(Exchange.SLIP_ENDPOINT) String > previous) > > … > > UUID result = lookup(id); > > if(result > == null){ > > exchange.getIn().setHeader("foo", > "bar"); > > exchange.setProperty("foo", > "bar"); > > return > “seda:alert”; > > } > > … > > return null; > > … > > } > > > > public class Router extends RouteBuilder{ > > private static final UUID id = > UUID.fromString("fbb470de-cb84-4b4c-b5d2-11610062b194"); > > > > public void configure() { > > > > from("file:W:/data?noop=true").routeId("File") > > .setProperty("id",constant(id)) > > .log("Starting > to process file: ${header.CamelFileName}") > > .unmarshal().csv().to("seda:product") > > .log("${exchangeId} - ${property.supplierId} - ${property.foo} > - ${header.foo}"); > > > > from("seda:product").routeId("Check") > > .dynamicRouter(bean("mmc", > "check")) > > .log("${exchangeId} - ${property.supplierId} - ${property.foo} > - ${header.foo}"); > > > > from("seda:alert").routeId("Alert") > > .log("${exchangeId} - ${property.supplierId} - ${property.foo} - > ${header.foo}"); > > } > > } > > > > Output:[file://W:/data] File INFO > ID-DESK-0001-64505-1299079027828-0-2 - fbb470de-cb84-4b4c-b5d2-11610062b194 - > - > [ Camel Thread 3 - seda://alert] Alert INFO > ID-DESK-0001-64505-1299079027828-0-4 - fbb470de-cb84-4b4c-b5d2-11610062b194 - > - > [amel Thread 2 - seda://product] Check INFO > ID-DESK-0001-64505-1299079027828-0-3 - fbb470de-cb84-4b4c-b5d2-11610062b194 - > - -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
