Skip to content

Need advice on specific use case of adding rules dynamically  #2

@AdVanOmmen

Description

@AdVanOmmen

Hi Duncan,

Your drools-incremental-update project is very instructive. I tried to adapt it to the following use case in the latest 7.7.0.Final release of Drools:

  • We have a (k) jar publishing a compiled set of bpmn and drl files. It has a name of "rules".
  • In another maven project we add this as a dependency to create one Kiebase with using the KieServices getKieClassPathContainer() and getKieBaseModel("rules") to repeatibly create a KieSession from it with newKieSession();

Now for the more difficult part:

  • We would like to use this in a web application where the user may type an additional rule or two. These rules should be combined with the basic KieBase, so we can run drools with this and server the results to the user.
  • This seems to call for a dynamic/programmatic build of this newly combined Kiebase.

Our first attempt was to build on the code in this project by creating a new KieBaseModel named "customrules" and use the addInclude into the kmodel.xml with the name "rules" into the KieFileSystem together with the additional drl

Via the KieBuilder created from this KieFIleSystem this did not work as expected: showing in the results:

Error Messages:
Message [id=1, kieBase=customrules, level=ERROR, path=src/main/resources/META-INF/kmodule.xml, line=0, column=0
   text=Unable to build KieBase, could not find include: rules]

In the same method it proved easy to get to the "rules" by creating a KieClassPathContainer and invocation of getKieBase("rules")

Regards,
Ad van Ommen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions