Hi Tina,<div>It seems that you are using KAgent without incremental change set processing enabled. Thus, the kagent's internal kbase is recreated (re-instantiated) every time a change is detected. So, you must do:</div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br>session = </span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">kagent.getKnowledgeBase()</span><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">.newStatefulKnowledgeSession();</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">In order to do this you could add a kagent's event listener to be notified whenever the agent has rebuilt his kbase.</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Or, you could use incremental change set:</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">aconf.setProperty("drools.agent.newInstance", "false");</span></div><div>KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><span class="Apple-style-span" style="border-collapse: separate; font-family: arial; font-size: small; ">"test agent", kbase, aconf);</span> </span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">Using this feature, the changes are always applied in the current kbase, so there is no need to re-create your session.</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">For more information: </span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><a href="http://ilesteban.wordpress.com/2010/03/25/knowledge-agent-incremental-change-set-processing-and-binary-diff/">http://ilesteban.wordpress.com/2010/03/25/knowledge-agent-incremental-change-set-processing-and-binary-diff/</a></span></div>
<div><a href="http://ilesteban.wordpress.com/2010/05/26/knowledge-agent-incremental-change-set-build-implementation/">http://ilesteban.wordpress.com/2010/05/26/knowledge-agent-incremental-change-set-build-implementation/</a></div>
<div><br></div><div>Best,</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><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">2010/8/18 Tina Vießmann <span dir="ltr"><<a href="mailto:tviessmann@stud.hs-bremen.de">tviessmann@stud.hs-bremen.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
I've set up a knowledge agent the change set configuration. While
running the application I'm changing the rules file and the agent
detects the change and rebuidls the knowledge base. But after that
the output that should have changed didn't change.<br>
<br>
Thank you! :)<br>
<br>
Greetings<br>
Tina<br>
<br>
<br>
Here are the code snippets: <br>
<br>
<blockquote>ResourceFactory.getResourceChangeNotifierService().start();<br>
ResourceFactory.getResourceChangeScannerService().start();<br>
<br>
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("AITS CEP Engine Agent");<br>
kagent.applyChangeSet(ResourceFactory.newClassPathResource("changeset.xml"));<br>
<br>
KnowledgeBase knowledgeBase = kagent.getKnowledgeBase();<br>
<br>
session = knowledgeBase.newStatefulKnowledgeSession();<br>
</blockquote>
<br>
<br>
<blockquote><change-set
xmlns='<a href="http://drools.org/drools-5.0/change-set" target="_blank">http://drools.org/drools-5.0/change-set</a>'<br>
xmlns:xs='<a href="http://www.w3.org/2001/XMSchema-instance" target="_blank">http://www.w3.org/2001/XMSchema-instance</a>'<br>
xs:schmeaLocation='<a href="http://drools.org/drools-5.0/change-setdrools-change-set-5.0.xsd" target="_blank">http://drools.org/drools-5.0/change-setdrools-change-set-5.0.xsd</a>'
><br>
<br>
<add><br>
<resource source='classpath:testRule.drl' type='DRL'
/><br>
</add><br>
<br>
</change-set><br>
</blockquote>
<br>
<br>
The status information put out to the console are:<br>
<br>
[2010:08:230 16:08:93:debug] ResourceChangeScanner attempt to scan 1
resources<br>
[2010:08:230 16:08:93:debug] ResourceChangeScanner modified
resource=[ClassPathResource path='testRule.drl'] : 1282139449234 :
1282141364812<br>
[2010:08:230 16:08:93:debug] ResourceChangeNotification received
ChangeSet notification<br>
[2010:08:230 16:08:93:debug] ResourceChangeScanner thread is waiting
for 60 seconds.<br>
[2010:08:230 16:08:93:debug] ResourceChangeNotification processing
ChangeSet<br>
[2010:08:230 16:08:93:debug] ResourceChangeNotification ChangeSet
modified resource=[ClassPathResource path='testRule.drl'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@1acfa31<br>
[2010:08:230 16:08:93:debug] KnowledgeAgent received ChangeSet
changed notification<br>
[2010:08:230 16:08:93:info] KnowledgeAgent applying ChangeSet<br>
[2010:08:230 16:08:93:debug] KnowledgeAgent rebuilding KnowledgeBase
using ChangeSet<br>
[2010:08:230 16:08:109:debug] ResourceChangeNotification thread is
waiting for queue update<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent obtaining pkg
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='testRule.drl'] to
KnowledgeDefinition=[Rule name=Insert Watcher Into Knowledge Base,
agendaGroup=MAIN, salience=0, no-loop=false]<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:218:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1acfa31 to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='testRule.drl'] to
KnowledgeDefinition=[Rule name=Add Event to Watcher Set,
agendaGroup=MAIN, salience=0, no-loop=false]<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:218:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1acfa31 to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='testRule.drl'] to
KnowledgeDefinition=org.drools.rule.TypeDeclaration@1bed3d1<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:218:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1acfa31 to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='testRule.drl'] to
KnowledgeDefinition=org.drools.rule.TypeDeclaration@1f528ab<br>
[2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:234:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1acfa31 to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:234:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='testRule.drl'] to
KnowledgeDefinition=org.drools.rule.Function@1bb9829<br>
[2010:08:230 16:08:234:debug] KnowledgeAgent notifier subscribing to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:234:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1acfa31 to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:234:debug] KnowledgeAgent mapping
resource=[ClassPathResource path='testRule.drl'] to
KnowledgeDefinition=org.drools.rule.Function@eb840f<br>
[2010:08:230 16:08:234:debug] KnowledgeAgent notifier subscribing to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:234:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1acfa31 to
resource=[ClassPathResource path='testRule.drl']<br>
[2010:08:230 16:08:234:debug] KnowledgeAgent adding
KnowledgeDefinitionsPackage net.eads.astrium.aits.cep.rules<br>
[2010:08:230 16:08:250:info] KnowledgeAgent new KnowledgeBase now
built and in use<br>
[2010:08:230 16:08:250:debug] KnowledgeAgent finished rebuilding
KnowledgeBase using ChangeSet<br>
</div>
<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>
<br></blockquote></div><br></div>