Actually I think you do not need to call update at all. The object model has been modified, it is just that you will not trigger a deletion-reinsertion into the Working Memory. However the client that inserted the object model initially will be able to see the new value of the field message. Not calling update, you do not have to worry about any of the rules being executed again. The only thing I do not understand here is, if you want your rules to overwrite the message that was potentially changed by a rule that was previously executed. Because this is what is going to happen with the way the rules are right now. Or maybe you want them to accumulate, so that after all rules ran, the client has a list of all messages.
--- On Thu, 1/15/09, [email protected] <[email protected]> wrote: From: [email protected] <[email protected]> Subject: rules-dev Digest, Vol 25, Issue 8 To: [email protected] Date: Thursday, January 15, 2009, 11:00 AM Send rules-dev mailing list submissions to [email protected] To subscribe or unsubscribe via the World Wide Web, visit https://lists.jboss.org/mailman/listinfo/rules-dev or, via email, send a message with subject or body 'help' to [email protected] You can reach the person managing the list at [email protected] When replying, please edit your Subject line so it is more specific than "Re: Contents of rules-dev digest..." Today's Topics: 1. Need to Exit from DRL without using drools.halt() (Sarath Kumar Daruru) 2. RE: Need to Exit from DRL without using drools.halt() (Anstis, Michael (M.)) ---------------------------------------------------------------------- Message: 1 Date: Thu, 15 Jan 2009 15:36:06 +0530 From: Sarath Kumar Daruru <[email protected]> Subject: [rules-dev] Need to Exit from DRL without using drools.halt() To: "'[email protected]'" <[email protected]> Message-ID: <73c89fca1ca6c14e9dfc31575b11f7813287f10...@mshbaclmx.blueally.org> Content-Type: text/plain; charset="us-ascii" Hi All, I have small doubt in the DRL file execution. I have developing the small Claims application. I have 4 rules in my application. Below are the rules I have declared in the drl file based on the rules. Claims.drl rule "Amount Validation-Rule1" when $c : Claims(amount >= ( maxClaimAmount) ) then $c.setMessage ( "The total amount claimed exceeds the maximum permitted by the Policy" ); update($c); end rule "Expired Policy-Rule2" when $c : Claims( currentDate > ( policyExpireDate )) then $c.setMessage( "Your Policy has been expired" ); update($c); end rule "Feature Date-Rule3" when $c : Claims( claimDate >= ( currentDate ) ) then $c.setMessage( "Rejecting the claim because the date on the claim is in the future" ); update($c); end and my java class is Claims.java // Setting the values to Claims object Claims rule = new Claims (); rule.setAmount(amount); rule.setClaimsHospitalStayeddays(claimsHospitalStayeddays); rule.setClaimDate(claimDate); rule.setCurrentDate(currentDate); rule.setDaysPermitted(daysPermitted); rule.setPolicyExpireDate(policyExpireDate); rule.setCurrentDate(currentDate); rule.setMaxClaimAmount(maxClaimAmount); StatefulSession workingMemory = ruleBase.newStatefulSession(); workingMemory.insert(rule); workingMemory.fireAllRules(); If my first rule is fails then it is displaining in the messaege I managed to get that value in my java class. If the condition is not satisfied then is fell into the infinte loop. Again and again it is calling, not coming from that loop. If I keep the drools.halt(); at the end of the rule then it is executing. My question - Is there any alternate method is there to come out from infinte loop without using drools.halt(); method? Why it is fell into the infinite loop? Thanks, Sarath Kumar Daruru -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20090115/b3565256/attachment-0001.html ------------------------------ Message: 2 Date: Thu, 15 Jan 2009 10:44:27 -0000 From: "Anstis, Michael (M.)" <[email protected]> Subject: RE: [rules-dev] Need to Exit from DRL without using drools.halt() To: "Rules Dev List" <[email protected]> Message-ID: <[email protected]> Content-Type: text/plain; charset="us-ascii" You could simply add a "processed" flag and change your rules... rule "Amount Validation-Rule1" when $c : Claims(amount >= ( maxClaimAmount), processed = false ) then $c.setMessage ( "The total amount claimed exceeds the maximum permitted by the Policy" ); $c.setProcessed(true); update($c); end Otherwise the updates are causing the fact to be re-accessed by the RETE network. Alternatively you could use a ClaimOutcome object... rule "Amount Validation-Rule1" when $c : Claims(amount >= ( maxClaimAmount)) not ClaimOutcome(claim = $c) then ClaimOutcome co = new ClaimOutcome($c, "The total amount claimed exceeds the maximum permitted by the Policy" ); insert(co); end With kind regards, Mike ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Sarath Kumar Daruru Sent: 15 January 2009 10:06 To: '[email protected]' Subject: [rules-dev] Need to Exit from DRL without using drools.halt() Hi All, I have small doubt in the DRL file execution. I have developing the small Claims application. I have 4 rules in my application. Below are the rules I have declared in the drl file based on the rules. Claims.drl rule "Amount Validation-Rule1" when $c : Claims(amount >= ( maxClaimAmount) ) then $c.setMessage ( "The total amount claimed exceeds the maximum permitted by the Policy" ); update($c); end rule "Expired Policy-Rule2" when $c : Claims( currentDate > ( policyExpireDate )) then $c.setMessage( "Your Policy has been expired" ); update($c); end rule "Feature Date-Rule3" when $c : Claims( claimDate >= ( currentDate ) ) then $c.setMessage( "Rejecting the claim because the date on the claim is in the future" ); update($c); end and my java class is Claims.java // Setting the values to Claims object Claims rule = new Claims (); rule.setAmount(amount); rule.setClaimsHospitalStayeddays(claimsHospitalStayeddays); rule.setClaimDate(claimDate); rule.setCurrentDate(currentDate); rule.setDaysPermitted(daysPermitted); rule.setPolicyExpireDate(policyExpireDate); rule.setCurrentDate(currentDate); rule.setMaxClaimAmount(maxClaimAmount); StatefulSession workingMemory = ruleBase.newStatefulSession(); workingMemory.insert(rule); workingMemory.fireAllRules(); If my first rule is fails then it is displaining in the messaege I managed to get that value in my java class. If the condition is not satisfied then is fell into the infinte loop. Again and again it is calling, not coming from that loop. If I keep the drools.halt(); at the end of the rule then it is executing. My question - Is there any alternate method is there to come out from infinte loop without using drools.halt(); method? Why it is fell into the infinite loop? Thanks, Sarath Kumar Daruru -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20090115/b72523c8/attachment-0001.html ------------------------------ _______________________________________________ rules-dev mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-dev End of rules-dev Digest, Vol 25, Issue 8 ****************************************
_______________________________________________ rules-dev mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-dev
