WebSphere WebSphere Enterprise Service Bus, Version 6.0.1 Operating Systems: AIX, HP-UX, Linux, Solaris, Windows

Writing event selectors

An event selector defines a set of events.

An event selector is a regular expression that defines a set of events based on their property data (attributes or sub-elements). For example, an event selector might specify all events from a particular host whose severity is greater than 30 (warning). Event selectors are used to define event groups, specify filter criteria, and query the event server.

Because the Common Base Event specification is based on XML, event selectors are written using a subset of XPath syntax. The specific syntax you can use for an event selector depends on how the event selector is to be used, as summarized by the following table.

Event selector purpose Syntax
Event group definition Limited to XPath subset supported by default data store plug-in
Event query and purge through event access interface Limited to XPath subset supported by default data store plug-in
Emitter filter configuration Any valid XPath
Subscription through Notification Helper interface Any valid XPath
Note: The default data store plug-in uses a subset of XPath syntax. However, if you are using a different data store plug-in, it might support a different subset of XPath. The event selectors you write for event group definitions and for the event access interface must use the syntax that is supported by your data store plug-in.

Writing XPath event selectors

XPath is a standard language used to identify parts of an XML document; for more information, see the XPath specification at http://www.w3.org/TR/xpath.

A simple XPath event selector that specifies an attribute value takes the following form:
CommonBaseEvent[@attribute = value]
The value can be either a numeric value or a string enclosed in single or double quotation marks.
You can also specify an attribute of a subelement:
CommonBaseEvent[/subelement/@attribute = value]

When using XPath operators, keep the following general rules in mind:

The following examples are valid XPath event selectors.

XPath event selectors Selector definition
CommonBaseEvent[@extensionName = 'ApplicationStarted'] All events with the extensionName attribute ApplicationStarted
CommonBaseEvent[sourceComponentId/ @location = "server1"] All events containing a sourceComponentId element with the location attribute server1
CommonBaseEvent[@severity] All events with a severity attribute, regardless of its value
CommonBaseEvent[@creationTime < '2003-12-10T12:00:00-05:00' and @severity > 30] All events created before noon EST on 10 December 2003 and with severity greater than 30 (warning):
CommonBaseEvent[contains(@msg, 'disk full')] All events with the phrase disk full occurring within the msg attribute
CommonBaseEvent[(@severity = 30 or @severity = 50) and @priority = 100] All events whose severity atrribute is equal to 30 or 50, and whose priority is equal to 100.

Writing event selectors for the default data store plug-in

If your event selector might be used to define an event group or to query the persistent data store, it is subject to the restrictions of the default data store plug-in. These restrictions are as follows:
  • An event property can be specified only on the left side of an operator or XPath function. The value on the right side of an operator must be a literal value. The following example is not a valid event selector:
    CommonBaseEvent[30 < @priority and 
                    contains('this message', @msg)]
    Instead, this could be rewritten as follows:
    CommonBaseEvent[@priority > 30 and 
                    contains(@msg, 'this message')]
  • Only the following XPath functions are supported:
    • contains
    • starts-with
    • false
    • true
    • not
  • The union operator (|) is not supported.
  • An event selector must take the following form:
    CommonBaseEvent[predicate_expression]
    Only a single predicate expression can be associated with the CommonBaseEvent element. Stacked predicates are not supported (for example, CommonBaseEvent[@extensionName = "server_down"][@severity = 10]).
  • A predicate can be only be associated with the last step of a location path. The following example is not a valid event selector:
    CommonBaseEvent[contextDataElement[@contextValue = "myContextValue"]
                    /@contextId = "myContextId"]
    Instead, this could be rewritten as follows:
    CommonBaseEvent[contextDataElement[@contextValue = "myContextValue" 
                    and @contextId = "myContextId"]]
  • If an event selector refers to properties of extended data elements that are at different levels of the XML containment hierarchy, these elements must be grouped together by level. The following example is not a valid event selector, because the references to the type and value attributes (both top-level) of extendedDataElements are separated:
    CommonBaseEvent[extendedDataElements[@type = 'int' and
                                         children/@type = 'intArray' and
                                         children/@name = 'myName' and
                                         @value = 10]]
    Instead, this could be rewritten as follows, grouping the top-level and second-level attributes together:
    CommonBaseEvent[extendedDataElements[@type = 'int' and
                                         @value = 10 and
                                         children/@type = 'intArray' and
                                         children/@type = 'myName']]
  • Node indexes are not supported (for example, CommonBaseEvent[extendedDataElements[1]]).
  • Wildcard characters are not supported (for example, CommonBaseEvent[extendedDataElements/*/children/values = "text"]).
  • When referring to the values property of an extended data element, you must specify not only the value but also the type of the property:
    CommonBaseEvent[extendedDataElements[values = "myVal" 
      and @type = "string"]]
    You can specify the type for multiple comparisons within a compound expression by grouping them with parentheses:
    CommonBaseEvent[extendedDataElements[(values = "myVal" or 
                                          values = "yourVal") and
                                          @type = "string"]]
    In this example, the type expression applies to both parts of the compound expression in parentheses. You cannot override this by specifying a different type expression inside the parentheses.
    You can also group together multiple related types by using the starts-with or contains functions. For example, the following expression would match a property with either the string or stringArray type:
    CommonBaseEvent[extendedDataElements[values = "myVal" and
                                         starts-with(@type, 'string')]]

Concept topic

Terms of Use | Rate this page

Timestamp iconLast updated: 13 Dec 2005
http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.websphere.wesb.doc\doc\ccei_adminCBEB_eventselector.html

(C) Copyright IBM Corporation 2005. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)