[rules-users] How can I know, how many facts are processed by stateFulSession?

Edson Tirelli tirelli at post.com
Tue Aug 31 10:24:26 EDT 2010


   I am not sure I understand your problem. The rule clearly should NOT
match facts with value 0, as it will raise division by zero error all the
time. So, the solution, in my mind is:

rule "r1"
    when
        p : CTestObj( value != 0 )
    then
        p.setValue( 1 / p.getValue() );
end

   If you need to give a different treatment to objects with value == 0,
just add another rule for them.

   []s
   Edson


2010/8/31 tom ska <tiberium.linux at gmail.com>

> Hello,
> I have a class and rule:
>
> class CTestObj
> {
>         private double value;
>
>         void setValue(double v) {
>                 this.value = v;
>         }
>
>         double getValue() {
>                 return this.value;
>         }
> }
>
> rule "r1"
>     when
>         p : CTestObj
>     then
>         p.setValue( 1 / p.getValue() );
> end
>
> As you can see, in this rule, there is risk, to put into stateFulSession
> object with value set 0. I can't validate this, because, this problem has a
> variation where I put into stateFulSession object with set no 0, but the
> rule will modify it...
> So - I can't validate this = fact with value 0 is correct.
>
> But I process with stateFulSession many, many facts... For example 1000.
> And, after 900 facts it occurs, that fact number 901 has value set on 0. In
> effect I get an exception:  org.drools.runtime.rule.ConsequenceException:
> java.lang.ArithmeticException: / by zero. And ksession stops processing
> facts. But, 900 facts are processed! I don't want to process them second
> time.
> And this is my question:
>
> How can I know, which fact is first no-processed fact? Which one stoped
> fireAllRules method?
> Beacuse I don't want to process them another time.
>
> Greetings :)
> tom.
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100831/79ef90b9/attachment.html 


More information about the rules-users mailing list