[rules-users] When I insert fact to working memery in the rule file, others rule some time can't be fired.

luke lzz313 at sina.com
Fri Nov 11 03:18:41 EST 2011


Hi, 

When I insert fact to working memery in the rule file, others rule some time
can't be fired. 

I use the drools rule version is 5.3.0.Final 

call rule engine in java and loop 100,then has 1-3 times the "second" rule
and "third" rule can't be fired. 

rule file: 
package com.sample 

import com.sample.pojo.Order 
import com.sample.pojo.User 
import com.sample.pojo.Item 

declare ActivityType 
        orderId : String 
        name : String 
        type : String 
end 


rule "first" 
        no-loop true 
        salience 100 
    when 
    $user:User() 
        $order:Order(userId ==
$user.id,server=="server",operator=="operator",gameName=="gameName",createdDt
> "2011-11-01",createdDt < "2011-11-30",points >= 240) 
    not Order(userId == $user.id,id != $order.id) 
    then 
    drools.insert(new ActivityType($order.getId(),"first","S")); 
    System.out.println("inserted activity type,"+"
orderId="+$order.getId()); 
end 

rule "second" 
        salience 2 
    when 
        $activityType : ActivityType(name == "first",type == "S") 
        $order:Order(id == $activityType.orderId,points == 240,amount >= 10) 
    $user:User(id == $order.userId) 
    then 
        $user.setItem(new Item("aaa",1)); 
end 

rule "third" 
        salience 1 
        when 
                $activityType : ActivityType(name == "first", type == "S") 
                $order:Order(points == 240, id == $activityType.orderId) 
                $user:User(id == $order.userId) 
        then 
                $user.setItem(new Item("aaa",1*$order.getQuality())); 
end

--
View this message in context: http://drools.46999.n3.nabble.com/When-I-insert-fact-to-working-memery-in-the-rule-file-others-rule-some-time-can-t-be-fired-tp3499083p3499083.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list