Search code examples
mulemule-studiomule-el

Mulesoft - Using choice component


I'm developing an application with mule studio, I need to use the "Choice" component, but I'd like to evaluate not a message property contained in the payload, but a variable contained in a property file, like that:

<choice doc:name="Choice">
                <when expression="${CONTROL_VARIABLE}.equals(&quot;S&quot;)">
                    <set-variable variableName="URL_ADDRESS" value="${URL_PREPATH_VALUE}/[#payload.URL]" doc:name="Variable"/>
                </when>
                <otherwise>
                    <set-variable variableName="URL_ADDRESS" value="[#payload.URL]" doc:name="Variable"/>
                </otherwise>
            </choice>

Of course it doesn't work, because if I understand properly, only message payload can be evaluated.

How can I accomplish the task in the best way? Have I to add all the property file variables in the payload in some way?

Thank you!


Solution

  • The conditional expression in the CHOICE is going to work absolutely fine with data loaded from properties files.

    try the following piece and it should work.

    <when expression="'${CONTROL_VARIABLE}' == 'S'">
    

    Hope this helps.