JBoss Drools Working Memory multiple facts

1.7k views Asked by At

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)

1

There are 1 answers

1
Michael Neale On BEST ANSWER

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

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