[rules-users] Calling a function from When part

RulesUsers agrawalmanisha26 at gmail.com
Thu Aug 2 10:04:26 EDT 2012


Hi FrankVhh,

The above approach you suggested works, 
But the problem is it continuously hits this method when it satisfies the
rule  & in the method I have a DB call, so it creates some problem.
For eg: -
function boolean sampleFunction(){ 
//makes a DataBase call 
System.out.println("1234");
return true/false; 
} 


rule "sample1" 
when 
    //condition 1
then 
 System.out.println("abcd");
   //some action to satisfy condition 2
 System.out.println("mnop");
end

rule "sample2" 
when 
    //condition 2
    sampleFunction(); 
then 
     //some action
    System.out.println("xyz");
end


O/P
abcd
1234
1234
1234
1234
mnop
1234
1234
1234
1234
1234
1234
1234
1234
1234
1234
xyz


Is there any way to tackle this. As in by using salience or something.?

Regards,
Sam



--
View this message in context: http://drools.46999.n3.nabble.com/Calling-a-function-from-When-part-tp4018987p4018995.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list