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() {
      NewOrder order;
      on all NewOrder():order validateOrder(order);
   }
   action validateOrder(NewOrder order){
      if orders.hasKey(order.key) then{
         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() {
      ValidNewOrder valid;
      on all ValidNewOrder():valid spawn processOrder(valid.order);
   }
   action processOrder( NewOrder order ) {
   ...
   }
}
Copyright © 2013-2015 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.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.