[rules-users] Is it possible to update KnowledgeBase inside a rule?

Wolfgang Laun wolfgang.laun at gmail.com
Fri Jun 28 01:35:33 EDT 2013


That's a rather extreme way of controlling the business logic. Have
you investigated all other options?

The API calls you want are:
KnowledgeBuilder kbuilder = ...
kbuilder.add(...);
ksession.getKnowledgeBase().addKnowledgePackages(kbuilder.getKnowledgePackages());

In RHS code you can do:
  kcontext.getKnowledgeRuntime().getKnowledgeBase()...

BTW: The section "The Right Hand Side (then)" in the Expert manual
tells you this, you just have to read it ;-)

-W


On 27/06/2013, Sonata <plz.write.to at gmail.com> wrote:
> Say I want to change the loaded packages dynamically base on some Business
> logic,
> is it possible to update the KnowledgeBase in rule files (not in Java) like
> calling addKnowledgePackages() removeKnowledgePackage() etc.?
>
> If it is possible, how do you make it so that the current session is
> updated
> with the changes and re-fire for the new rules?
>
> Or, how do you make it so that the current session is not affected but the
> next session will be using the updated KnowledgeBase?
>
> Thank you
>
> P.S. I am using 5.5.0.Final
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Is-it-possible-to-update-KnowledgeBase-inside-a-rule-tp4024578.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list