!--a11y-->
Many applications need to filter and separate the messages that are received into different categories, depending on the application requirements. In such cases, you can use the JMS message selection, which allows the application to get only those messages that contain specific information, and to reject the messages that are useless for the application. When you have messages that are sent to many clients, the message selection criteria can be put in the header of the message. Then the JMS provider can handle a lot of the filtration work, and in this way can let the application work smoothly. Otherwise, if message selection is not used, then this job must be performed by the application itself.
You attach the specific criteria for the message selection using the message properties and specify the message selection criteria using the JMS message selection expressions.
For more information about the message selector syntax, see JMS Specification.

String selector; selector = new String((name = “searched_string”) OR (name = “another_searched_string”)); |
· When you use the Queue connection, the message consumer creation looks as follows:

subscriber = topicSession.createSubscriber(topic, selector); |
· When you use the Queue connection, the message consumer creation looks as follows:

receiver = queueSession.createReceiver(queue, selector); |
The messages received by the application now contain the specified data in the message.
For an example, see Using Message Filters.
