[rules-users] KnowledgeAgent and Pipeline

Mark Proctor mproctor at codehaus.org
Tue May 12 16:43:17 EDT 2009


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 
<https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/javadocs/stable/drools-api/org/drools/agent/KnowledgeAgent.html#newStatelessKnowledgeSession%28org.drools.runtime.KnowledgeSessionConfiguration%29>*(KnowledgeSessionConfiguration 
<https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/javadocs/stable/drools-api/org/drools/runtime/KnowledgeSessionConfiguration.html> 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
>
>
>   

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


More information about the rules-users mailing list