Edson, Michal,

thank you for your answers. If I understand well, Drools can't recognize if the $fact2 has been changed by the current rule or not. Anyway, I found such a behaviur as a bit confusing, so my second question is, is it a desirable behaviour? And is it going to be changed or left as is?

Best regards
Przemyslaw

Edson Tirelli pisze:

Michal is correct. Every time a "from" expression is executed, Drools does not know if a result for the expression is new or not and it creates a new fact handle, bypassing the no-loop.

    []s
    Edson

2009/2/13 Michal Bali <[email protected] <mailto:[email protected]>>

    This is what I think is going on:
    when you call update($fact1) it will first retract $fact1 which in
    turn retracts $fact2, the $fact1 is then inserted again which cause
    another 'from' evaluation and a NEW $fact2 is pulled -> no-loop
    doesn't work because Drools sees it as different data
    I am just guessing here ...


    On Fri, Feb 13, 2009 at 9:12 AM, Przemysław Różycki
    <[email protected] <mailto:[email protected]>> wrote:

        Hello,

        Doesn't really anyone have any logical explanation of why such a
        rule loops?

        To remind the rule:


        rule "Hello World"
               no-loop
               when
                       $fact1 : MyFactBean1(  )
                       $fact2 : MyFactBean2(  ) from $fact1
               then
                       System.out.println("Fired!!!");
                       update($fact1);
        end

        If I don't use 'from' everything is fine.
        I really didn't find in a documentation, that 'from' causes any
        special behaviour of the rule looping.


        Best regards,
-- Przemysław Różycki
        AMG.net, A Bull Group Company
        ul. Łąkowa 29
        90-554 Łódź
        www.amg.net.pl <http://www.amg.net.pl>



        Przemysław Różycki pisze:

            Thanks for answer, Vikrant, but I don't think so. I have
            always used no-loop without any additions and it worked
            (when I didn't use from). BTW, if you comment a condition
            with from, then the rule does not loop. I also checked with
            "no-loop true" and result is the same.

            Best regards,
            Przemek

            Vikrant Yagnick pisze:

                I have to quickly recheck the documentation by I think
                you have to write "no-loop true". Just writing no-loop
                defaults to false I guess.

                -----Original Message-----
                From: [email protected]
                <mailto:[email protected]>
                [mailto:[email protected]
                <mailto:[email protected]>] On Behalf
                Of Przemyslaw Rózycki
                Sent: Tuesday, February 10, 2009 3:24 PM
                To: Rules Users List
                Subject: [rules-users] Rules with from always loops
                (Drools 4.0.7)

                Hello,

                why does such a rule always loop? Even if no-loop is used?

                rule "Hello World"
                       no-loop
                       when
                               $fact1 : MyFactBean1(  )
                               $fact2 : MyFactBean2(  ) from $fact1
                       then
                               System.out.println("Fired!!!");
                               update($fact1);
                end

                The full code of my test application and drl is attached.

                Best regards,
-- Przemysław Różycki
                AMG.net, A Bull Group Company
                ul. Łąkowa 29
                90-554 Łódź
                www.amg.net.pl <http://www.amg.net.pl>


                MASTEK LTD.
                Mastek is in NASSCOM's 'India Top 20' Software Service
                Exporters List.
                In the US, we're called MAJESCOMASTEK

                
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                Opinions expressed in this e-mail are those of the
                individual and not that of Mastek Limited, unless
                specifically indicated to that effect. Mastek Limited
                does not accept any responsibility or liability for it.
                This e-mail and attachments (if any) transmitted with it
                are confidential and/or privileged and solely for the
                use of the intended person or entity to which it is
                addressed. Any review, re-transmission, dissemination or
                other use of or taking of any action in reliance upon
                this information by persons or entities other than the
                intended recipient is prohibited. This e-mail and its
                attachments have been scanned for the presence of
                computer viruses. It is the responsibility of the
                recipient to run the virus check on e-mails and
                attachments before opening them. If you have received
                this e-mail in error, kindly delete this e-mail from
                desktop and server.
                
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



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


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



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



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




--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com <http://www.jboss.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

Reply via email to