jasa
jasa

Reputation: 11

Drools 6 many agenda-groups declarations

Can i only have one agenda-group declaration for the same rule in Drools 6?

Can I put this?

rule "rule_x"
agenda-group "group_x"
agenda-group "group_y"
when

then
end

I want to active a this rule when several groups are focused.

Upvotes: 0

Views: 1285

Answers (1)

laune
laune

Reputation: 31300

Most rule attributes are just syntactic sugar, and agenda-group is one of them. It's easy to achieve the same effect by falling back to logic patterns.

Define

class Group { private String name; ... }

and use one instance of it as a fact to represent the currently active group. Rules will have to show an additional pattern:

rule in-group-one
when
    Group( name == "one" )
    ...

If the rule to be in several groups at the same time:

rule in-groups-one-two
when
    Group( name in ("one", "two") )

You can also mimic the behaviour of agenda group stacking.

Later The idea of focussing more than one group at the same time should be considered very carefully. While it is clear that a rule in groups a, b and c should fire when these three groups are in focus, it isn't clear at all what should happen with a rule in groups a and b, or with another rule in groups a, c and d. Whatever should happe can indeed be expressed in logic, but does it make sense, and (more importantly) is it useful?

Upvotes: 2

Related Questions