You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mail2bansi <ma...@gmail.com> on 2012/12/06 13:34:03 UTC

Simple Expression With And Condition doesnt work in Camel 2.8

Hello Group,
Here is the snippet from my camel-context.xml 
<choice>
                <when>
                    <simple>("${noun} contains 'Hello' and ${verb} contains
'World'")  </simple>

                    <to uri="direct://helloStart"/>
                </when>
             

            </choice>

It throws the following error at run-time:
org.apache.camel.ExpressionIllegalSyntaxException: Illegal syntax: noun

Any pointers/suggestions with the correct syntax will be greatly
appreciated.

Thanks ,
Bansi






--
View this message in context: http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Simple Expression With And Condition doesnt work in Camel 2.8

Posted by AlanFoster <al...@alanfoster.me>.
Oh, I just noticed another small mistake. You've wrapped everything in speech
marks, this isn't necessary in the xml dsl

<simple>${property.noun} contains 'Hello' and ${property.verb} contains
'World'</simple> 



--
View this message in context: http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702p5723792.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Simple Expression With And Condition doesnt work in Camel 2.8

Posted by AlanFoster <al...@alanfoster.me>.
You have stored the information on the exchange's properties, so you need to
use the correct simple syntax

<simple>("${property.noun} contains 'Hello' and ${property.verb} contains
'World'")  </simple>



--
View this message in context: http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702p5723791.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Simple Expression With And Condition doesnt work in Camel 2.8

Posted by Claus Ibsen <cl...@gmail.com>.
In Camel 2.8 or older you have to be more careful when using simple
language. The parser was re-written for 2.9 onwards.
For example you should not have the ("xxx") around the entire simple expression.

And try with 1 expression first, and make sure that works. Then you
can add the " and ...".
And only have exactly 1 space around the operator.



On Wed, Dec 12, 2012 at 7:16 AM, mail2bansi <ma...@gmail.com> wrote:
> Thanks everyone for responding. But still it doesnt work. I am not sure if
> the below expression is evaluated as it always call the route under first
> expression even thought its false
>
> Here is an example:
> <choice>
>                 <when>
>                     <simple>("${property.noun} contains 'Hello' and
> ${property.verb} contains 'World'")  </simple>
>
>
>                     <to uri="direct://HelloWorldRequestStart"/>
>                 </when>
>
>                 <when>
>                     <simple>("${property.noun} contains 'Hello' and
> ${property.verb} contains 'Camel'")  </simple>
>
>                      <to uri="direct://HelloCamelRequestStart"/>
>
>                 </when>
>             </choice>
>
> The Exchange property sets the following attributes:
> noun: Hello
> verb: camel
>
> But it always calls <to uri="direct://HelloWorldRequestStart"/> instead of
> <to uri="direct://HelloCamelRequestStart"/>
> Not sure where i am going wrong
>
> Regards,
> Bansi
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702p5723935.html
> Sent from the Camel - Users 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

Re: Simple Expression With And Condition doesnt work in Camel 2.8

Posted by mail2bansi <ma...@gmail.com>.
Thanks everyone for responding. But still it doesnt work. I am not sure if
the below expression is evaluated as it always call the route under first
expression even thought its false

Here is an example:
<choice>
                <when>
                    <simple>("${property.noun} contains 'Hello' and
${property.verb} contains 'World'")  </simple>

                
                    <to uri="direct://HelloWorldRequestStart"/>
                </when>

                <when>
                    <simple>("${property.noun} contains 'Hello' and
${property.verb} contains 'Camel'")  </simple>

                     <to uri="direct://HelloCamelRequestStart"/>

                </when>
            </choice>

The Exchange property sets the following attributes: 
noun: Hello 
verb: camel

But it always calls <to uri="direct://HelloWorldRequestStart"/> instead of
<to uri="direct://HelloCamelRequestStart"/>
Not sure where i am going wrong

Regards,
Bansi





--
View this message in context: http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702p5723935.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Simple Expression With And Condition doesnt work in Camel 2.8

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Dec 8, 2012 at 1:15 AM, mail2bansi <ma...@gmail.com> wrote:
> Thanks Christian for quick response. I greatly appreciate it.
> The ${noun} or ${verb} are String variables and are set into Exchange as
> follows:
>
>
> MessageDispatchHeader messageDispatchHeader =
> xxxMessageEnvelope.getMessageDispatchHeader();
>         final String noun = messageDispatchHeader.getNoun();
>         final String verb = messageDispatchHeader.getVerb();
>
> Exchange   exchange = template.send("direct://contentBaseRouteStart", new
> Processor() {
>                 public void process(Exchange exchange) throws Exception {
>
>
>                     // Noun Verb Combo.
>                     exchange.getIn().setBody(xxxMessageEnvelope);
>                     exchange.setProperty("noun", noun);
>                     exchange.setProperty("verb", verb);
>

You need to prefix the name with "property." as documented here
http://camel.apache.org/simple

eg ${property.noun}



>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702p5723778.html
> Sent from the Camel - Users 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

Re: Simple Expression With And Condition doesnt work in Camel 2.8

Posted by mail2bansi <ma...@gmail.com>.
Thanks Christian for quick response. I greatly appreciate it.
The ${noun} or ${verb} are String variables and are set into Exchange as
follows:


MessageDispatchHeader messageDispatchHeader =
xxxMessageEnvelope.getMessageDispatchHeader();
        final String noun = messageDispatchHeader.getNoun();
        final String verb = messageDispatchHeader.getVerb();

Exchange   exchange = template.send("direct://contentBaseRouteStart", new
Processor() {
                public void process(Exchange exchange) throws Exception {
                    

                    // Noun Verb Combo.
                    exchange.getIn().setBody(xxxMessageEnvelope);
                    exchange.setProperty("noun", noun);
                    exchange.setProperty("verb", verb);




--
View this message in context: http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702p5723778.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Simple Expression With And Condition doesnt work in Camel 2.8

Posted by Christian Müller <ch...@gmail.com>.
What should ${noun} or ${verb} be? I suggest to have a look at our
documentation: http://camel.apache.org/simple.html

Best,
Christian

On Thu, Dec 6, 2012 at 1:34 PM, mail2bansi <ma...@gmail.com> wrote:

> Hello Group,
> Here is the snippet from my camel-context.xml
> <choice>
>                 <when>
>                     <simple>("${noun} contains 'Hello' and ${verb} contains
> 'World'")  </simple>
>
>                     <to uri="direct://helloStart"/>
>                 </when>
>
>
>             </choice>
>
> It throws the following error at run-time:
> org.apache.camel.ExpressionIllegalSyntaxException: Illegal syntax: noun
>
> Any pointers/suggestions with the correct syntax will be greatly
> appreciated.
>
> Thanks ,
> Bansi
>
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Simple-Expression-With-And-Condition-doesnt-work-in-Camel-2-8-tp5723702.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--