title: jms message selectors
body: <p>I am using ActiveMQ 5.5 and JMS. I have created a topic consumer with a message selector of </p>
  
  <pre><code>key&lt;&gt;'aValue'
  </code></pre>
  
  <p>meaning that the consumer will only receive messages that have a property called "key" that does not have the value 'aValue'.</p>
  
  <p>Then I send a message with no property called "key" (Note that the case is NOT that there is a property with a null value, there is no property.)</p>
  
  <p>What puzzles me is that the message is delivered.</p>
  
  <p>This is not the case if I use the operator NOT LIKE: </p>
  
  <pre><code>key NOT LIKE 'aVal%'. 
  </code></pre>
  
  <p>In this case the consumer does not receive the message. This is inconsistent in my mind. </p>
  
  <p>This is what the JMS spec says:</p>
  
  <blockquote>
    <p>A message selector matches a message when the selector evaluates to true when the message's header field and property values are substituted for their corresponding identifiers in the selector.</p>
  </blockquote>
  
  <p>According to the SQL92 spec (which JMS message selectors syntax is based on) comparing anything to NULL results in NULL rather than to a value (TRUE or FALSE in this case). If this is the case the first case should not result in the message being received.</p>
  
  <p>Has anybody come across this? Which result, the &lt;> case or the NOT LIKE case, is the correct one when the producer has not specified the property and the consumer has a selector? Any ideas how this can be worked around?</p>