Updating rules in Business Central affects execution of those rules which are extended from one another
Issue
- The following rules are defined in
Business CentralofBRMS 6where they extend one another. e.g.Rule AextendsRule BandRule BextendsRule C. Users build and deploy the rules toBRMS maven repositoryso that the resultantkjarcan be used to execute it;s consituent rules from a client application. Now the application which is executing the rules from thekjarinsideBRMS maven repositoryis also runningKieScannerwith some predefined interval for scanning the updated version of thekjarto ensure the latest version of thekjaris loaded by the application. ThisKieScannernow picks up the latest deployed ruleskjarversion which hasRule A, extendingRule B,Rule BextendingRule C. -
The rules are updated in the
Business Centralapplication and thekjaris also built as and when the latest rules are required to be run by the client application. For the first time when the application first executes the rules fromkjareverything works fine and in order. Now when the application is executing the rules after the rules and thekjaris updated the execution results show some weird behavior.- Sometimes
Rule BandRule Cfire butRule Adoesn't even though all conditions are met. - Sometimes
Rule AandRule Cfire butRule Bdoesn't.
It is confirmed that the input facts inserted intoksessionbased on which the rules should fire are correct and it should ideally fire all three rules, because once the application and it's JVM is restarted it starts working fine again.
- Sometimes
-
Some observations for the pattern of this issue are given below.
- This happens only if the client application is running with the
KieScannerAPI to pick up the latest deployed rules version. If user restarts JVM then all the rules fire fine. - Issue occurs only if the rules have more than one level of
inheritance. If rules are modified so that they have only one level of inheritance likeRule AextendsRule B(i.e.Rule Bwon't extendRule Cfurther) then also rule execution is fine withKieScanneras well.
- This happens only if the client application is running with the
-
Suppose there are two rules where the second one extends the first one.
test rule 2
package org.drools.test;
import org.drools.Cheese;
rule "test rule 2" extends "test rule 1"
when
Cheese( price <= 6) from c
then
System.out.println(" ****** Printing from rule 'test rule 2' ****** ");
end
test rule 1
package org.drools.test;
import org.drools.Cheese;
rule "test rule 1"
when
c: Cheese( type == "hilton" )
then
System.out.println(" ****** Printing from rule 'test rule 1' ****** ");
end
These rules are drafted in Business Central and build&deploy the project there to create the kjars. Now an application code is used to test these rules using KieScanner API to look for changes made to the rules from time to time, and the application keeps on running the rules at a scheduled interval. If the application fires the rules for the first time with a fact which matches both the above rules, the results
are favorable.
****** Printing from rule 'test rule 2' ******
****** Printing from rule 'test rule 1' ******
Now if user makes a change to test rule 2 in such a way that it should not be executed. User saves the rules and build&deploy the project in Business Central. Now, KieScanner picks up the updated kjar containing the updated rule but it is observed that the application no longer longer runs the test rule 2 rule. But surprisingly the test rule 1 still gets executed.
****** Printing from rule 'test rule 1' ******
Now user updates the RHS of the test rule 1 rule in such a way that it does not put any effect on LHS.
test rule 1
package org.drools.test;
import org.drools.Cheese;
rule "test rule 1"
when
c: Cheese( type == "hilton" )
then
System.out.println(" &&&&&&& Printing from rule 'test rule 1' &&&&&&& ");
end
This time user no longer sees the test rule 1 even getting fired in the application code.
- Are the rules' inheritance designed and authored in correct way, when
Rule AextendsRule BandRule BextendsRule C? - Are there any specific guidelines around
Rule Inheritancewhich users should take care of in such a case to avoid this kind of issue? - Are there any workarounds for this issue?
- What could the root cause behind this issue?
Environment
- Red Hat JBoss BRMS (BRMS)
- 6.1
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
