Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in Java | Overview of Apama JMon Applications | About event listeners and match listeners | Defining multiple listeners
Defining multiple listeners
A monitor can define any number of event expressions, and create any number of listeners. The following code,
public void onLoad() {
   EventExpression eventExpr1 = new EventExpression("Tick(*, >10.0)");
   EventExpression eventExpr2 =
     new EventExpression("NewsItem(\"ACME\", *)");
is creating two event expressions, eventExpr1 and eventExpr2. Then each is assigned a match listener, thus activating two distinct listeners. The fact that both are being assigned the same match listener object, i.e. this same object this, is inconsequential. It just means that the same method, the match method of this object, will be called when the correlator detects either of the event expressions.
As already described, creating a listener is an asynchronous operation that returns immediately. In the above code, in practice both listeners are created concurrently. It is not possible for the eventExpr1 listener to trigger before the eventExpr2 listener is created. However, once the enclosing method's code has completed execution, the listeners can trigger at any time, and independently of each other.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.