[rules-users] Is there a faster way of doing this in Drools ?

soumya_sd soumya_sd at yahoo.com
Wed May 9 11:43:43 EDT 2012


Vincent Legendre wrote
> 
> Users changing rules IS the correct use-case of drools (I would even say
> that if rules never change, drools is likely to be worse than pure java).
> What others said is "changing the rules at each request by regenerating
> and recompiling" is not.
> 
> I can't imagine that users may change rules at each request, so you must
> have, at least for some time (thus a lot of requests), a stable rule base.
> What is costly is to compile rules, but you already know that.
> So the idea is to keep in some kind of cache the actual rules, and only
> recompile them when they change.
> 
> The source of rules does not matter : you can generate the DRL according
> to your configuration, or make you users directly write rules (with
> guvnor, which will fits well if your rules are only basic filters).
> 
> The optimisation you have to do is to keep your compiled rules somewhere
> (by serializing your KnowlegdePackages or simply keep it in a kind of
> map), and reuse it until your source change : you have to find a way to
> detect that rules (or the config that is used to generate them) have
> changed, and then recompile a new up-to-date KnowledgePackage.
> 
> 

Thank you for your insights. 

At this point I'm designing for the worst case i.e., I'm assuming the rules
with change with every request. 

Moreover, this can happen on a regular basis in the system I'm trying to
design. 

Product
{ 
  price
  ave_user_rating
  num_ratings
  category 
  
} 

User wants to see Product with with the following rules 

at t=t_1 : If product.category in {A,B}. 

at t=t_2 : If product.category in {A,B} AND price < 100 

at t=t_3 :  If product.category in {A,B}  AND price < 100 AND num_ratings >
100 

You can imagine the user changing these rules in a span of less than a
minute. 

I understand that Drools is designed for cases when rules changes often. But
can it support something like the one I described above where rules are
changing at a much faster rate? 


Thanks. 






--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-a-faster-way-of-doing-this-in-Drools-tp3973888p3974487.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list