[rules-users] Rule definition help

Rahul Phadnis rahul.phadnis at fatspaniel.com
Thu Feb 22 16:11:54 EST 2007


I am very new to JBoss rules and I am trying to use it
for evaluating alert conditions.

I am asserting the AlertDefinition object as a fact
into the working memory.

The rules file would define a variety of alert
condition rules. 
for example

rule "Device not working (condition id = 4)"
    # the if part
	when
        alertDefinition : AlertDefinition (conditionID
== 4, 
        eid : entityID)
        # here i would like to get the last power
reading from device
        # with id == eid 
        eval (dao.getPower(eid).doubleValue() < 1000)
        # then get temperature from the device
        eval ((dao.getTemperature(eid) != null && 
dao.getTemperature(eid) > 50)
        || (dao.getAmbTemperature(eid) != null && 
dao.getAmbTemperature(eid) > 40)
        ) 
        
	then
        # what do we do if the rule evaluates to true
        log("Triggered Device not working  alert for "
+ eid);
end


Here are  my questions:

1. Am using the evals correctly? Can I possibly split
this into multiple rules to make it work better?

2. Can assign dao.getTemperature(eid) to a field. The
getTemperature call is expensive and doing it twice is
not right.

Any pointer would be appreciated.

-Rahul




More information about the rules-users mailing list