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 -
-