On Mon, Aug 19, 2013 at 10:41 PM, peacock.snowdrift <
mark.har...@arcinnovations.co.nz> wrote:

> Claus Ibsen-2 wrote
> > A good idea is to check the docs
> > http://camel.apache.org/predicate.html
> >
> > For example you can use the front page of Apache Camel
> > http://camel.apache.org/
> >
> > And type in keywords in the search box.
> >
> > As well read some of the intro guides and whatnot.
> > There is also a lot of links to external Camel intro and resources at
> > http://camel.apache.org/articles
>
> Hi,
>
> I have looked through the documentation as you suggest but still cannot
> find
> the syntax for referring to local variables with predicates - all the
> examples I have found look at the exchange's headers.
>
> Thanks.
>

Hello,

As Willem points out your mixing design time and runtime.

Predicates is mostly intended for runtime hence most examples works on
exchange headers.

However if you want to use predicts I believe you can use the constant()
method in your predicate.
---
from(uri)
... stuff here...
.to(destination)
.choice()
.when(constant(localVar).isEqualTo("value")).to(additionalDestination);
---
Or since you are doing all this in design time you can also build the route
normal if statements (as you do) but use a local route definition variable
to avoid having to duplicating code .
---
RouteDefinition myRoute = from(uri)
 .... stuff here...
.to(destination):

if ( localVar == value) {
  myRoute.to(additionalDestination);
} else {
  myRoute.to(someotherDestination);
}

myRoute.to(commonFinalDestination);
---

Best regards
Pontus Ullgren

Reply via email to