Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I modify Mule payload variables?

Tags:

mule

Using Mule 3.3, I've got a Payload (which starts out as a JSON and I'm converting it to an Object using java.util.HashMap). I can access the variables just fine from a JDBC query using:

#[message.payload.AddJob.variable1]

How do I go about adding a new variable (say variable2), or modifying the value of an existing variable?

I've tried:

<message-properties-transformer doc:name="Message Properties">
    <add-message-property key="message.payload.AddJob.variable2" value="&quot;hello&quot;"/>
</message-properties-transformer>

Which had no effect.

I also tried a groovy Script (below) as suggested here: How to add additional data to a mule payload?, but it overwrites the entire payload with "hello", not just variable2.

payload['AddJob.variable2'] = 'hello'
like image 701
Benjamin Bryan Avatar asked Mar 16 '26 09:03

Benjamin Bryan


1 Answers

What with:

<expression-transformer
            expression="#[message.payload.AddJob.variable2='hello';message.payload]" />

?

like image 181
David Dossot Avatar answered Mar 19 '26 00:03

David Dossot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!