[rules-users] KnowledgeAgent detects resource changes and updates but nothing changes

Esteban Aliverti esteban.aliverti at gmail.com
Wed Aug 18 10:50:05 EDT 2010


Hi Tina,
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:

session = kagent.getKnowledgeBase().newStatefulKnowledgeSession();

In order to do this you could add a kagent's event listener to be notified
whenever the agent has rebuilt his kbase.

Or, you could use incremental change set:

KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.newInstance", "false");
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("test
agent", kbase, aconf);

Using this feature, the changes are always applied in the current kbase, so
there is no need to re-create your session.

For more information:
http://ilesteban.wordpress.com/2010/03/25/knowledge-agent-incremental-change-set-processing-and-binary-diff/
http://ilesteban.wordpress.com/2010/05/26/knowledge-agent-incremental-change-set-build-implementation/

Best,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


2010/8/18 Tina Vießmann <tviessmann at stud.hs-bremen.de>

>  Hi,
>
> 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.
>
> Thank you! :)
>
> Greetings
> Tina
>
>
> Here are the code snippets:
>
> ResourceFactory.getResourceChangeNotifierService().start();
> ResourceFactory.getResourceChangeScannerService().start();
>
> KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("AITS CEP
> Engine Agent");
>
> kagent.applyChangeSet(ResourceFactory.newClassPathResource("changeset.xml"));
>
> KnowledgeBase knowledgeBase = kagent.getKnowledgeBase();
>
> session = knowledgeBase.newStatefulKnowledgeSession();
>
>
>
> <change-set xmlns='http://drools.org/drools-5.0/change-set'
>             xmlns:xs='http://www.w3.org/2001/XMSchema-instance'
>             xs:schmeaLocation='
> http://drools.org/drools-5.0/change-setdrools-change-set-5.0.xsd' >
>
>     <add>
>         <resource source='classpath:testRule.drl' type='DRL' />
>     </add>
>
> </change-set>
>
>
>
> The status information put out to the console are:
>
> [2010:08:230 16:08:93:debug] ResourceChangeScanner attempt to scan 1
> resources
> [2010:08:230 16:08:93:debug] ResourceChangeScanner modified
> resource=[ClassPathResource path='testRule.drl'] : 1282139449234 :
> 1282141364812
> [2010:08:230 16:08:93:debug] ResourceChangeNotification received ChangeSet
> notification
> [2010:08:230 16:08:93:debug] ResourceChangeScanner thread is waiting for 60
> seconds.
> [2010:08:230 16:08:93:debug] ResourceChangeNotification processing
> ChangeSet
> [2010:08:230 16:08:93:debug] ResourceChangeNotification ChangeSet modified
> resource=[ClassPathResource path='testRule.drl'] for
> listener=org.drools.agent.impl.KnowledgeAgentImpl at 1acfa31
> [2010:08:230 16:08:93:debug] KnowledgeAgent received ChangeSet changed
> notification
> [2010:08:230 16:08:93:info] KnowledgeAgent applying ChangeSet
> [2010:08:230 16:08:93:debug] KnowledgeAgent rebuilding KnowledgeBase using
> ChangeSet
> [2010:08:230 16:08:109:debug] ResourceChangeNotification thread is waiting
> for queue update
> [2010:08:230 16:08:218:debug] KnowledgeAgent obtaining pkg
> resource=[ClassPathResource path='testRule.drl']
> [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]
> [2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:218:debug] ResourceChangeNotification subscribing
> listener=org.drools.agent.impl.KnowledgeAgentImpl at 1acfa31 to
> resource=[ClassPathResource path='testRule.drl']
> [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]
> [2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:218:debug] ResourceChangeNotification subscribing
> listener=org.drools.agent.impl.KnowledgeAgentImpl at 1acfa31 to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:218:debug] KnowledgeAgent mapping
> resource=[ClassPathResource path='testRule.drl'] to
> KnowledgeDefinition=org.drools.rule.TypeDeclaration at 1bed3d1
> [2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:218:debug] ResourceChangeNotification subscribing
> listener=org.drools.agent.impl.KnowledgeAgentImpl at 1acfa31 to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:218:debug] KnowledgeAgent mapping
> resource=[ClassPathResource path='testRule.drl'] to
> KnowledgeDefinition=org.drools.rule.TypeDeclaration at 1f528ab
> [2010:08:230 16:08:218:debug] KnowledgeAgent notifier subscribing to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:234:debug] ResourceChangeNotification subscribing
> listener=org.drools.agent.impl.KnowledgeAgentImpl at 1acfa31 to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:234:debug] KnowledgeAgent mapping
> resource=[ClassPathResource path='testRule.drl'] to
> KnowledgeDefinition=org.drools.rule.Function at 1bb9829
> [2010:08:230 16:08:234:debug] KnowledgeAgent notifier subscribing to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:234:debug] ResourceChangeNotification subscribing
> listener=org.drools.agent.impl.KnowledgeAgentImpl at 1acfa31 to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:234:debug] KnowledgeAgent mapping
> resource=[ClassPathResource path='testRule.drl'] to
> KnowledgeDefinition=org.drools.rule.Function at eb840f
> [2010:08:230 16:08:234:debug] KnowledgeAgent notifier subscribing to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:234:debug] ResourceChangeNotification subscribing
> listener=org.drools.agent.impl.KnowledgeAgentImpl at 1acfa31 to
> resource=[ClassPathResource path='testRule.drl']
> [2010:08:230 16:08:234:debug] KnowledgeAgent adding
> KnowledgeDefinitionsPackage net.eads.astrium.aits.cep.rules
> [2010:08:230 16:08:250:info] KnowledgeAgent new KnowledgeBase now built and
> in use
> [2010:08:230 16:08:250:debug] KnowledgeAgent finished rebuilding
> KnowledgeBase using ChangeSet
>
> _______________________________________________
> 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/20100818/d7ceee58/attachment.html 


More information about the rules-users mailing list