You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by irshad <ir...@gmail.com> on 2013/03/12 15:39:08 UTC
How to use predicate in when() for Body in choice()
Hello,
I am pretty new in using camel and trying to incorporate it in our
architecture, so everyone here is pretty new to Camel.
Question: After the choice() method we are using a boolean expression in
when() where it is complaining to use predicate. So could you give an idea
how to use predicate for the same.
from("direct:saveFile").convertBodyTo(List.class).split(body())
.choice()
.when("R".equalsIgnoreCase(simple("${body.filing.frstatus}").toString()))
.to("sql:insertQuery")
.when("R".equalsIgnoreCase(simple("${body.filing.frstatus}").toString()))
.to("sql:updateQuery")
.otherwise()
.to("errorHandler")
.end();
thanks
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-predicate-in-when-for-Body-in-choice-tp5728999.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: How to use predicate in when() for Body in choice()
Posted by Christian Müller <ch...@gmail.com>.
Instead of:
when("R".equalsIgnoreCase(simple("${body.filing.frstatus}").toString()))
you should have something like:
when(simple("${body.filing.frstatus} == 'R')")
or implement your own predicate. It's only an interface with one method:
http://camel.apache.org/predicate.html
when(MyFrStatusCheckingPredicate("R"))
Best,
Christian
On Tue, Mar 12, 2013 at 3:39 PM, irshad <ir...@gmail.com> wrote:
> Hello,
>
> I am pretty new in using camel and trying to incorporate it in our
> architecture, so everyone here is pretty new to Camel.
>
> Question: After the choice() method we are using a boolean expression in
> when() where it is complaining to use predicate. So could you give an idea
> how to use predicate for the same.
>
> from("direct:saveFile").convertBodyTo(List.class).split(body())
> .choice()
>
> .when("R".equalsIgnoreCase(simple("${body.filing.frstatus}").toString()))
> .to("sql:insertQuery")
>
> .when("R".equalsIgnoreCase(simple("${body.filing.frstatus}").toString()))
> .to("sql:updateQuery")
> .otherwise()
> .to("errorHandler")
> .end();
>
>
> thanks
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-use-predicate-in-when-for-Body-in-choice-tp5728999.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
Re: How to use predicate in when() for Body in choice()
Posted by irshad <ir...@gmail.com>.
Thank you for the info :)
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-predicate-in-when-for-Body-in-choice-tp5728999p5729857.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: How to use predicate in when() for Body in choice()
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Could you please use the @user mailing list for questions on help and
how to use Camel.
http://camel.apache.org/mailing-lists.html
On Tue, Mar 12, 2013 at 3:39 PM, irshad <ir...@gmail.com> wrote:
> Hello,
>
> I am pretty new in using camel and trying to incorporate it in our
> architecture, so everyone here is pretty new to Camel.
>
> Question: After the choice() method we are using a boolean expression in
> when() where it is complaining to use predicate. So could you give an idea
> how to use predicate for the same.
>
> from("direct:saveFile").convertBodyTo(List.class).split(body())
> .choice()
>
> .when("R".equalsIgnoreCase(simple("${body.filing.frstatus}").toString()))
> .to("sql:insertQuery")
>
> .when("R".equalsIgnoreCase(simple("${body.filing.frstatus}").toString()))
> .to("sql:updateQuery")
> .otherwise()
> .to("errorHandler")
> .end();
>
>
> thanks
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-predicate-in-when-for-Body-in-choice-tp5728999.html
> Sent from the Camel Development mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen