You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Pred05 <re...@etu.univ-lorraine.fr> on 2015/05/27 10:56:57 UTC

Set value on a body attribute

Hi everybody, 
i haven't find in google if it is possible to set a value on a body
attribute directly in camel. 

For example to do something like this : 

<route id="aRoute">
    <from uri="direct:aRoute">
    <choice>
        <when>
            <simple>${body.attribute0 == 5}</simple>
            <simple>${body.attribute1 = 10}</simple> 
            <to uri="bean:doSomethingA?method=go"/>
        </when>
        <otherwise>
            <simple>${body.attribute1 = 15}</simple>
            <to uri="bean:doSomethingB?method=go"/>
        </otherwise>
    </choice>
</route>


Thanks for help!



--
View this message in context: http://camel.465427.n5.nabble.com/Set-value-on-a-body-attribute-tp5767522.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Set value on a body attribute

Posted by Pred05 <re...@etu.univ-lorraine.fr>.
Ok thanks for help, it work fine!



--
View this message in context: http://camel.465427.n5.nabble.com/Set-value-on-a-body-attribute-tp5767522p5767634.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Set value on a body attribute

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

ideally we would need a <script> in the dsl, so ppl can run groovy /
mvel / javascript / or whatnot that just runs the script.

You can "do this" today using the language endpoint and set
transform=false, and refer to a script in a script file on the
classpath etc.

Though there has a bit reluctant to include the <script> as people
should maybe not code in xml. However from time to time it can be
handy.



On Wed, May 27, 2015 at 4:08 PM, Pred05
<re...@etu.univ-lorraine.fr> wrote:
> Ok thanks you, can you explain to me how ?  i have try to replace the second
> <simple> by :
> <mvel>request.body.attribute1 = 10;</mvel>
>
> But it does't work because <simple> is already present.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Set-value-on-a-body-attribute-tp5767522p5767541.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: Set value on a body attribute

Posted by Pred05 <re...@etu.univ-lorraine.fr>.
Ok thanks you, can you explain to me how ?  i have try to replace the second
<simple> by :
<mvel>request.body.attribute1 = 10;</mvel> 

But it does't work because <simple> is already present. 



--
View this message in context: http://camel.465427.n5.nabble.com/Set-value-on-a-body-attribute-tp5767522p5767541.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Set value on a body attribute

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Not with simple. You would need to use mvel, groovy etc.

On Wed, May 27, 2015 at 10:56 AM, Pred05
<re...@etu.univ-lorraine.fr> wrote:
> Hi everybody,
> i haven't find in google if it is possible to set a value on a body
> attribute directly in camel.
>
> For example to do something like this :
>
> <route id="aRoute">
>     <from uri="direct:aRoute">
>     <choice>
>         <when>
>             <simple>${body.attribute0 == 5}</simple>
>             <simple>${body.attribute1 = 10}</simple>
>             <to uri="bean:doSomethingA?method=go"/>
>         </when>
>         <otherwise>
>             <simple>${body.attribute1 = 15}</simple>
>             <to uri="bean:doSomethingB?method=go"/>
>         </otherwise>
>     </choice>
> </route>
>
>
> Thanks for help!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Set-value-on-a-body-attribute-tp5767522.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/