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:
  1. 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.
  2. 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

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.