Pregunta

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!

¿Fue útil?

Solución

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.

Otros consejos

you can also define choice expression condition referring to properties files as below.

<when expression="#['${test}' =='1']">

You were just missing to enclose you property reference with single quote.You can also use equals method instead of using == operator. You just need to enclose your property reference with single quote before the comparison.

<*when expression="'${CONTROL_VARIABLE}'.equals('S')"*>

Explanation: When you enclose the property reference with single quote like '${CONTROL_VARIABLE}' it gets converted into string object after this you can apply any method/operator which supports String type.

Hope this helps.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top