Life cycle of a rule

Each stage in the life cycle of a rule can have multiple causes and effects. By writing and including expressions within life cycle actions (as defined by the <lifeCycleActions> element), a rule writer can define the actions to take at each stage.

Stages in the life cycle of a rule

Following are the four primary stages in the life cycle of a rule:
Load
The loading of the rule into the running Active Correlation Technology engine, which triggers the actions within the <onLoad> element.
Activation
The activation of the rule, which triggers the actions within the <onActivation> element.
Deactivation
The deactivation of the rule, which triggers the actions within the <onDeactivation> element.
Unload
The unloading of the rule from the running Active Correlation Technology engine, which triggers the actions within the <onUnload> element.

The activation and deactivation stages can occur multiple times in the life cycle of a rule, but the load and unload stages occur only once.

Typically, you do not need to define life cycle actions. Following are examples of when you might want to define a particular life cycle action:
  • When a certain rule is loaded, you might want to create a connection to an external system (such as a database manager) that needs to be accessed within that rule. When this same rule is unloaded, you want to drop the connection and run any necessary cleanup processes.
  • When a certain rule is activated, you might want to verify that certain resources are available to that rule.
  • When a threshold rule is deactivated but the threshold has not been met, and the time period is not yet over, you might want to forward a message to someone with this information.
Because the activation and deactivation of a rule can occur many times in the life cycle, any actions that you code for these stages can run frequently.

The causes and effects of each life cycle stage

Table 1 lists the causes and effects of each life cycle stage.

Table 1. Causes and effects of each life cycle stage
Life cycle stage Causes Effects
Load Any of the following circumstances:
  • A rule or rule block is added or replaced, which causes the new rule or rules to be loaded.
  • The rule set is replaced in the Active Correlation Technology engine, which causes the rules in the new rule set to be loaded.
The actions within the <onLoad> element run.
Activation The rule is activated. A rule can be activated in any of the following ways:
  • According to the definitions within the <activationInterval> element
  • Through the activate() method that is available through the act_lib variable
  • Through application calls to the activate() method in the Active Correlation Technology engine
If the rule is inactive, the actions within the <onActivation> element run.
Deactivation The rule is deactivated. A rule can be deactivated in any of the following ways:
  • According to the definitions within the <activationInterval> element, except that the <deactivateOnEvent> element within the <activationByGroupingKey> element does not cause rule deactivation
  • Through the deactivate() method that is available through the act_lib variable
  • Through application calls to the deactivate() method in the Active Correlation Technology engine
If the rule is active, the actions within the <onDeactivation> element run.
Unload Any of the following circumstances:
  • The Active Correlation Technology engine shuts down, which causes the rules to be unloaded.
  • A rule or rule block is removed or replaced, which causes the old rule or rules to be unloaded.
  • The rule set is removed from, or replaced in, the Active Correlation Technology engine, which causes the rules in the old rule set to be unloaded.
If the rule is active, the actions within the <onDeactivation> element run, followed by the actions within the <onUnload> element. Otherwise, only the actions within the <onUnload> element run.