2.1 KiB
layout | title | header | prev_section | next_section | doc |
---|---|---|---|---|---|
docs | Rules engine | Rules engine | user-guide/defining-rules | user-guide/managing-rules | true |
Easy Rules engine holds a registry of rules with unique names. Each instance of Easy Rules engine can be seen as a separate namespace.
Rules are applied according to their natural order (which is priority by default).
Create a rules engine
To create a rules engine and register a rule, use the following snippet:
RulesEngine rulesEngine = aNewEngineBuilder().build();
rulesEngine.registerRule(myRule);
You can then fire registered rules as follows:
rulesEngine.fireRules();
Rules engine parameters
Easy Rules engine can be configured with the following parameters:
Parameter | Type | Required | Default |
---|---|---|---|
skipOnFirstAppliedRule | boolean | no | false |
skipOnFirstFailedRule | boolean | no | false |
rulePriorityThreshold | int | no | Integer.MAX_VALUE |
silentMode | boolean | no | false |
The skipOnFirstAppliedRule
parameter tells the engine to skip next rules when a rule is applied.
The skipOnFirstfailedRule
parameter tells the engine to skip next rules when a rule fails.
The rulePriorityThreshold
parameter tells the engine to skip next rules if priority exceeds the defined threshold.
Silent mode allows you to mute all loggers when needed.
You can specify these parameters through the RulesEngineBuilder API:
RulesEngine rulesEngine = aNewRulesEngine()
.withRulePriorityThreshold(10)
.withSkipOnFirstAppliedRule(true)
.withSkipOnFirstFailedRule(true)
.withSilentMode(true)
.build();