Hello,
Since I wanted to highlight what the problem was, I didnt quite give the
entire source code. Let me be clear now.
IN the drl file:
rule "Rating"
when
m : RatingMessage()
then
System.out.println("Rating inserted as: "+ m.getid() + "
and
rating: " +
m.getRating());
end
I have a Java file by name RatingMessage.java, the source code of which is
pasted below:
public class RatingMessage {
private int mid;
private double rating;
public RatingMessage(int mid, double rating) {
//super();
this.mid = mid;
this.rating = rating;
}
public int getMid() {
return mid;
}
public void setMid(int mid) {
this.mid = mid;
}
public double getRating() {
return rating;
}
public void setRating(float rating) {
this.rating = rating;
}
}
In this case public RatingMessage(int mid, double rating) method is invoked
and when I am calling the methods in the main java file as
insertRating(101, 1.0);
insertRating(102, 1.0);
ksession.fireAllRules();
Randomly 101 or 102 is being picked and I am getting only one of these as
the output. Since each insertRating will invoke ksession.insert twice I was
expecting to see both ratings inserted.
public RatingMessage insertRating(int mid, double d) {
RatingMessage msg = new RatingMessage(mid,d);
ksession.insert(msg);
return msg;
}
Let me know if you need anything else to figure out the problem in the code.
Thanks
--
View this message in context:
http://drools.46999.n3.nabble.com/Basic-question-tp4023234p4023238.html
Sent from the Drools: User forum mailing list archive at
Nabble.com.