<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Different mechanism of loading rule between Designer and Engine</title><link>https://answers.axonivy.com/questions/2742/different-mechanism-of-loading-rule-between-designer-and-engine</link><description>&lt;p&gt;Hi all&lt;/p&gt;
&lt;p&gt;I have a project that using api &lt;em&gt;ivy.rules.engine&lt;/em&gt; to execute Drool rule, i just found a difference between Designer and Engine about the way it load rule package.&lt;/p&gt;
&lt;p&gt;Here is folder rule i have:
&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/Untitled_RkIO6RW.png"&gt;&lt;/p&gt;
&lt;p&gt;I have two main folders: &lt;em&gt;salaryReference&lt;/em&gt; and &lt;em&gt;salaryCalculation&lt;/em&gt;, each of them has a child package called &lt;em&gt;demo&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;Here is the code that i load those rule bases:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;//salaryRuleBase and basicSalaryRuleBase are IRuleBase type

in.salaryRuleBase = ivy.rules.engine.createRuleBase();
in.salaryRuleBase.loadRulesFromNamespace("salaryCalculation");

in.basicSalaryRuleBase = ivy.rules.engine.createRuleBase();
in.basicSalaryRuleBase.loadRulesFromNamespace("salaryReference");
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Those two rule base only need to load main package (not childs). To be sure that it load correct package, i put two test rules on child packages, ex:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import ch.ivyteam.ivy.environment.Ivy;

rule "SalaryCal.demo"
when
then
    Ivy.log().info("=========Rule SalaryCal.demo");
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import ch.ivyteam.ivy.environment.Ivy;

rule "SalaryRef.demo"
when
then
    Ivy.log().info("=========Rule SalaryRef.demo");
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When executing this code on Designer (Axon ivy 6.3.0.52421), it work exactly as i want. only rules from &lt;em&gt;salaryCalculation/basic.drl&lt;/em&gt; and &lt;em&gt;salaryReference/default.drl&lt;/em&gt; are loaded and executed. I don't see any logs from test rules. &lt;/p&gt;
&lt;p&gt;But when i deploy this project to server(same version with Designer) , i saw this line:
&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/Untitled_iNiDG64.png"&gt;&lt;/p&gt;
&lt;p&gt;That a big trouble in our real project because we separate rule by packages and somehow expect rule engine will only load package that we set to them, non recursively. &lt;/p&gt;
&lt;p&gt;Do you know why do we have this difference? it's quite confused and strange to us&lt;/p&gt;
&lt;p&gt;&lt;a href="https://drive.google.com/file/d/0B6qldkZvvHgHRWM5X1dWb1VvM1k/view?usp=sharing"&gt;Here&lt;/a&gt; is demo project if you want to try it out&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2742/different-mechanism-of-loading-rule-between-designer-and-engine" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 19 Jul 2017 04:09:22 -0400</lastBuildDate><item><title>Answer by nghia-tran</title><link>https://answers.axonivy.com/questions/2742/different-mechanism-of-loading-rule-between-designer-and-engine/2772</link><description>&lt;p&gt;Hi Trung,&lt;/p&gt;
&lt;p&gt;We created a ticket for your issue. We will investigate the problem as soon as possible. If this is a real issue, then it will be fixed in one of the next releases (currently the issue is put into version 7.0 backlog). If we cannot reproduce this issue on our environment. We will come back to you with more information.&lt;/p&gt;
&lt;p&gt;In the mean time, you can continue with your workaround by separating the namespaces.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nghia-tran</dc:creator><pubDate>Wed, 19 Jul 2017 04:09:22 -0400</pubDate><guid>https://answers.axonivy.com/questions/2742/different-mechanism-of-loading-rule-between-designer-and-engine/2772</guid></item></channel></rss>