Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-496

Rules in Drools 6.x cannot use more than 64 patterns

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • None
    • 6.0.0.Final, 6.0.1.Final, 6.1.0.Final, 6.2.0.Beta1
    • None
    • None
    • Workaround Exists
    • Hide

      Enable the legacy RETE mode

      1) add a dependency to the drools-reteoo jar
      2) Use the option

      kieBaseConfiguration.setOption( RuleEngineOption.RETEOO );
      kContainer.newKieBase( kieBaseConfiguration );
      
      Show
      Enable the legacy RETE mode 1) add a dependency to the drools-reteoo jar 2) Use the option kieBaseConfiguration.setOption( RuleEngineOption.RETEOO ); kContainer.newKieBase( kieBaseConfiguration );

      When trying a script as shown below we can not get it to work with 6.0.1 but with 5.6.0. There seems to be some relation to the number of facts, the more facts the higher probablity that the 6.0.1 version do not trigger. We have made two simple singelthreaded scenarios that I can upload if wanted.

      The examle has a lot of facts, but we notice that from about 50 it seems that the problam may occur.

      rule "TestRule"
      Person(name == "Name0")
      Person(name == "Name1")
      ....
      Person(name == "Name1000")
      then
      System.out.println("Successfully trigged");
      end

      This is the testcode for 5.6.0.Final (work always):
      package drools_test;

      import org.drools.KnowledgeBase;
      import org.drools.builder.KnowledgeBuilder;
      import org.drools.builder.KnowledgeBuilderFactory;
      import org.drools.builder.ResourceType;
      import org.drools.io.ResourceFactory;
      import org.drools.runtime.StatefulKnowledgeSession;
      import drools_test.data.Person;

      public class App {
      private final static int NUMBER_OF_PERSONS = 3000;

      public static void main(String[] args) {
      KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
      kbuilder.add(ResourceFactory.newClassPathResource("rules.drl",
      App.class), ResourceType.DRL);
      KnowledgeBase kb = kbuilder.newKnowledgeBase();
      StatefulKnowledgeSession session = null;
      try {
      session = kb.newStatefulKnowledgeSession();
      for (int i = 0; i < NUMBER_OF_PERSONS; ++i)

      { session.insert(new Person(String.format("Name%s", i))); session.fireAllRules(); }

      session.fireAllRules();
      } finally {
      if (session != null)

      { session.dispose(); }
      }
      }
      }

      And this is the same code for 6.0.1.Final which always fails:
      package drools_test;

      import org.kie.api.KieServices;
      import org.kie.api.runtime.KieContainer;
      import org.kie.api.runtime.KieSession;

      import drools_test.data.Person;

      public class App
      {
      private final static int NUMBER_OF_PERSONS = 3000;

      public static void main(String[] args)
      {
      KieServices kieServices = KieServices.Factory.get();
      KieContainer kContainer = kieServices.getKieClasspathContainer();
      KieSession session = null;

      try {
      session = kContainer.newKieSession();
      for (int i = 0; i < NUMBER_OF_PERSONS; ++i) { session.insert(new Person(String.format("Name%s", i))); session.fireAllRules(); // Comment out this line and the rule will fire. }
      session.fireAllRules();
      } finally {
      if (session != null) { session.dispose(); }

      }
      }
      }

        1. drools-test_5.6.0.tar
          180 kB
          Jörgen Risholt
        2. drools-test_6.0.1.tar
          180 kB
          Jörgen Risholt

              mfusco@redhat.com Mario Fusco
              ejorris Jörgen Risholt (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: