Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuleUnit Running Rule From Different Rule Unit #6197

Open
piacenti opened this issue Dec 14, 2024 · 2 comments
Open

RuleUnit Running Rule From Different Rule Unit #6197

piacenti opened this issue Dec 14, 2024 · 2 comments

Comments

@piacenti
Copy link

piacenti commented Dec 14, 2024

I have a situation where when running RuleUnit X it evaluates a rule from RuleUnit Y. When I run RuleUnit Y the same rule fires again so I end up with some duplicate data. The project is large so it would be hard to share the scenario. The generated LambdaPredicates predicateInformation method does mention rules from both rule units as consumers of that logic which includes the impacted rule. The odd thing is that the reverse doesn't happen. Evaluation of RuleUnit Y for that specific rule doesn't cause an evaluation of the RuleUnit X rule that uses that same logic. I've seen this issue for a few rules at this point. I am having to use from statements in those rules to deal with things I can't with OOPath, generally related to heavily dependent on methods logic.

I'm using Drools version 9.44.0.Final. Also RuleUnit X and RuleUnit Y both share the same model so they are implemented as a base class that contains all the store fields and the individual units simply extend that base

flowchart TD
    Base[Base Implementing RuleUnitData] --> RuleUnitX
    Base --> RuleUnitY
Loading

hence the very similar logic for a certain condition across units.

Edit:
The details around logic shared between rules of different units was just speculation. However, I found a rule that is having the same behavior which shares no logic with any other unit and yet it fires when evaluating a unit it doesn't belong to. Could sharing DataStores between units cause this? I've tried recreating them with new instances every time but the problem doesn't seem to change.

When I look into the elements of the InternalAgendaGroup to be evaluated for RuleUnit X I see many rules for RuleUnit Y listed so something seems to be wrong with the instance creation process.

@piacenti
Copy link
Author

I also see the same behavior with version 10.0.0

@piacenti
Copy link
Author

piacenti commented Dec 31, 2024

The problem goes away if I separate each drl rule unit file into a separate maven module for separate builds. So it seems something is not quite right when processing multiple rule unit drl files in the same folder in the same project at least for my case where each contain thousands of rules.

Also I found that trying to do multiple executions of the plugin each to deal with one of the affected drl files simply doesn't work. It seems that the kie-maven-plugin ignores configurations specifying resource folders to scan and instead use a hard coded static final String RESOURCES_ROOT = "src/main/resources/"; in the KieBuilderImpl class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant