[rules-users] Major problems with dynamic rules

Michael Neale michael.neale at gmail.com
Mon Jan 22 17:39:11 EST 2007


Hi Justine. It does sound like something is amiss, could you wrap up a unit
test for this ? is that possible, then we can slap it to a JIRA and fix it.

Thanks,

Michael.

On 1/23/07, Justine Hlista <justine at vsasset.com> wrote:
>
> Hello,
>
> I am having some major problems working with dynamic rules. This may be a
> showstopper for us. Perhaps I have missed something in the docs.
>
> The main problem is significantly different behavior depending on when I
> assert facts versus when I read drl files that use them.
>
> It *appears* that I must class load all potential fact classes by
> referencing them in a dummy rule before I assert facts and and begin using
> dynamic rules against them. But that is a guess.
>
> An example:
>
> I have 2 rule files and 1 fact class (class factA with a String field1).
>
> ---------------------
> testCase1.drl:
> ---------------------
> rule Bootstrap
>     when
>         a : factA(field1=="blah")
>     then
>         System.out.println("bootstrap: a blah");
> end
> ---------------------
> testCase2.drl:
> ---------------------
> rule "aIsHello"
>     when
>         a: factA(field1=="hello")
>     then
>         System.out.println("a: " + a.getField1());
>         a.setField1("world");
>         modify(a);
> end
>
> rule "aIsWorld"
>     when
>         a: factA(field1 == "world")
>     then
>         System.out.println("Retracted a with field1 = " + a.getField1());
>         retract(a);
> end
>
>
> If I first assert my factA (workingMemory.assertObject( new
> factA("hello")) ) before loading either drl file, only rule "aIsHello"
> fires.
>
> If I first load testCase1.drl and then assert factA and then load
> testCase2.drl, then both rule "aIsHello" and rule "aIsWorld" both fire.
> This is the expected behavior (at least for me).
>
> If I modify testCase1.drl such that it does not reference class factA but
> some other class (e.g. factAtoo), then only rule "aIsHello" fires (as in
> the first case).
>
> I am extremely confused, as I would at least expect the same behavior in
> all cases. For our application, it is critical that we be able to assert
> facts and modify rules independently and dynamically. What am I missing
> about how dynamic rules should work??
>
> Any help is greatly appreciated!
>
> Justine
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070123/a97e07f1/attachment.html 


More information about the rules-users mailing list