[rules-users] Basic question

goforcrazy goforcrazy at gmail.com
Sun Apr 7 01:18:11 EDT 2013


Hello All,

I am having some basic problems with how my rule file is working. Any help
regarding this will be greatly appreciated.

My rule is as follows:

rule "Rating"

	when 
		m : method()
	then
		System.out.println("Rating inserted as: "+ m.getid() + " and rating: " +
m.getRating());
		
end


In my main java file, I am calling in the main method:

insertRating(101, 1.0);
insertRating(102, 1.0);
ksession.fireAllRules();


The definition of insertRating is as below:
public void insertRating(int mid, double d) 
{
		RatingMessage msg = new RatingMessage(mid,d);
		ksession.insert(msg);
		
}

My expectation is that 2 different ksession objects will be created and when
fireAllRules() is executed, the rule will be able to print the ID and rating
for both 101 and 102.

I am surprised that the output is 
Rating inserted ID as: 101 and rating: 1.0	


It randomly takes either 101 or 102 and never both. Why is it so? Am I
missing something?

Thanks a million for the help:)



--
View this message in context: http://drools.46999.n3.nabble.com/Basic-question-tp4023234.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list