[rules-users] Rule definition help

Anstis, Michael (M.) manstis1 at ford.com
Fri Feb 23 06:00:27 EST 2007


It seems inefficient to make calls to a database from a rule LHS as (I'm
guessing [Edson?]) that the Rete network can't be built\optimised around
an evaluated predicate (trying to use the correct language, but possibly
failing badly). Would the AlertCondition not already have these
properties populated? Making the rule simpler too:

Rule "Device not working (condition id = 4)"
	when
		$ac : AlertCondition (conditionId ==4, $eid : entityID,
$p : power, $at : ambTemperature)
	then
		log("Triggered Device not working  alert for " + $eid +
", power=" + $p + ", ambient temperature=" + $at);
end

-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Rahul Phadnis
Sent: 22 February 2007 21:12
To: rules-users at lists.jboss.org
Subject: [rules-users] Rule definition help

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

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




More information about the rules-users mailing list