2.12. JMS Message Selectors
A JMS message selector enables you to filter the messages that a
MessageConsumer
receives. To filter a message, a selector uses all the message headers and properties for filtering. However, it does not use the message content. Depending on the type of destination, a message selector works in the following ways:
- On the Queue, it returns only those messages whose header and property values match the selector. For example, if a message has a JMSType header with value fred, then the following selector is a match:
JMSType=fred
whereas, others stay in the queue and can be read by a MessageConsumer with different selector. - On the Topic, it ignores the messages that do not match the selector.
In Red Hat JBoss AMQ 6.2 release, a selector expression does not match if you apply it to a non-existent header. For example, if the selector message displays
JMSType<> fred, ensure that the header exists with defined values. If not, the selector does not match the undefined values. Now, if a non-existent header exists, use the following expression:
JMSType is NULL or JMSType <> fred