Additional JMS Features

The following sections cover some additional features available in JMS. Not all the features of JMS are covered, and you should refer to the JMS API specification for more information.

Message Selectors

The JMS API provides support for filtering received messages. This is accomplished by using a message selector. The createConsumer() and the createDurableSubscriber() methods have variants that allow a message selector to be specified.

The message selector is a string containing an SQL-like conditional expression. Only message header values and properties can be specified in the message selector. It is not possible to filter messages based on the contents of the message body.

 String highPriority = "JMSPriority = '9' AND ...

Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.