Apama 10.7.2 | Developing Apama Applications | Developing Apama Applications in EPL | Defining Event Listeners | Specifying and/or/not logic in event listeners | Example event expressions using 'and/or' logic in event listeners
 
Example event expressions using 'and/or' logic in event listeners
The following example event expressions indicate a few patterns that can be expressed by using and/or logic in event listeners.
Event Expression
Description
A -> (B or C)
Match on an A followed by either a B or a C.
(A -> B) or C
Match on either the pattern A followed by a B, or just a C on its own.
A -> ((B -> C) or (C -> D))
Find an A first, and then seek for either the pattern B followed by a C or C followed by a D. The latter patterns will be looked for concurrently, but the monitor will match upon the first complete pattern that occurs. This is because the or operator treats its operands atomically, that is, in this case it is looking for the patterns themselves rather than their constituent events.
(A -> B) and (C -> D)
Find the pattern A followed by a B (that is, A -> B) followed by the pattern C -> D, or else the pattern C -> D followed by the pattern A -> B. The and operator treats its operands atomically. That is, in this case it is looking for the patterns themselves and the order of their occurrence, rather than their constituent events. It does not matter when a pattern starts but it occurs when the last event in it is matched. Therefore {A',C',B',D'} would match the specification, because it contains an A -> B followed by a C -> D. In fact, the specification would match against either of the following patterns of event instances; {A',C',B',D'}, {C',A',B',D'}, {A',B',C',D'}, {C',A',D',B'}, {A',C',D',B'} and {C',D',A',B'}