Drools 决策表规则不使用更新值
我正在使用 Drools Rules Server 作为服务。我们正在使用一个决策表,
Pre Rules Movie Object:
actor: "unknown"
movie: "Ghostbusters"
rating: 9
我在 Drools 决策表中有 2 个简单的规则。第一条规则检查值 (movie=="Ghostbusters"
),然后设置对象 setActor("Bill Murray")
的调用。
第二条规则检查 Actor 是什么。我在第二条规则中有两行。 如果 Actor == "Bill Murray"
它会调用 setRating(10)
操作。如果 actor == "unknown"
setRating(8)
第一条规则按预期触发,我可以 printLn getActor
显示它是“ Bill Murray”,但在第二条规则中,actor == “unknown”
操作始终会触发。即使在该行中我打印 getActor
它也会打印“Bill Murray”,但它使用“未知”规则。
当对象从规则返回时,它具有 Actor = Bill Murray
以及规则中设置的所有值“正确”,但规则似乎始终使用我在评估规则时在规则之外创建的原始对象。
我是否需要添加一些内容到决策表或调用 drools 规则服务器以“更新”规则表之间的对象?
I am using Drools Rules Server as a service. We are using a decision table
Pre Rules Movie Object:
actor: "unknown"
movie: "Ghostbusters"
rating: 9
I have 2 simple rules in a Drools Decision table. The 1st rule checks for a value (movie=="Ghostbusters"
) and then sets the calls that objects setActor("Bill Murray")
.
The 2nd rule checks to see what the Actor is. I have 2 rows in this second rule. if Actor == "Bill Murray"
it calls an action of setRating(10)
. And if actor == "unknown"
setRating(8)
The first rule fires as expected, and I can printLn the getActor
to show it's "Bill Murray" but in the second rule, the actor == "unknown"
action always fires. Even if in that row I print getActor
it prints "Bill Murray" but it's using the "unknown" rule.
When the object comes back from the rules, it has Actor = Bill Murray
and all values set in the rule "correct" but the rules seem to always use the original object I created outside the rule when evaluating rules.
Is there something I have to add to the decision table or the call to invoke the drools rule server to "update" the object between rule tables?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道自从您提出问题以来已经过去了太多时间,但对于其他有同样问题的人来说:
如前所述,您应该修改对象而不是设置它。要在决策表中执行此操作,请在 RuleTable 中添加一个操作列,并在第二行中添加:
modify($className){ setActor("Bill Murray")};
将操作下的第一行保留为空白。
I know too much time has passed since you asked the question but for others with the same problem:
As stated you should modify the object and not set it. To do this in decision tables add an action column in your RuleTable and in second line you should add:
modify($className){ setActor("Bill Murray")};
Keep the first row under action blank.
您应该使用 Drools 文档(4.8.4.1、4.8.4.2)中所述的
update
或modify
方法:这将告诉引擎对象已更改并且规则将被更改重新申请。
you should use
update
ormodify
method as described in Drools docs (4.8.4.1, 4.8.4.2):this will tell the engine that object has been changed and rules will be reapplied.