[rules-users] Drools v5 multithreading questions

Andrey Nechaev nechaev.andrey at gmail.com
Mon Jun 15 06:12:52 EDT 2009


Hello, All!



I’m evaluating the new version of Drools (5.0.1), so I’m especially
interested in multithreading and partitioning options, implemented in Drools
v5.

I’ve prepared a little test case to check how the feature works. Here is the
rule I’m using:

package test

rule test

when

                        NODE2($p : value > 20)

            then

                        System.out.println("Fired :” + $p);

end



The NODE2 POJO is very simple:

public class NODE2 {

            private int value;

            public NODE2(int value) {

                        this.value = value;

            }

            public int getValue() {

                        return value;

            }



            public void setValue(int value) {

                        this.value = value;

            }

}



And here is the main code snippet:

1:         KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();

2:         conf.setOption(MultithreadEvaluationOption.YES);

3:         conf.setOption(MaxThreadsOption.get(10));

4:         KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase(conf);

5:

6:         KnowledgeBuilder bld =
KnowledgeBuilderFactory.newKnowledgeBuilder();

7:         bld.add(ResourceFactory.newReaderResource(new
StringReader(rule)), ResourceType.DRL);

8:         kb.addKnowledgePackages(bld.getKnowledgePackages());

9:

10:       StatefulKnowledgeSession session =
kb.newStatefulKnowledgeSession();

11:       session.insert(new NODE2(25));

12:

13:       session.fireAllRules();

In such a case my program hangs and nothing is displayed in the Console.

If I put lines 10-11 prior to line 6, I get a NullPointerException:

Exception in thread "main" java.lang.NullPointerException

            at
org.drools.reteoo.ObjectSource.addObjectSink(ObjectSource.java:124)

…

But, if I comment out the lines 2&3, everything works ok…

So, please help – what I’m doing wrong?



Best regards,

Andrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090615/33be47c1/attachment.html 


More information about the rules-users mailing list