JBoss Drools 工作记忆的多项事实
这是我的规则:
rule "Your First Rule"
when
$testRule : TestRule(count >= 100)
then
System.out.println("100 PACKETS!");
end
这就是我创建 RuleBase 和工作内存的方式:
public void invokeRules(){
RuleBase ruleBase = readRule(); \\creates ruleBase from DRL package
workingMemory = ruleBase.newStatefulSession();
testRule = new TestRule();
factHandle = workingMemory.insert(testRule);
workingMemory.fireAllRules();
}
我有一个更新部分:
workingMemory.update(factHandle, testRule);
我现在在工作内存中获取 1 个 TestRule 事实,并且该规则正在创建 TestRule 的另一个实例。我知道我正在实例化两个 TestRule 事实,但只有工作内存中的一个做出反应。我哪里错了?!
(无计可施)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定“并且规则正在创建 TestRule 的另一个实例”是什么意思?
你有没有调用workingMemory.fileAllRules();更新后立即?
Not sure what you mean by "and the rule is creating another instance of TestRule"?
Did you call workingMemory.fileAllRules(); immediately after update?