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?
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.