Use message selectors

 

We can use message selectors to filter out messages that do not satisfy given criteria. For details about message selectors, see Message selectors. Message selectors are associated with a subscriber as follows:

// Associate a message selector with a non-durable subscriber
String selector = "company = 'IBM'";
TopicSubscriber sub = session.createSubscriber( topic, selector, false );

We can control whether the JMS client or the broker performs message filtering by setting the MessageSelection property on the TopicConnectionFactory. If the broker is capable of performing message selection, it is generally preferable to let the broker do it because it reduces the number of messages sent to your client. However, if the broker is very heavily loaded, it might be preferable to let the client perform message selection instead.


uj24800_