title: Mule message.payload and payload
body: <p>I have a Mule Expression Language expression:</p>
  
  <pre><code>&lt;set-payload value="#[message.payload.hasNext() ? message.payload.next(): null]" doc:name="Set Payload"/&gt;
  &lt;choice  doc:name="Choice"&gt;
    &lt;when expression="#[message.payload != null]"&gt;
  </code></pre>
  
  <p>I am trying to iterate over a <code>ConsumerIterator</code> and am getting the error</p>
  
  <pre><code>Execution of the expression "message.payload.hasNext() ? message.payload.next(): null" failed. (org.mule.api.expression.ExpressionRuntimeException)
  org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
  6. Execution of the expression "message.payload.hasNext() ? message.payload.next(): null" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: ConsumerIterator (org.mule.api.transformer.TransformerMessagingException)
  org.mule.transformer.AbstractTransformer:135 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerMessagingException.html)
  </code></pre>
  
  <p>My solution to this is to rewrite the code without the <code>message.</code> prefix:</p>
  
  <pre><code>&lt;set-payload value="#[payload.hasNext() ? payload.next(): null]" doc:name="Set Payload"/&gt;
  &lt;choice  doc:name="Choice"&gt;
    &lt;when expression="#[payload is NullPayload]"&gt;
  </code></pre>
  
  <ol>
  <li><p>What is the difference between #[message.payload] and #[payload]? </p></li>
  <li><p>If <code>payload</code> is an instance of <code>NullPayload</code> why doesn't <code>payload.hasNext()</code> throw an <code>Exception</code>?</p></li>
  </ol>
  
  <p>From what I've read the best practice is to use <code>#[message.payload]</code> instead of <code>#[payload]</code>. </p>
  
  <p>I am using Mule 3.6.2.</p>