Versions Compared

Key

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

Message selectors allow you to filter specific messages using a selector string. The message consumer will then receive only messages whose headers and properties match the selector. There are different patterns that can be used in selector strings, 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. See the list of supported message types and header fields in WSO2 MB.

Note

Note that message selectors are not supported in a clustered setup of WSO2 Message Broker (WSO2 MB).

Using message headers as selector criteria

A message header contains a number of predefined fields that contain values that both clients and providers can use to identify and to route messages. Following is a list . See the list of supported message types and header fields in WSO2 MB.

The following are examples of message header selector strings that are supported:

...

  • JMSDeliveryMode
  • JMSExpiration
  • JMSPriority
  • JMSRedelivered

...

Using message properties as selector criteria

If you need values in addition to those provided by the header fields, you can create and set properties for the messages.Following  See the list of supported message types and header fields in WSO2 MB.

The following is a list of message property selector strings that are supported:

...

Creating a message selector subscription

The createConsumer and  and createDurableSubscriber methods allow you to specify a message selector as an argument when you create a message consumer.

You can create a message selector subscriber for a topic as shown in the following example:example given below. Note that the nolocal parameter is set to 'false' as it is not supported by WSO2 MB. However, messages will be delivered to the subscriber irrespective of the nolocal parameter.

Code Block
String messgeSelector="JMSType='AAAA'"; 
topicSession.createSubscriber(topic,messgeSelector,true)

...

false)