0

Trying to wrap my head around MEL and so running through a few examples.

I am trying to evaluate multiple MEL expressions as part of the Set Payload component and looks like only the last expression is evaluated by mule. My flow looks like the below

<flow name="dummysoapFlow">
    <http:listener config-ref="DummyHttp" path="dummy" doc:name="HTTP" allowedMethods="GET"/>
    <set-payload value="#[['name':'Sudarshan']]" doc:name="Set Payload"/>
    <set-payload value="#[ ['name':'Fudarshan']; with (payload) {age = 18} ]" doc:name="Set Payload"/>
    <logger message="Landed past HTTP #[payload]" level="INFO" doc:name="Logger"/>
</flow>

My Actual result looks the below

Landed past HTTP {age=18, name=Sudarshan}

I expect

Landed past HTTP {age=18, name=Fudarshan}

Can we use multiple expression as part of the Set Payload MP ?, I can see that its possible with the expression component here

Community
  • 1
  • 1
Sudarshan
  • 8,574
  • 11
  • 52
  • 74
  • I have used set payload with expression like this #[message.payload=org.mule.util.StringUtils.remove(message.payload,'test1');message.payload=org.mule.util.StringUtils.remove(message.payload,'test2')] modified my original payload to bring in to my requirement. Check it fits to you. We can add as many which is required in set Payload. But if you have more to modified, why you were looking for Set payload , can use Expression component itself. – star May 08 '15 at 01:02
  • I agree with you, I was just playing here, I think the key takeaway is the assignment into the payload variable, I had assumed that as we are in the Set Payload MP it would automagically execute all expressions in the context of the payload itself. Anyways this works and thanks, if you can pop it into a answer,I will mark it "correct" – Sudarshan May 08 '15 at 01:12

1 Answers1

3

Can use the set payload script as mentioned in below Example

 [message.payload=org.mule.util.StringUtils.remove(message.payload,'test1');mess‌​age.payload=org.mule.util.StringUtils.remove(message.payload,'test2')]
star
  • 1,493
  • 1
  • 28
  • 61