How do I modify Mule payload variables?

北慕城南 提交于 2019-12-19 04:14:31

问题


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'

回答1:


What with:

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

?



来源:https://stackoverflow.com/questions/12610080/how-do-i-modify-mule-payload-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!