The Kmodule.xml file is stored under the src/main/resources/meta-inf/folder.
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <Kmodulexmlns= "Http://jboss.org/kie/6.0.0/kmodule">3 <Kbasename= "Rules"Packages= "Rules">4 <ksessionname= "Ksession-rules"/>5 </Kbase>6 <Kbasename= "Dtables"Packages= "Dtables">7 <ksessionname= "Ksession-dtables"/>8 </Kbase>9 </Kmodule>
View Code
The definition of this Kmodule.xml file is very simple, but it is also easy to understand:
- A kmodule contains two kbase, this is our example of the two use cases, respectively, corresponding to the DRL rule file example, a corresponding Excel table rule example.
- Each kbase has a name that can take arbitrary strings, but not duplicate names.
- Then there is a packages, you can see the packages inside the string is actually src/main/resources the name of the folder below, or called the package name, the rule engine will find the rule definition file according to the package defined here. You can define multiple packages at the same time, separated by commas.
- Each kbase below can contain multiple ksession, of course, in this case we have customized one.
- Each ksession has a name, and the name can be any string, but it cannot be duplicated.
- The Name property inside Kbase and Ksession is not repeatable globally.
- Kbase and Ksession In fact there are many other properties, but here is not very important, first of all, we will explain the following.
Properties of the Kbase:
| Property name |
Default Value |
valid value |
Description |
| Name |
None |
Any |
The name of the Kiebase, this property is mandatory and must be set. |
| Includes |
None |
Comma-delimited list of kiebase names |
means that this kiebase will contain the rule, process definition product files for all include Kiebase. The non-mandatory attribute. |
| Packages |
All |
Comma-delimited list of strings |
By default, all rule files under the Resources directory (subdirectories) will be included. You can also specify a specific directory under the rules file, through a comma can contain multiple directories under the article file. |
| Default |
False |
True, False |
Indicates that the current kiebase is not the default, if it is the default, you can find the kiebase without a name, but each module can have a maximum of one kiebase. |
| Equalsbehavior |
Identity |
Identity, equality |
As the name implies, the act of "equals" is defined, and this equals is for fact, and when inserting a fact into working memory, the Drools engine checks to see if that fact already exists. Use existing facthandle if it exists, or create a new one. The basis of the existence of a fact is determined by the way the attribute is defined: set to identity, is to determine whether the object exists, can be understood as = = To determine whether it is the same object, if the property is set to equality, is to judge by the Equals method of the fact object. |
| Eventprocessingmode |
Cloud |
Cloud, Stream |
This property is temporarily ignored, and will be learned in the following CEP (Complex event Processing: Compound event Processing) section. |
| Declarativeagenda |
Disabled |
Disabled, Enabled |
This is a high-level function switch, after opening the rules will be able to control the execution of some rules or not, for the time being not understood well, after understanding and then with a special chapter. |
Properties of the Ksession:
| Property name |
Default Value |
valid value |
Description |
| Name |
None |
Any |
The name of the kiesession, which must be unique and mandatory, must be set. |
| Type |
Stateful |
Stateful, stateless |
Defines whether the session is stateful (stateful) or stateless (stateless), a stateful session can be executed multiple times with working memory, while stateless can only be performed once. |
| Default |
False |
True, False |
Defines whether the session is the default, and if it is the default, you can create a session without using the name of the session, and there can be at most one default session in the same module. |
| Clocktype |
Realtime |
Realtime, Pseudo |
Defines the clock type, which is used on event handling, on compound event processing, where realtime is used for the system clock, while pseudo is used for simulation with unit tests. Don't bother about it for the moment. |
| Beliefsystem |
Simple |
Simple, JTMS, defeasible |
I haven't figured it out yet, and I'll talk about it after we figure it out. |
Kmodule.xml parsing in drools6.5.0 version of the Java Rules Engine