How do you set message properties in Mule using Groovy?

GarySharpe picture GarySharpe · Nov 21, 2013 · Viewed 10.5k times · Source

How do you set message properties in Mule using Groovy?

I need to set a message property from within a Groovy Scripting Component. Documentation on the subject does not appear to be easy to find.

Answer

Ryan Hoegg picture Ryan Hoegg · Nov 21, 2013

You can set individual properties as follows:

message.setInvocationProperty('myFlowVariable', 'value') // sets a flow variable, like <set-variable/>
message.setOutboundProperty('myProperty', 'value') // sets an outbound message property, like <set-property/>
message.setProperty('myInboundProperty', 'value', PropertyScope.INBOUND) // sets an inbound property