1

I have created two different rules, which belong to two different agenda-groups. First one:

rule "32-30-33.32"
dialect "java"
salience 0
agenda-group "32-30"
when
    map : Map((this["Product Name"].toUpperCase().contains("PREMIUM ADPRODUCT")) && ((this["Size Length"] != 5) || (this["Size"].toUpperCase() not contains "300X600") || (this["Size"].toUpperCase() not contains "280X130") || (this["Size"].toUpperCase() not contains "300X250") || (this["Size"].toUpperCase() not contains "970X250") || (this["Size"].toUpperCase() not contains "320X50")));
then
    JSONObject jObject = new JSONObject("{\"error34\":\"Premium Adproduct doesn't contain required Creative size!\"}");
    Iterator<?> keys = jObject.keys();
     while(keys.hasNext()) {
          String key = (String)keys.next();
          Object value = jObject.get(key);
          map.put(key, value);
     }
    debug(drools);
end

Another rule, in another agenda group:

rule "47-37-1.0"
dialect "java"
salience 0
agenda-group "47-37"
when
    map : Map((this["OrderName"] == null));
then
    JSONObject jObject = new JSONObject("{\"error1\":\"OrderName should not be null \"}");
    Iterator<?> keys = jObject.keys();
     while(keys.hasNext()) {
          String key = (String)keys.next();
          Object value = jObject.get(key);
          map.put(key, value);
     }
    debug(drools);
end

After this, I set focus to the group "47-37",

kieSession.getAgenda().getAgendaGroup("47-37").setFocus();

All rules within the group "32-30" are also getting evaluated. I'm using Drools 7.0.0. How can I control execution of rules only within the focused group?

lucifer
  • 405
  • 5
  • 13
  • Does this answer your question? [understanding agenda-group in drools](https://stackoverflow.com/questions/6870192/understanding-agenda-group-in-drools) – Prog_G Nov 12 '19 at 12:28
  • Duplicate questions. you can find the explanation here[1] [1]https://stackoverflow.com/a/9535813/7726319. – Prog_G Nov 12 '19 at 12:29
  • @Prog_g It doesn't answer it. How to not let another rule in another group not get evaluated, unless it is focused? – lucifer Nov 13 '19 at 06:41
  • You can you separate kiesessions or use entry-point. See https://docs.jboss.org/drools/release/7.7.0.Final/drools-docs/html_single/#_entrypoint for entry point – Prog_G Nov 13 '19 at 06:46
  • AFAIK, you cannot separate rules on a session-level, it takes all the rules from your KieBase – lucifer Nov 13 '19 at 11:05
  • you can create multiple partitions (entry-points) on a drool session. Events and rules inside each entry point are separate. I think you want the same as you have mentioned in your question. – Prog_G Nov 13 '19 at 11:44

0 Answers0