Pattern Matching Examples
Some pattern matching example helps to understand pattern matching better.
Simple Correlation
Collects Order and Fulfillment events based on their Customer IDs.
define pattern /OrderTracker using /Order as order and /Fulfillment as fulfillment with order.customerId and fulfillment.customerId starts with order then fulfillment
Simple Temporal Correlation
Collects Order and Fulfillment events based on their Customer IDs such that Fulfillment occurs within 10 minutes of placing the order.
define pattern /OrderFullfilmentSLA using /Order as order and /Fulfillment as fulfillment with order.customerId and fulfillment.customerId starts with order then within 10 minutes fulfillment
A pattern instance is created when the Order event arrives. If a corresponding Fulfillment event does not follow within 10 minutes of the Order event, then the Failure listener is triggered. If the event does arrive on time, then the Success listener is invoked.
Duplicate Suppression – Store and Forward
Collects related events of the same type that share the same correlation ID.
define pattern /ShipmentAggregator using /Shipment as shipment with shipment.destinationState starts with shipment then within 2 hours repeat 0 to 49 times shipment
This pattern aggregates at most 50 Shipment events within a span of two hours. it uses the event's destinationState as the correlation property. When the first shipment event arrives, the pattern instance is created. Then the timer starts and the pattern instance waits for two hours, accumulating a maximum of 49 more shipment events.