Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A message selector allows a JMS consumer to be more selective about the messages that it receives from a particular topic or queue. A message selector uses message properties and message headers as criteria in conditional expressions. These expressions use Boolean logic to declare the messages that are delivered to a client. The message consumer will only receive messages where the headers and properties match the selector. There are different patterns that can be used in selector strings to filter messages and the broker (JMS provider) filters messages according to that query. It is not possible for a message selector to filter messages on the basis of the content of the message body.

...

The way selectors work depends on the type of subscription that is created from JMS clients. The following sections explain the different scenarios:

Queue subscriptions

  • Only messages that match the selector will be delivered to the subscriber. 
  • If at least one subscriber out of a few subscribers for a queue has a matching selector, the message will be delivered to that subscriber. 
  • If more than one subscriber has a matching selector, the messages will be delivered in round robin manner between those subscribers. 
  • If none of the subscribers have matching selectors, that message will be placed in the Dead Letter Channel (DLC).

...

Examples of selector patterns

Some example Given below are some sample selector patterns are listed below:.

Selector PatternsExample
Header='value' OR Header='value' JMSType='AAAA' OR JMSPriority=4
Property='value' AND Property='value'Country='SL' AND ID=1
Header='value' OR Property='value'JMSType='AAA' OR msgID='1'
Header='value' AND Property='value' AND Property='value' JMSType = 'AAA' AND color = 'red' AND weight= 3500
(Property='value' OR Header='value') AND Property='value' (Country='SL' OR JMSType='AAA') AND ID=1

...