Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Common EPL Patterns in Monitors | Testing uniqueness
 
Testing uniqueness
The events:
event OrderKey{...}
event NewOrder {
   OrderKey key; //You can use anything for key as long as it is unique
   ...
}
event ValidNewOrder {
   NewOrder order;
}
The monitors:
monitor OrderFilter {
   dictionary < OrderKey, NewOrder > orders;
   action onload() {
      on all NewOrder() as order validateOrder(order);
   }
   action validateOrder(NewOrder order){
      if orders.hasKey(order.key) {
         print "Duplicate order!"
         print "Original: " + orders[order.key].ToString();
         print "Incoming: " + order.ToString();
      }
      else {
         orders.add(order.key,order);
         route validNewOrder(order);
      }
   }
}
 
monitor OrderProcessor {
...
   action onload() {
      on all ValidNewOrder() as valid spawn processOrder(valid.order);
   }
   action processOrder( NewOrder order ) {
   ...
   }
}

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.