user595234
user595234

Reputation: 6249

Mule MEL, how to get a property value?

In the Mule MEL, how to get a property value ?

In the java code, I did this:

eventContext.getMessage().setInvocationProperty("amount", 100);

I have tried these options

#[message.invocationProperty.invocation]
#[message.invocationProperty('invocation')]
#[message.getInvocationProperty().get('invocation')]

I realize that message is an instance of org.mule.el.context.MessageContext, then what is the correct syntax ?

Upvotes: 1

Views: 10216

Answers (5)

2ark0
2ark0

Reputation: 107

Although the sintaxis is almost the same, it depends on the scope of the property variable, but the most usual way is:

#[flowVars['flow_var_name']]

In my personal opinion I don't recommend to use:

#[flowVars.variable]

Because in some complex environment with many messageContext switches the variable could get lost. I recommend to take a look on the next post from Mulesoft oficial blog that shows how to handle Properties and variables.

Upvotes: 1

Abhishek M
Abhishek M

Reputation: 1

To get the Invocation properties of a message follow this syntax:

#[flowVars.parameter] or #[flowVars['paramater']]

Upvotes: 0

Stefano
Stefano

Reputation: 1722

If you set a variable with scope INVOCATION (with Message Enricher or Variable), you can get the variable with the syntax below:

#flowVars['your_Variable_Name']

Upvotes: 3

user1760178
user1760178

Reputation: 6657

This answer for your comment

<set-variable variableName="amount" value="message.invocationProperties['amount']" />

Solution is

<set-variable variableName="amount" value="#[message.invocationProperties['amount']]" />

Upvotes: 0

Ale Sequeira
Ale Sequeira

Reputation: 2039

Try #[message.inboundProperties['propertyName']] or #[message.invocationProperties['propertyName']]

Upvotes: 3

Related Questions