fearman
fearman

Reputation: 11

Non-template Dynamic rules in Drools

To simplify my usecase. I have temperature points t1-t4 whose values are being measured. Users can specify different condition and values for a rule to fire. For example

t1+ ( 2* t2) LESS-THAN 100 or t3 EQUAL 5. 

So the condition and comparator are dynamic, the compared value and measured values too will be dynamic. Is this a candidate for Drools or any other rule engine. It seems to me that Drools is a template-oriented rule-engines, so one can do

rule "engine_is_hot"
  no-loop
 when
 $t1 : Temp( id =="1", $v1 : value) 
 $t2 : Temp( id =="2", $v2 : value) 
   eval ( $v1>=50 || $v1 + $v2<=100)
 then
        System.out.println( $t1.getId()+""+$t2.getId());
end

So is possible to Generate the rules dynamically and by that I mean, the logical comparator, comparedvalues and present values are dynamic. And I tried using PackageDescr , it wasn't flexible ; I can't specify I want a < or >= logical comparator.

Upvotes: 1

Views: 806

Answers (1)

Related Questions