سؤال

How can I check if my session variable is null or empty in this CHOICE Its not working for me.

    <processor-chain doc:name="Processor Chain">
        <choice> 
            <when evaluator="groovy" expression="#[header:session:countryCode] != ">                    
                <logger message="Valid Country Id" level="INFO" doc:name="Logger"/>                 
            </when>            
            <otherwise>
                <logger message="Invalid Country Id" level="INFO" doc:name="Logger"/>                   
            </otherwise>
        </choice>           
    </processor-chain>

I also tried != '' and != null

هل كانت مفيدة؟

المحلول

You are using an invalid groovy expression. It should be:

    ...
    <when expression="message.getProperty('countryCode',org.mule.api.transport.PropertyScope.SESSION)!=null 
                      || message.getProperty('countryCode',org.mule.api.transport.PropertyScope.SESSION)!=''"
    evaluator="groovy">
    ...

You can also access properties with Header evaluator but I'm not sure if you can evaluate to find out if it is null or empty

نصائح أخرى

If you're using Mule 3.3.x, better use MEL than Groovy:

<when expression="#[org.mule.util.StringUtils.isNotEmpty(sessionVars.countryCode)]">
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top