Param N C
Param N C

Reputation: 37

Order of execution of Rules by Drools Engine?

I have situation where all the rules in the rule files has to checked for an execution. If my understanding is correct what document says is rules will be executed by by engine arbitrarily .

Question or Doubts I have are .

  1. Why all rules are getting executed sequentially irrespective when I am executing them and no matter how many times.
    And I am not using any salience or other feature to achieve this.

  2. And I got an answers in many places I must use the salience feature to execute them in an order . If I use the salience and I have requirement of executing all the rules , will it really hit the performance in large scale. If yes, How it could affect the performance,even Rule Engine is also going to execute all rules arbitrarily say some random order.

Thanks in advance.

Upvotes: 1

Views: 4337

Answers (1)

laune
laune

Reputation: 31290

Rules where all patterns and constraints match are executed in an unspecified order except when salience requires firings to occur according to these values.

Rule firing is not randomized and may, therefore, appear to be sequential in the order they are written on some DRL file.

Using salience doesn't affect performance noticeably. The salience value is observed while entering rule in a linked list ("agenda") and you can read that code to convince yourself.

Using salience, however, should not be considered unless there is a good reason. Frequently it is a sign of poor understanding of the paradigm of logic programming.

Upvotes: 2

Related Questions