What is a Rule?
A rule is a directive to guide or influence a process behaviour and is a key concept of an Event driven architecture.
A rule consists of a conditional expression that is specified using the attributes defined in a corresponding event structure and a rule action that takes place when the rule condition is satisfied by an instance of the event structure.
Event management policies define how an event instance is handled once the rule action is executed. This, in a nutshell, describes how a typical rules-based system works.
Typically, rules follow Event-Condition-Action (ECA) rule semantics where an event happens and if a rule condition evaluates to true for this event, then some prescribed action is performed. The ECA components are defined as:
- Event – the state information for the process
- Condition – the Boolean condition that evaluates to true or false for the event
- Action – the action to be carried out if the rule condition evaluates to true for the event
Standard Notation
The standard notation for ECA rules is:
ON <event structure>
IF <condition>
THEN <action>
where:
- the ON clause identifies the event structure for which the rule is defined,
- the IF clause specifies the rule condition,
- and the THEN clause specifies the rule action.
Example
An example of a rule is the following: If a customer chose to fly Abcair Airlines to Orlando and if his stay in Orlando is more than 7 days, then offer an Acar rental car promotion to him. Using the ECA notation, this rule is:
ON
AddFlight (Custid, Airline, FromCity, ToCity, Depart, Return)
IF
Airline = 'Abcair' and ToCity = 'Orlando' and Return-Depart >= 7
THEN
OfferPromotion (CustId, 'RenralCar', 'Acar')
where:
- The ON structure identifies the event structure for this rule.
- The IF clause defines the rule condition using variables in the event structure.
- The THEN clause defines the commands that represent the action for this rule.