Search code examples
mulemule-el

NullPayload vs null check


According to the following ticket: https://www.mulesoft.org/jira/browse/MULE-6427 For NullPayload I should be able to use :

<when expression="#[payload == null]">

but that doesn't work. It fails. I am using Mule 3.5.1

Here is an example flow:

<flow name="testNull">
        <poll frequency="10000">
            <logger />
        </poll>

        <set-payload value="#[org.mule.transport.NullPayload.getInstance()]" />

        <choice>
            <when expression="#[payload == null]">
                <logger level="ERROR" message="NullPayload is same as null" />
            </when>
            <otherwise>
                <logger level="ERROR" message="Doesnt work" />
            </otherwise>
        </choice>

    </flow>

This will always print 'Doesn't work'. However message.payload == null works. Whats the difference between "payload" and "message.payload"?


Solution

  • There seems to be an issue with the #[payload] alias. Use the real thing and it will work: #[message.payload].