Sorry, I take back what I said about the previous email - when I was refering 
to agenda groups, I actually ment activation groups. 

But thinking about it more, I think activation groups might be a ok. Just makes 
sure that all rules in the activation group have the same consequence.

Regards,
Alan Ho 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ho, Alan
Sent: Wednesday, February 14, 2007 4:04 PM
To: Rules Users List
Subject: RE: [rules-users] Short-circuit rules by group?!

I won't recommend using agenda groups in this case. If you want to make sure 
that a message is sent once and only once per customer, the predicate for each 
rule should look like :

When
        customer : Customer()
        "Your custom business logic" && !customer.sentAEvent Then
        sendEventToCustomer
        customer.sentAEvent = true
        drools.assert(customer.sentAEvent)
End


This will ensure that only one event would get sent. Even if you use Agenda 
Groups, you can't prevent the LHS (condition statement) to be evaluated for 
every single rule. In the case where you have multiple rule's LHS are evaluted 
to be true, the "drools.assert" executed during the first valid rule would 
cause a revaluation of all rules that has "!customer.sentEvent" in its 
condition. When the re-evaluations reoccur, the !customer.sendAEvent is 
evaluated to false, hence a event is never sent twice to the customer.

Agenda groups isn't a good idea because then your agenda groups is tightly tied 
to the data. You might end up creating more and more agenda groups for each 
customer.

Does that make sense :P

Regards,
Alan Ho

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jdepaul
Sent: Tuesday, February 13, 2007 9:43 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Short-circuit rules by group?!


I have several rules defined in groups by Customer, so I have number of rules 
for Walmart, some rules for NIKE, more rules for SomeCustomer...  When one of 
the rules matches for a given customer I need to send an event notification.  I 
need to make sure that I send only ONE event notification per Customer 
(regardless of how many rules were matched), thus after finding the very first 
match in the Walmart group, I'd like to activate a rule, and then short-circuit 
and "Skip" to the next group of rules for NIKE - to see if any of the matches 
are found in the next group.  

I've implemented this functionality using a Match object, which I assert into 
WorkingMemory whenever I find a match for customer, then all my rules check for 
absence of Match for given customer...

This works, but I wonder if there is a better way to do it - using Agenda 
Groups, maybe - once I find ONE match for Walmart, skip to the next Agenda 
Group?!  Could someone comment on this?

THanks,
James
--
View this message in context: 
http://www.nabble.com/Short-circuit-rules-by-group-%21-tf3222142.html#a8949165
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to