[rules-users] Creating a KnowledgeBase using a KnowledgeAgent, KnowledgeAgentConfiguration and KnowledgeBaseConfiguration

Esteban Aliverti esteban.aliverti at gmail.com
Mon Aug 23 08:35:10 EDT 2010


I think that is the minimum code needed to create a kagent with custom
configuration.
The only line you could remove is:

kbase = kagent.getKnowledgeBase();

Because you are using incremental change-set processing (
drools.agent.newInstance = false), you don't need to obtain a reference to
the new kbase, because there is no new kbase. The agent will use the same
kbase you provided.

If you don't want to use incremental change-set processing, then you must
keep that line, and you could remove any reference to
KnowledgeAgentConfiguration.

Best,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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


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

>  Hi,
>
> I want to create a KnowledgeBase using stream processing mode, getting its
> resources from an change-set xml and getting the updated when resources are
> changed. So far I'm aware I need a KnowledgeAgent and a configuration for
> the kagent and the kbase.
> My code is:
>
> // create knowledge base
>
> // knowledge base configuration
> KnowledgeBaseConfiguration kbaseConf =
> KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
> kbaseConf.setOption(EventProcessingOption.STREAM);
>
> // knowledge base
> KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConf);
>
>
> // create knowledge agent
>
> // create knowledge agent configuration
> KnowledgeAgentConfiguration kagentConf =
> KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
> //enable incremental knowledge base build
> kagentConf.setProperty("drools.agent.newInstance", "false");
> //create knowledge agent
> KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("AITS CEP
> Engine Agent", kbase, kagentConf);
>
>
> // apply change-set XML to knowledge agent
>
> kagent.applyChangeSet(ResourceFactory.newClassPathResource("changeset.xml"));
>
> //  get updated knowledge base object
> kbase = kagent.getKnowledgeBase();
>
> // create session
> session = kbase.newStatefulKnowledgeSession();
>
>
> Can it be done in a more compact way?
>
> Thank you! :)
> Tina
>
> _______________________________________________
> 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/20100823/39211dfa/attachment.html 


More information about the rules-users mailing list