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, rules-dev-request@lists.jboss.org <rules-dev-request@lists.jboss.org> wrote:
From: rules-dev-request@lists.jboss.org <rules-dev-request@lists.jboss.org>
Subject: rules-dev Digest, Vol 25, Issue 8
To: rules-dev@lists.jboss.org
Date: Thursday, January 15, 2009, 11:00 AM

Send rules-dev mailing list submissions to
	rules-dev@lists.jboss.org

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
	rules-dev-request@lists.jboss.org

You can reach the person managing the list at
	rules-dev-owner@lists.jboss.org

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 <sarathd@blueally.com>
Subject: [rules-dev] Need to Exit from DRL without using drools.halt()
To: "'rules-dev@lists.jboss.org'"
<rules-dev@lists.jboss.org>
Message-ID:
	<73C89FCA1CA6C14E9DFC31575B11F7813287F10EEC@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.)" <manstis1@ford.com>
Subject: RE: [rules-dev] Need to Exit from DRL without using
	drools.halt()
To: "Rules Dev List" <rules-dev@lists.jboss.org>
Message-ID:
	<C7774483B6A70C4BB10E917CC1A59DC11BCAEE@eu1wam35.warley.ford.com>
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: rules-dev-bounces@lists.jboss.org
[mailto:rules-dev-bounces@lists.jboss.org] On Behalf Of Sarath Kumar
Daruru
	Sent: 15 January 2009 10:06
	To: 'rules-dev@lists.jboss.org'
	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
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev


End of rules-dev Digest, Vol 25, Issue 8
****************************************