Hi Claus

Thanks! Now it works
I do use: Predicate isSystemActive = 
simple("${exchangeProperty.systemConfig.isActive}").isEqualTo(true);

-----Original Message-----
From: Claus Ibsen <claus.ib...@gmail.com> 
Sent: Tuesday, 18 October 2022 09:13
To: users@camel.apache.org
Subject: Re: Predicates

Hi

systemConfig.isActive is a key name, so that only works if the property is 
really named like that.
Its not doing any kind of method call - i.e. calling isActive() on the property 
with key xxxx, that the simple can do.

On Tue, Oct 18, 2022 at 9:01 AM Reto Peter <reto.pe...@advanceit.ch> wrote:

> Hi Clause
>
> So for a header I can define a Predicate, but for a property I can't?
>
> Example with header: (that works?)
> Predicate isSystemActive = header("isSystemActive").isEqualTo("true");
>
> Example with property: (that doesn’t work?) Predicate isSystemActive = 
> exchangeProperty ("systemConfig.isActive").isEqualTo(true);
>
> So later I can use:
> choice().when(isSystemActive)
>
> -----Original Message-----
> From: Claus Ibsen <claus.ib...@gmail.com>
> Sent: Monday, 17 October 2022 20:49
> To: users@camel.apache.org
> Subject: Re: Predicates
>
> Hi
>
> > exchangeProperty("systemConfig.isActive")
>
> This is not simple language, but refers to a exchange property key 
> with the given name.
> You need to use simple as predicate instead of exchangeProperty
>
>
>
>
>
>
> On Mon, Oct 17, 2022 at 7:38 PM Reto Peter <reto.pe...@advanceit.ch>
> wrote:
>
> > Hi
> > I have a simple question about the Predicates I got a systemConfig 
> > object, which has 2 getters/setters.
> > The systemConfig object is set as an exchange property.
> >
> > When I use a the simple function, that works!
> > from("direct:testPredicates")
> > .to("direct:getSystemConfig")
> >        .choice()
> > .when(simple("${exchangeProperty.systemConfig.isActive} == false || 
> > ${exchangeProperty.systemConfig.isEnabled} == false"))
> >        .log("System is active and System is enabled")
> >               .otherwise()
> >                     .log("System is not active or MLSSync is disabled")
> >        .end();
> >
> > When I try to use Predicates, then I thought this should work like this:
> > Before the route:
> > Predicate isSystemActive =
> > exchangeProperty("systemConfig.isActive").isEqualTo(true);
> > Predicate isSystemEnabled =
> > exchangeProperty("systemConfig.isEnabled").isEqualTo(false);
> >
> > Inside the route:
> > from("direct:testPredicates")
> > .to("direct:getSystemConfig")
> >        .choice()
> >               .when(and(isSystemActive, isSystemEnabled))
> >                     .log("System is active and System is enabled")
> >               .otherwise()
> >                     .log("System is not active or MLSSync is disabled")
> >        .end();
> >
> > I am using Camel 3.18.2
> >
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to