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.
Note |
---|
Note that message selectors are not supported in a clustered setup of WSO2 Message Broker (WSO2 MB). |
See the following topics for details:
Table of Contents | ||||
---|---|---|---|---|
|
...
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).
...
- Only messages that match the selector will be delivered to the durable topic subscriber.
- When keeping a copy of a message coming for a topic for the particular subscription ID, selectors are not evaluated. They are evaluated upon delivery only.
- If a message does not match with the selector for a particular durable topic subscription, it will be routed to the Dead Letter Channel (DLC).
Messages routed to DLC
- If none of the subscribers have matching selectors with a message and if the message is for a durable queue or durable subscription, the message is routed to the DLC.
- User has the option to delete messages selectively if they are unnecessary.
- It is possible to create a new queue and route all unmatched messages to that queue if required.
- It is possible to create a new subscriber with a matching selector for some or all messages routed to the DLC and route all messages to the original queue again. Then, if there are newly created matching subscriptions, those messages will be delivered accordingly. Other messages will go to DLC queue once again.
...