What is the scope of variables in Mule expression components, and how does that relate to flow variables? I had a flow with a set-variable and was surprised to see that the value was being overwritten by an assignment in an expression-component. For example,
<flow name="HelloWorldFlow1" doc:name="HelloWorldFlow1">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="9999" doc:name="HTTP"
doc:description="This endpoint receives an HTTP message." path="helloworld"/>
<set-variable variableName="asdf" value="firstvalue" doc:name="Variable"/>
<logger message="#[flowVars["asdf"]]" level="INFO" doc:name="Logger"/>
<expression-component doc:name="Expression"><![CDATA[asdf = "secondvalue";]]></expression-component>
<logger message="#[flowVars["asdf"]]" level="INFO" doc:name="Logger"/>
<expression-component doc:name="Expression"><![CDATA[qwer = "thirdvalue";]]></expression-component>
<logger message="#[flowVars["qwer"]]" level="INFO" doc:name="Logger"/>
</flow>
The output of this is:
INFO 2014-04-25 08:58:46,889 [[helloworld].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: firstvalue
INFO 2014-04-25 08:58:46,893 [[helloworld].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: secondvalue
INFO 2014-04-25 08:58:46,895 [[helloworld].connector.http.mule.default.receiver.02] org.mule.api.processor.LoggerMessageProcessor: null
If possible, can you point me to the documentation of the scoping rules? I've tried a few different searches and keep getting extraneous results.
Clarification: Within the expression-component, does Mule first check to see if there is a flow variable with a given name and then use that variable instead of creating a new one? If the expression component creates a variable, is the scope limited to just the expression component code? In http://blogs.mulesoft.org/mule-school-the-mulemessage-property-scopes-and-variables/, it says that Mule flow variables "behave like instance properties", but I can't find a definition for what an instance property is. The word scope is also not in the expression component reference page (http://www.mulesoft.org/documentation/display/current/Expression+Component+Reference).