[rules-users] Rules fired without calling session.fireAllRules()

Maxim Veksler maxim.veksler at gmail.com
Tue Nov 18 03:19:10 EST 2008


On Tue, Nov 18, 2008 at 12:17 AM, Jin Chai <jin.chai at jdsu.com> wrote:

> Hi,
>
> I have the following code, which is not working as I expected.
>
> rule "New AlertFacade"
>    salience 1140
>        when
>            $af : AlertFacade();
>        then
>            System.out.println($af.getProperties());
> end
>
>
> In the java code:
>   while (!isFireAllRules)
>   {
>     session.insert(alertFacade);
>     ....
>   }
>   session.fireAllRules();
>
>
> But I am seeing the rule "New AlertFacade" is fired everytime I inserted
> the
> fact.  Shouldn't it wait until fireAllRules() be called? Am I missing
> something
> here?
>

The "when' is evaluated as Drools builds its RETE network, which happens as
soon as you insert() the fact. This is called the LHS.
The "then" should happen only after you issue "fireallrules()". This is also
called the RHS of the rule.

If you see the system.out prints before you call fireallrules check that
your not using some eval in another rule in the LHS that might cause the
system.out calls.


>
> Thanks,
> Jin
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081118/7c5b1af1/attachment.html 


More information about the rules-users mailing list