rule "Calculate Business profit,1"
salience 1000
no-loop true
when
emi : EMIAgainstProperty ( businessProfit2 > (businessProfit1 * 1.5) )
then
modifyRetract(emi);
emi.setBusinessProfit((emi.getBusinessProfit1()+emi.getBusinessProfit2())/2);
modifyInsert(emi);
end
rule "Calculate Business profit,2"
salience 999
no-loop true
when
emi : EMIAgainstProperty ( businessProfit2 <= (businessProfit1 * 1.5) )
then
modifyRetract(emi);
emi.setBusinessProfit(emi.getBusinessProfit2());
modifyInsert(emi);
end
rule "Calculate AIC"
salience 998
no-loop true
when
emi: EMIAgainstProperty( businessProfit > ( businessProfit1 * 2) )
then
System.out.println(" AIC "+emi.getBusinessProfit());
modifyRetract(emi);
emi.setAIC(emi.getBusinessProfit1()*2);
modifyInsert(emi);
end
rule "Calculate AIC1"
no-loop true
salience 997
when
emi: EMIAgainstProperty( businessProfit <= ( businessProfit1 * 2) )
then
modifyRetract(emi);
System.out.println
(" AIC Less "+emi.getBusinessProfit());
emi.setAIC(emi.getBusinessProfit());
modifyInsert(emi);
end
Natraj,
You mean modifying twice inside the same rule consequence?
There should be no problem in modifying a fact twice inside the same consequence besides wasted effort, so if you are going into an infinite loop, that is a bug. Would you please open a JIRA with a test case showing the problem? Having said that, there is no reason to modify a fact twice inside the same consequence block, so if that is the case, you may also check your code again.
Now, if you are talking about modifying a fact in the consequence of 2 different rules, then you need to verify if your modification is not causing rules to be reevaluated and fired in loops, what is possible to happen and you need to fix your rules to avoid that.
[]s
Edson
2007/7/19, Natraj Gudla <natraj.forums@gmail.com>:Hello All,Has anyone faced a situation where a fact gets modified more than once within a given DRL. The modification is required so that the other rules properly fire based on the consequence of the earlier.I am able to get through the modifyRetract() and modifyInsert() once in a rule consequence, but the second time i do it, it goes into an infinite loop and results in out of memory.Why is it that i cant modify the object more than once. In such a case, how to deal with business scenarios which need this.Also, is it possible to handle the execution of another DRL within one DRL.ThanksNatraj Gudla
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users