Message selectors

 

JMS provides a mechanism to select a subset of the messages on a queue so that this subset is returned by a receive call. When creating a QueueReceiver, we can provide a string that contains an SQL (Structured Query Language) expression to determine which messages to retrieve. The selector can refer to fields in the JMS message header as well as fields in the message properties (these are effectively application-defined header fields). Details of the header field names, as well as the syntax for the SQL selector, are in JMS messages.

The following example shows how to select for a user-defined property named myProp:

queueReceiver = session.createReceiver(ioQueue, "myProp = 'blue'");

The JMS specification does not permit the selector associated with a receiver to be changed. Once a receiver is created, the selector is fixed for the lifetime of that receiver. This means that, if you require different selectors, create new receivers.


uj24460_