<meta http-equiv="content-type" content="text/html; charset=utf-8">Maybe the new rules fail to compile. You can add an KnowledgeAgentEventListener to the agent to check for compilation errors.<div>Could you post some code snippet showing how are you creating the kagent, the kbase, etc.</div>
<div><br></div><div>You can take a look at some tests using newInstence=false here:</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><a href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentIncrementalChangeSetTest.java">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentIncrementalChangeSetTest.java</a> <br>
<div><br clear="all">Best Regards,</div><div><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Mon, Apr 18, 2011 at 1:31 PM, Mattias Avelin <span dir="ltr"><<a href="mailto:mattias.avelin@netlight.se">mattias.avelin@netlight.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks for the swift reply!<br>
<br>
I have configured my Knowledge Agent to reuse the same KnowledgeBase (set drools.agent.newInstance property to "false" in my KnowledgeAgentConfiguration) as described in the Expert documentation. But my stateful session keeps using the old rules event though I can see from the log output that the Knowledgebase has been updated.<br>
<br>
/Mattias<br>
________<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Esteban Aliverti [<a href="mailto:esteban.aliverti@gmail.com">esteban.aliverti@gmail.com</a>]<br>
Sent: Monday, April 18, 2011 16:49<br>
To: Rules Users List<br>
Subject: Re: [rules-users] Dynamic updates of stateful sessions<br>
<div class="im"><br>
By default, the Knowledge Agent creates a new kbase when changes in the monitored resources are detected. So the stateful sessions you had are not going to "see" the changes because they belong to a different kbase.<br>
If you want the agent to apply the changes to the current kbase, you need to set drools.agent.newInstance property to "false" in knowledge agent configuration.<br>
You can read about this here: <a href="http://ilesteban.wordpress.com/2010/03/25/knowledge-agent-incremental-change-set-processing-and-binary-diff/" target="_blank">http://ilesteban.wordpress.com/2010/03/25/knowledge-agent-incremental-change-set-processing-and-binary-diff/</a><br>
<br>
If you are defining the kagent using spring, you can use the "newInstence" attribute of <kagent> bean.<br>
<br>
Best Regards,<br>
<br>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
<br>
Esteban Aliverti<br>
- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>
- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br>
<br>
</div><div class="im">On Mon, Apr 18, 2011 at 11:41 AM, Mattias Avelin <<a href="mailto:mattias.avelin@netlight.se">mattias.avelin@netlight.se</a><mailto:<a href="mailto:mattias.avelin@netlight.se">mattias.avelin@netlight.se</a>>> wrote:<br>
We have a application in which we have both stateless & stateful sessions<br>
running. We're using the KnowledgeAgent and ChangeSets to automatically<br>
update our knowledge bases when the rules are changed.<br>
This works fine for our stateless sessions for which we are creating a new<br>
session for each request and if the rules have been updated this is<br>
reflected in next session we create.<br>
<br>
But for stateful sessions I'm not quite as sure on how to get it working. I<br>
can see in the logs that the KnowledgeBase is re-built when the<br>
KnowledgeAgent detects the updated rule files. But my "long running" session<br>
is does not reflect these changes (which it shouldn't right?). But how do we<br>
apply these changes to the stateful session without loosing all the facts I<br>
accumulated?<br>
<br>
The way I've solved it now is to keep a "last updated" timestamp for the<br>
knowledgeBase and a "created" timestamp for the session and then compare<br>
these before using the session. If the knowledgeBase's "update timestamp" is<br>
later that the sessions "creation timestamp" I create a new Session and then<br>
"manually" copy all facts from the former to the latter.<br>
<br>
Is this the way you would do this or is there a better way?<br>
<br>
Best Regards<br>
<br>
Mattias Avelin<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
</div><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><mailto:<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
<div class="im"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
</div>______________________________________________________________________<br>
This email has been scanned by the MessageLabs Email Security System.<br>
For more information please visit <a href="http://www.messagelabs.com/email" target="_blank">http://www.messagelabs.com/email</a><br>
______________________________________________________________________<br>
<div><div></div><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div></div>