[jboss-jira] [JBoss JIRA] (DROOLS-496) Working rule script in version 5.6.0 does not work in 6.0.1

Jörgen Risholt (JIRA) issues at jboss.org
Thu May 22 10:04:56 EDT 2014


Jörgen Risholt created DROOLS-496:
-------------------------------------

             Summary: Working rule script in version 5.6.0 does not work in 6.0.1
                 Key: DROOLS-496
                 URL: https://issues.jboss.org/browse/DROOLS-496
             Project: Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: 6.0.1.Final
            Reporter: Jörgen Risholt
            Assignee: Mark Proctor
            Priority: Critical


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();
            }
        }
    }
}



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)



More information about the jboss-jira mailing list