Message Selector Syntax

JMS message selectors are used by JMS clients to filter the messages that a JMS server delivers to a given MessageConsumer . A message selector is provided (optionally) when a MessageConsumer is created, using either the QueueSession.createReceiver( ) or the TopicSession.createSubscriber( ) methods.

A message selector is a string that specifies a predicate to be applied to each message the provider wants to deliver to a MessageConsumer. If the predicate evaluates to true, the message is delivered; if false, the message isn’t delivered. In point-to-point messaging, when messages are filtered out by a message selector, the message remains in the queue until the client eventually reads it, or the message times out, and the server removes it from the queue. In publish-subscribe messaging, messages that are filtered are never delivered to the subscriber.

Get Java Enterprise in a Nutshell, 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.