Stopping a rule task
You can interrupt a rule task when a specific state is reached.
You can add a final stop command in the action part of a business rule to avoid evaluating the other rules in a task (see the bottom section How to use the stop in rule actions).
For example, a rule task determines whether a loan application should be rejected. Each rule
condition detects a rejection case and all the rules have the following
form:
if [condition for rejection]
then
reject the loan;Calling the stop command ends the processing with the first rejection.
The remaining rules are not run, which can save processing time.Stopping the execution of rules in a rule task
You can call stop command in the actions of a rule. This triggers the following actions:
- The rule action stops. The subsequent statements in the rule action are not executed.
- The other rules in the same task node are not executed.
- The final action of the task is executed and execution of the ruleflow continues.
How to use the stop in rule actions
The stop command is available in the RunningEngine Java API (see the RunningEngine interface section in Rule Designer API).
It is available in ARL, but it is not a keyword from BAL. To be able to use it in a rule in BAL, you must declare its verbalization and BOM-to-XOM mapping in the BOM.
Define a stop method in the BOM as follows:
- Static
- Implementation (BOM-to-XOM mapping):
stop(““);
To use it in a rule in BAL, add the following code:
then
note(“Stopping the task now”);
stop;