Postponing the processing of events by using when has occurred
The clause when <event> has occurred <calendar duration> ago instructs the agent to postpone the processing of the event.
You use postponed processing if an event depends on other events, if the order in which the events are processed is important, or if an action must happen after a certain duration. You can also test the presence or absence of events.
In a rule that uses the clause when <event> has occurred <calendar duration> ago, the event that occurred is the reference event. The rule is not triggered upon the arrival of this event, but it is postponed by a fixed calendar duration. Each rule instance is applicable only once, when the condition that is expressed by the calendar duration is satisfied.
- The rule processes a single event in the when clause.
- The rule must contain a time expression with an implicit reference to now that is expressed by a calendar duration and ago, for example, 1 day ago or 2 hours 30 minutes ago. The time now represents the most recent time stamp of all the events received so far.
- The rule can contain a condition that tests the attributes or relationship of the event, and the attributes or relationships of the bound entity.
when a purchase event has occurred 1 hour 15 minutes ago
if the loyalty card amount of 'the customer' is more than 200
then ...
The following rule checks if the pizza order that was made 30 minutes before now is not delivered. If the order is not delivered, the order is late.
when a pizza order has occurred 30 minutes ago
if
the order status of 'the order' is not DELIVERED
then
make it true that 'the order' is late;