liveBook · Manning

Filter expression

As explained in Event Processing in Action

An expression that determines whether an event instance is selected or excluded, or cannot be evaluated.

A filter expression is a predicate evaluated against an event. An event passes when the predicate is true and fails when it is false; in some cases, the expression cannot be evaluated. section 8.1.1 section 6.2.3

On an input terminal, a filter admits only events that pass. The accepted event-type list is itself a filter; additional expressions can test event attributes. Terminal filtering is stateless: filtering one event does not affect how later events are filtered. section 5.1.3 section 8.1.2

Selecting events

A filter described as “allow only triangle and square events” selects those events and excludes other shapes. A more formal XPath expression, /ranking > 5, tests an event’s ranking against a constant. section 8.1.1

Table 8.1. Features typically found in filter expressions

Feature

Interpretation

Attribute inclusion Checks whether the event instance contains an attribute with that name
Attribute has value Checks that the value of the attribute is not null
Data type assertion Checks that the attribute’s value is valid with respect to its data type, for example, that it is valid as a number, string or timestamp
Binary relation Tests the value of an attribute against a constant or against the value of another attribute, using a relation such as <, >, =, ≠, ≤, or ≥
Conjunction Expression is the conjunction ("AND") of two or more expressions
Disjunction Expression is the disjunction ("OR") of two or more expressions
Negation Expression is the negation of another expression

Common expression features include attribute checks, comparisons, AND, OR, and negation. section 8.1.1

Keeping a filter on the input terminal separates the selection rule from the consumer or agent’s other behavior. The filter can potentially be performed by a channel or producer. A distribution protocol may also let a consumer supply a filter, allowing a channel to combine consumer filters and filter earlier. section 8.1.1 section 5.3.2

A Filter event processing agent adds a main filtering step after any input-terminal filter. It routes events to Filtered-in when they satisfy the expression, Filtered-out when they do not, and Non-filterable when the expression cannot be evaluated. Unconnected outputs discard their events. Unlike terminal filters, filtering within an agent can be stateful, and events that fail can continue to be processed. section 8.1.2 section 6.2.3

Figure 6.7. The Filter EPA showing the Input terminal and three output terminals

The Filter agent’s three outputs make the distinction between failed and non-filterable events visible. section 6.2.3

How Event Processing in Action covers it

How deep it goes
Defines predicate outcomes and common expression features, then distinguishes stateless terminal filtering from filtering within an agent.
Examples
Illustrates selection with geometric event shapes and XPath comparisons, including a ranking threshold.
What you can do after
Evaluate and understand where to place filters and how their outcomes affect event routing.
How it connects
Connects filtering with event types, event attributes, event processing agents, and event distribution channels.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Event Processing in Action. The section links point to the parts of the book it draws on.