You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by spurcell <sc...@mastercard.com> on 2016/10/18 13:53:24 UTC

Choice Based On Pojo in Exchange

Hello Team,

I have a Pojo in my exchange, and the pojo has a List<Errors> that may be
empty or may have 0..* errors. I would like to create a .choice() based upon
the size of the errors list. Is this possible? I see that I can use header
and body in the choice, but not sure if the pojo will work. Can someone
chime in on this?

Thanks

Something like this:
 .choice()
                .when(body().isErrors().size() < 1))
                .to("bean:xxx"")
                .otherwise()
                .to("bean:xxx");



--
View this message in context: http://camel.465427.n5.nabble.com/Choice-Based-On-Pojo-in-Exchange-tp5788899.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Choice Based On Pojo in Exchange

Posted by Claus Ibsen <cl...@gmail.com>.
You can use simple, mvel, ognl, groovy as the language to build that predicate
http://camel.apache.org/languages

For example with simple

when(simple("${body.isErrors().size()} < 1"))



On Tue, Oct 18, 2016 at 3:53 PM, spurcell <sc...@mastercard.com> wrote:
> Hello Team,
>
> I have a Pojo in my exchange, and the pojo has a List<Errors> that may be
> empty or may have 0..* errors. I would like to create a .choice() based upon
> the size of the errors list. Is this possible? I see that I can use header
> and body in the choice, but not sure if the pojo will work. Can someone
> chime in on this?
>
> Thanks
>
> Something like this:
>  .choice()
>                 .when(body().isErrors().size() < 1))
>                 .to("bean:xxx"")
>                 .otherwise()
>                 .to("bean:xxx");
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Choice-Based-On-Pojo-in-Exchange-tp5788899.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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