开发者

JBoss Drools Working Memory multiple facts

This is my rule:

rule "Your First Rule"

    when
        $testRule : TestRule(count >= 100)
    then 
        System.out.println("100 PACKETS!");
    end

This is how I create the RuleBase and WorkingMemory:

public void invokeRules(){
    RuleBase ruleBase = readRule(); \\creates ruleBase from DRL package
开发者_开发问答    workingMemory = ruleBase.newStatefulSession();
    testRule = new TestRule();
    factHandle = workingMemory.insert(testRule);    
    workingMemory.fireAllRules();
}

I have an update section:

workingMemory.update(factHandle, testRule);

I am now getting 1 TestRule fact in WorkingMemory and the rule is creating another instance of TestRule. I am aware that I am instantiating two TestRule facts but only the one in WorkingMemory reacts. Where am I going wrong?!

(Wits End)


Not sure what you mean by "and the rule is creating another instance of TestRule"?

Did you call workingMemory.fileAllRules(); immediately after update?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜