[rules-users] Why Using "from" Always Return A New Fact?

Edson Tirelli ed.tirelli at gmail.com
Thu Jan 20 11:47:51 EST 2011


   Yes, it might be different from version to version as we improve the
overall algorithm. The reason for the different behavior is that under
Drools 5.0 (and in most rule engines out there), every modify is just a
retract+assert. So, the different fact handles would prevent the proper
normalization of the activations. 5.1.x improved the algorithm with what we
call true modify, where a modify is a real modify (not retract+assert). This
algorithm allowed me to implement an optimization based on the system ID of
the objects returned by the from expression: if it is the same identity of a
previously existing fact, it will not recreate the fact handle, but reuse
the existing one. That means the first rule was not cancelled and
reactivated, it just remained active and so the from didn't had a direct
effect on the lock-on-modify. There are scenarios, though where this still
might happen, but I would have to review all that. The general advice as of
now is still to avoid using "from" with "lock-on-active", but I expect that
restriction to be lifted in drools 6.

   Edson



2011/1/20 hyjshanghai <hyjshanghai at gmail.com>

>
> OK. You mean the behavior differs by versions.  My above test in which both
> rules fired was using Drools 5.1.1.
>
> Questions:
>
> 1. "Since the lock and no-loop features are based on the fact handles, the
> sometimes undesired interaction occurs."
> Could you elaborate more on how is lock-on-active based on fact handles?
>
> 2. Is it the expected design that when I ran my above rules in Drools 5.1.1
> both rules should fire? How is it related to the fact that lock-on-active
> is
> based on fact handles?
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Why-Using-from-Always-Return-A-New-Fact-tp2286393p2292914.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> 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/20110120/b8fc4067/attachment.html 


More information about the rules-users mailing list