[jboss-jira] [JBoss JIRA] Commented: (JBRULES-1881) no-loop attribute not wrking with modify

Edson Tirelli (JIRA) jira-events at lists.jboss.org
Tue Mar 10 09:32:23 EDT 2009


    [ https://jira.jboss.org/jira/browse/JBRULES-1881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12456388#action_12456388 ] 

Edson Tirelli commented on JBRULES-1881:
----------------------------------------

The problem happens because you are using "from". There is a whole explanation in the "from" part of the manual regarding the interaction between "from" and the attributes "no-loop" and "lock-on-active", but being brief, the result of a "from" call is a black box for the engine. So, every time the expression of "from" is re-evaluated, it will create new fact handles for the results. 

So in your example, modifying $edi, will cause the expression "$prod" to be re-evaluated, creating a new fact handle for the result. This means that when the rule is re-activated, since the fact handles in the tuple are different from the previous ones, the no-loop will *not* prevent the activation.

This is a behavior that can not be changed now. I will mark this issue as FUTURE because hopefully we can improve it when we develop a feature called "true modify". 

The work around for you is to avoid the use of "from" together with "no-loop" and "lock-on-active". In your example, you could use nested accessors:

rule ...
when
$edi : EdiProduct( product.classificationCode == null, product.pricing.msrp.asBigDecimal > 0 )
then 
...
end


> no-loop attribute not wrking with modify 
> -----------------------------------------
>
>                 Key: JBRULES-1881
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-1881
>             Project: JBoss Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-compiler, drools-core
>    Affects Versions: 4.0.7
>            Reporter: Sravanthi Tipirneni
>            Assignee: Mark Proctor
>            Priority: Minor
>             Fix For: FUTURE
>
>
> in the rule given below, the rule is looping when i use 
>   modify( $edi ){
> 		  setSourceable(true)
> 		}
> in RHS. It does not loop when i use $edi.setSourceable(true);
> rule "Generic MSRP Rule"
> 	no-loop true
> 	when
> 		$edi : EdiProduct( $prod  : product  )
> 		Product( classificationCode == null, $prc : pricing ) from $prod
> 		Pricing( $msr : msrp ) from $prc
> 		Money( asBigDecimal > 0) from $msr
> 	then
> 	        modify( $edi ){
> 		  setSourceable(true)
> 		}
> 		//$edi.setSourceable(true);
> 		System.out.println("Rule is successfull");
> end

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list