Can KieContainer load multiple packages? and what's the relationship between KieContainer and KieBase

我的未来我决定 提交于 2019-12-13 17:33:01

问题


I'm new to drools. The project has several Kjars which are built from Kie workbench. And in our program, we want to put all these Kjars into one KieContainer. But I can see from the document is when creating KieContainer, it need a releaseId as parameter. The parameter is GroupId/ArtifactId/version of the Kjar, meaning, the KieContainer is related to only 1 Kjar.

So how can I load these Jars to only one KieContainer? or it is impossbile to load several Kjars into one container?

Another confusion is what's the exact relationship between KieContainer and KieBase?

Really appreciate in advance to answer my problem.


回答1:


First, I know you only asked about KieContainer and KieBase, but I think it's important to know about all 5 KieConcepts to get a full picture:

  1. KieServices: allows you to create KieContainers.
  2. KieContainer: has references to all rules, functions, etc. A KieContainer can load a KieModule and its dependencies. A KieContainer can have 1 or more KieBases
  3. KieModule: Defines multiple KieBases and KieSessions. KieModules can include other KieModules. This means you can have a top level KieModule that contains assets from different domains. Here is a link to the schema for KieModule, showing all the options you can have.
  4. KieBase: represents a compiled version of a set of assets. You can have a Stateless and Stateful session with the same rules for example. Another option is to have one KieBase for one set of packages, and another KieBase for another set of packages.
  5. KieSession: represents an instance of the rule engine containing the rules in a KieBase. Each KieBase can have one or more KieSessions

To my knowledge it is not possible to load several different Kjars into one KieContainer.

So my recommendation would be to either

A) Find a way to combine everything in one Kjar so you can create a KieContainer with all of your assets. This documentation may help you understand if this is a valid option for you given your use case.

B) Create a new KieContainer for each version of the assets that you need and route accordingly based on input. This has a bigger memory footprint, but this may be the best option if you can't use a single Kjar.



来源:https://stackoverflow.com/questions/44881243/can-kiecontainer-load-multiple-packages-and-whats-the-relationship-between-kie

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!