0

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)

cwrwatson
  • 61
  • 1
  • 6

1 Answers1

1

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

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

Michael Neale
  • 19,248
  • 19
  • 77
  • 109
  • Yes I do call fireAllRules after the update. The class that is inserted into workingMemory is not recognised by my rules – cwrwatson Feb 15 '11 at 23:20