As Wolfgang recommends, please double-check your java code.. it would be
useful to see how you build
the KnowledgeBase and the KnowledgeSession, as well as the **full** DRL
file(s) you are loading.
In particular:

- check that the KnowledgeBuilder does not return any error
(kbuilder.getErrors()). It will not throw exceptions,
but you would get a "best effort" KB which is unsafe to use.
- check that you are not loading other DRLs, *** especially with rules
retracting your RatingMessages ***.
- check that you are not importing a stale RatingMessage class, with the
same name but in a different package.
- provide information on the version you are using

Otherwise, this would be an END-OF-THE-UNIVERSE bug and no Drools-based
application could possibly work, which
is extremely unlikely...

Best
Davide

On 04/07/2013 08:20 AM, Wolfgang Laun wrote:
> Once again: the code you are posting isn't consistent in itself. You
> are changing either the DRL or the Java code from what you actually
> run.
>
> As I said: either post complete and accurate code that reproduces the
> problem or stop posting.
>
> -W
>
>
>
> On 07/04/2013, goforcrazy <[email protected]> wrote:
>> 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.
>> _______________________________________________
>> rules-users mailing list
>> [email protected]
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to