[rules-users] Drools v5 multithreading questions

Edson Tirelli tirelli at post.com
Mon Jun 15 08:07:47 EDT 2009


   Andrey,

   May I ask you please to open a JIRA with the info from your e-mail? I
will investigate this.

   Thanks,
      Edson

2009/6/15 Andrey Nechaev <nechaev.andrey at gmail.com>

> 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
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090615/e3d41a49/attachment.html 


More information about the rules-users mailing list