Filtering the message content of publications

Rather than receiving all messages on a topic to which you have subscribed, your consuming application can use XML Path (XPath) selectors to filter the messages based upon the contents of each message. This content-based subscription gives greater flexibility in defining the type of information that you want to receive, your applications can use it to avoid responsibility for their own filtering, and it improves performance by not flowing messages unnecessarily from the server to the application.

About this task

The WS-Notification publish and subscribe messaging model is topic-based. Each publication is classified as belonging to one of a fixed set of topics. Publishers label each publication with a topic name and consumers subscribe to all publications on a particular topic. For example a stock trading notification system might define a topic for each issue: Publishers post information labeled with the appropriate issue as the topic name, and subscribers subscribe to information regarding some issue.

You can use XPath selectors to filter messages for a given topic, by using a Boolean expression that is evaluated over the XML message content of the message body. For example, a subscriber to a topic-based publish and subscribe system for stock trading might use XPath selectors to specify constraints against three message attributes at the same time:
  • issue name
  • price
  • volume of shares
The resultant Boolean statement might be as follows:
(issue="IBM") and (price<120) and (volume>1000)

You code your XPath 1.0 message content filters in the subscribing applications, by using XML Path (XPath) language, Version 1.0..

Note: If your subscriber applications use message content filtering, and are coded to specify the XPath Version 1.0 SelectorDomain, they can also filter publications from other WS-Notification providers that are of type JMS TextMessage or BytesMessage. For more information about these JMS message types, see Sharing event notification messages with other bus client applications.

To filter the message content of publications by using XPath selectors, complete the following steps:

Procedure

  1. Create a new application that subscribes a WS-Notification consumer.
  2. Code an XPath message content filter in the subscribing application. For example code for doing this, see Example: Subscribing a WS-Notification consumer. For an example of message content filter usage, see Example: Matching a WS-Notification publication and subscription through a message content filter.
  3. Code error handling for cases where the filter is not valid.
  4. Invoke the application.
Task topic    

Terms of Use | Feedback

Last updated: Oct 21, 2010 5:30:17 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=compass&product=was-nd-iseries&topic=tjwsn_task_adev_xpath
File name: tjwsn_task_adev_xpath.html