[rules-users] KnowledgeAgent and Pipeline

Mark Proctor mproctor at codehaus.org
Tue May 12 19:22:29 EDT 2009


David Zeigler wrote:
> Hi Mark,
> Thanks for the quick reply.
>
> Now I'm getting a NullPointerException when I insert the message into
> the pipeline using 5.0.1.SNAPSHOT from today:
> java.lang.NullPointerException
> 	at org.drools.runtime.pipeline.impl.StatelessKnowledgeSessionPipelineImpl.insert(StatelessKnowledgeSessionPipelineImpl.java:24)
>
> It looks like StatelessKnowledgeSession's ruleBase is null when
> created by the KnowledgeAgent, which poses a problem since
> StatelessKnowledgeSessionPipelineImpl invokes getRootClassLoader() on
> the session's ruleBase.
>
> Here's what I'm doing:
> StatelessKnowledgeSession ksession = kagent.newStatelessKnowledgeSession();
> Pipeline pipeline =
> PipelineFactory.newStatelessKnowledgeSessionPipeline(ksession);
> pipeline.setReceiver(messageTransformer);
> pipeline.insert(message);  // NPE here
>   
I'm a bit busy to look into this in detail. But there is a unit test for 
this:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java
testModifyFileUrlWithStateless

That test works, maybe you could do an adaption of that unit test to 
make it fail and we can add it to the test framework, and which also 
means I'll fix it asap, if it's a bug.

Mark
> Thanks,
> David
>
> 2009/5/12 Mark Proctor <mproctor at codehaus.org>:
>   
>> David Zeigler wrote:
>>
>> Hi,
>> I've set up the KnowledgeAgent to automatically reload the rules
>> resources if they change.  If I use this with a Pipeline, it seems
>> that its StatelessKnowledgeSession is not reloaded automatically.  The
>> only way I've been able to get the Pipeline to reflect the rules
>> change is to do the following prior to each pipeline.insert():
>>
>> StatelessKnowledgeSession ksession =
>> kagent.getKnowledgeBase().newStatelessKnowledgeSession();
>> Pipeline pipeline =
>> PipelineFactory.newStatelessKnowledgeSessionPipeline(ksession);
>> pipeline.setReceiver( messageTransformer );
>>
>> Reloading the pipeline for each request adds a lot of overhead (halves
>> my transactions per second).  Is there a way to automatically reload
>> the Pipeline's session when its needed instead of recreating the
>> Pipeline prior to each insert?  I see there is a
>> ResourceChangeListener interface that I could probably use to
>> accomplish this, but I figured I'd ask in case there is a better way
>> to handle this case with pipelines.  What's the best approach?
>>
>>
>> Try trunk, it has a fix for this. Where if you get the
>> StatelessKnowledgeSession directly from the knowledgeagent every execute
>> will check for a new KnowledgeBase.
>> https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/
>>
>> https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/javadocs/stable/drools-api/org/drools/agent/KnowledgeAgent.html
>> KnowledgeAgent.newStatelessKnowledgeSession(KnowledgeSessionConfiguration conf)
>>  StatelessKnowledgeSession created from here will always have the execute()
>> method called against the latest built KnowledgeBase.
>>
>> So now you can just use that returned session with the pipeline and it
>> should always be using the latest rules.
>>
>> Mark
>>
>> I'm using 5.0.0.CR1.
>>
>> Thanks!
>> David
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>     
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090513/1c74d283/attachment.html 


More information about the rules-users mailing list