Este contenido no está disponible en el idioma seleccionado.
Chapter 3. Project deployment without Business Central
As an alternative to developing and deploying projects in the Business Central interface, you can use independent Maven projects or your own Java applications to develop Red Hat Process Automation Manager projects and deploy them in KIE containers (deployment units) to a configured Process Server. You can then use the Process Server REST API to start, stop, or remove the KIE containers that contain the services and their project versions that you have built and deployed. This flexibility enables you to continue to use your existing application work flow to develop business assets using Red Hat Process Automation Manager features.
Projects in Business Central are packaged automatically when you build and deploy the projects. For projects outside of Business Central, such as independent Maven projects or projects within a Java application, you must configure the KIE module descriptor settings in an appended kmodule.xml file or directly in your Java application in order to build and deploy the projects.
3.1. Configuring a KIE module descriptor file Copiar enlaceEnlace copiado en el portapapeles!
A KIE module is a Maven project or module with an additional metadata file META-INF/kmodule.xml. All Red Hat Process Automation Manager projects require a kmodule.xml file in order to be properly packaged and deployed. This kmodule.xml file is a KIE module descriptor that defines the KIE base and KIE session configurations for the assets in a project. A KIE base is a repository that contains all rules, processes, and other business assets in Red Hat Process Automation Manager but does not contain any runtime data. A KIE session stores and executes runtime data and is created from a KIE base or directly from a KIE container if you have defined the KIE session in the kmodule.xml file.
If you create projects outside of Business Central, such as independent Maven projects or projects within a Java application, you must configure the KIE module descriptor settings in an appended kmodule.xml file or directly in your Java application in order to build and deploy the projects.
Procedure
In the
~/resources/META-INFdirectory of your project, create akmodule.xmlmetadata file with at least the following content:<?xml version="1.0" encoding="UTF-8"?> <kmodule xmlns="http://www.drools.org/xsd/kmodule"> </kmodule>
<?xml version="1.0" encoding="UTF-8"?> <kmodule xmlns="http://www.drools.org/xsd/kmodule"> </kmodule>Copy to Clipboard Copied! Toggle word wrap Toggle overflow This empty
kmodule.xmlfile is sufficient to produce a single default KIE base that includes all files found under your projectresourcespath. The default KIE base also includes a single default KIE session that is triggered when you create a KIE container in your application at build time.The following example is a more advanced
kmodule.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example defines two KIE bases. Specific
packagesof rule assets are included with both KIE bases. When you specify packages in this way, you must organize your rule files in a folder structure that reflects the specified packages. Two KIE sessions are instantiated from theKBase1KIE base, and one KIE session fromKBase2. The KIE session fromKBase2is astatelessKIE session, which means that data from a previous invocation of the KIE session (the previous session state) is discarded between session invocations. That KIE session also specifies a file (or a console) logger, aWorkItemHandler, and listeners of the three supported types shown:ruleRuntimeEventListener,agendaEventListenerandprocessEventListener. The<configuration>element defines optional properties that you can use to further customize yourkmodule.xmlfile.As an alternative to manually appending a
kmodule.xmlfile to your project, you can use aKieModuleModelinstance within your Java application to programatically create akmodule.xmlfile that defines the KIE base and a KIE session, and then add all resources in your project to the KIE virtual file systemKieFileSystem.Creating
kmodule.xmlprogrammatically and adding it toKieFileSystemCopy to Clipboard Copied! Toggle word wrap Toggle overflow After you configure the
kmodule.xmlfile either manually or programmatically in your project, retrieve the KIE bases and KIE sessions from the KIE container to verify the configurations:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If
KieBaseorKieSessionhave been configured asdefault="true"in thekmodule.xmlfile, as in the previouskmodule.xmlexample, you can retrieve them from the KIE container without passing any names:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information about the kmodule.xml file, download the Red Hat Process Automation Manager [VERSION] Source Distribution ZIP file from the Red Hat Customer Portal and see the kmodule.xsd XML schema located at $FILE_HOME/rhpam-$VERSION-sources/kie-api-parent-$VERSION/kie-api/src/main/resources/org/kie/api/.
3.1.1. KIE module configuration properties Copiar enlaceEnlace copiado en el portapapeles!
The optional <configuration> element in the KIE module descriptor file (kmodule.xml) of your project defines property key and value pairs that you can use to further customize your kmodule.xml file.
Example configuration property in a kmodule.xml file
The following are the <configuration> property keys and values supported in the KIE module descriptor file (kmodule.xml) for your project:
- drools.dialect.default
Sets the default Drools dialect.
Supported values:
java,mvel<property key="drools.dialect.default" value="java"/>
<property key="drools.dialect.default" value="java"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.accumulate.function.$FUNCTION
Links a class that implements an accumulate function to a specified function name, which allows you to add custom accumulate functions into the decision engine.
<property key="drools.accumulate.function.hyperMax" value="org.drools.custom.HyperMaxAccumulate"/>
<property key="drools.accumulate.function.hyperMax" value="org.drools.custom.HyperMaxAccumulate"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.evaluator.$EVALUATION
Links a class that implements an evaluator definition to a specified evaluator name so that you can add custom evaluators into the decision engine. An evaluator is similar to a custom operator.
<property key="drools.evaluator.soundslike" value="org.drools.core.base.evaluators.SoundslikeEvaluatorsDefinition"/>
<property key="drools.evaluator.soundslike" value="org.drools.core.base.evaluators.SoundslikeEvaluatorsDefinition"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.dump.dir
Sets a path to the Red Hat Process Automation Manager
dump/logdirectory.<property key="drools.dump.dir" value="$DIR_PATH/dump/log"/>
<property key="drools.dump.dir" value="$DIR_PATH/dump/log"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.defaultPackageName
Sets a default package for the business assets in your project.
<property key="drools.defaultPackageName" value="org.domain.pkg1"/>
<property key="drools.defaultPackageName" value="org.domain.pkg1"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.parser.processStringEscapes
Sets the String escape function. If this property is set to
false, the\ncharacter will not be interpreted as the newline character.Supported values:
true(default),false<property key="drools.parser.processStringEscapes" value="true"/>
<property key="drools.parser.processStringEscapes" value="true"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.kbuilder.severity.$DUPLICATE
Sets a severity for instances of duplicate rules, processes, or functions reported when a KIE base is built. For example, if you set
duplicateRuletoERROR, then an error is generated for any duplicated rules detected when the KIE base is built.Supported key suffixes:
duplicateRule,duplicateProcess,duplicateFunctionSupported values:
INFO,WARNING,ERROR<property key="drools.kbuilder.severity.duplicateRule" value="ERROR"/>
<property key="drools.kbuilder.severity.duplicateRule" value="ERROR"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.propertySpecific
Sets the property reactivity of the decision engine.
Supported values:
DISABLED,ALLOWED,ALWAYS<property key="drools.propertySpecific" value="ALLOWED"/>
<property key="drools.propertySpecific" value="ALLOWED"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - drools.lang.level
Sets the DRL language level.
Supported values:
DRL5,DRL6,DRL6_STRICT(default)<property key="drools.lang.level" value="DRL_STRICT"/>
<property key="drools.lang.level" value="DRL_STRICT"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.1.2. KIE base attributes supported in KIE modules Copiar enlaceEnlace copiado en el portapapeles!
A KIE base is a repository that you define in the KIE module descriptor file (kmodule.xml) for your project and contains all rules, processes, and other business assets in Red Hat Process Automation Manager. When you define KIE bases in the kmodule.xml file, you can specify certain attributes and values to further customize your KIE base configuration.
Example KIE base configuration in a kmodule.xml file
The following are the kbase attributes and values supported in the KIE module descriptor file (kmodule.xml) for your project:
| Attribute | Supported values | Description |
|---|---|---|
|
| Any name |
Defines the name that retrieves |
|
| Comma-separated list of other KIE base objects in the KIE module |
Defines other KIE base objects and artifacts to be included in this KIE base. A KIE base can be contained in multiple KIE modules if you declare it as a dependency in the |
|
| Comma-separated list of packages to include in the KIE base
Default: |
Defines packages of artifacts (such as rules and processes) to be included in this KIE base. By default, all artifacts in the |
|
|
Default: | Determines whether a KIE base is the default KIE base for a module so that it can be created from the KIE container without passing any name. Each module can have only one default KIE base. |
|
|
Default: |
Defines the behavior of Red Hat Process Automation Manager when a new fact is inserted into the working memory. If set to |
|
|
Default: |
Determines how events are processed in the KIE base. If this property is set to |
|
|
Default: | Determines whether the declarative agenda is enabled or not. |
3.1.3. KIE session attributes supported in KIE modules Copiar enlaceEnlace copiado en el portapapeles!
A KIE session stores and executes runtime data and is created from a KIE base or directly from a KIE container if you have defined the KIE session in the KIE module descriptor file (kmodule.xml) for your project. When you define KIE bases and KIE sessions in the kmodule.xml file, you can specify certain attributes and values to further customize your KIE session configuration.
Example KIE session configuration in a kmodule.xml file
The following are the ksession attributes and values supported in the KIE module descriptor file (kmodule.xml) for your project:
| Attribute | Supported values | Description |
|---|---|---|
|
| Any name |
Defines the name that retrieves |
|
|
Default: |
Determines whether data is retained ( |
|
|
Default: | Determines whether a KIE session is the default session for a module so that it can be created from the KIE container without passing any name. Each module can have only one default KIE session. |
|
|
Default: | Determines whether event time stamps are assigned by the system clock or by a pseudo clock controlled by the application. This clock is especially useful for unit testing on temporal rules. |
|
|
Default: | Defines the type of belief system used by the KIE session. A belief system deduces the truth from knowledge (facts). For example, if a new fact is inserted based on another fact which is later removed from the decision engine, the system can determine that the newly inserted fact should be removed as well. |
3.2. Packaging and deploying a Red Hat Process Automation Manager project in Maven Copiar enlaceEnlace copiado en el portapapeles!
If you want to deploy a Maven project outside of Business Central to a configured Process Server, you can edit the project pom.xml file to package your project as a KJAR file and add a kmodule.xml file with the KIE base and KIE session configurations for the assets in your project.
Prerequisites
- You have a Mavenized project that contains Red Hat Process Automation Manager business assets.
-
Process Server is installed and
kie-serveruser access is configured. For installation options, see Planning a Red Hat Process Automation Manager installation.
Procedure
In the
pom.xmlfile of your Maven project, set the packaging type tokjarand add thekie-maven-pluginbuild component:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
kjarpackaging type activates thekie-maven-plugincomponent to validate and pre-compile artifact resources. The<version>is the Maven artifact version for Red Hat Process Automation Manager currently used in your project (for example, 7.18.0.Final-redhat-00002). These settings are required to properly package the Maven project for deployment.NoteInstead of specifying a Red Hat Process Automation Manager
<version>for individual dependencies, consider adding the Red Hat Business Automation bill of materials (BOM) dependency to your projectpom.xmlfile. The Red Hat Business Automation BOM applies to both Red Hat Decision Manager and Red Hat Process Automation Manager. When you add the BOM files, the correct versions of transitive dependencies from the provided Maven repositories are included in the project.Example BOM dependency:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about the Red Hat Business Automation BOM, see What is the mapping between Red Hat Process Automation Manager and the Maven library version?.
Add the following dependencies to the
pom.xmlfile to generate an executable rule model from your rule assets:-
drools-canonical-model: Enables an executable canonical representation of a rule set model that is independent from Red Hat Process Automation Manager -
drools-model-compiler: Compiles the executable model into Red Hat Process Automation Manager internal data structures so that it can be executed by the decision engine
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Executable rule models are embeddable models that provide a Java-based representation of a rule set for execution at build time. The executable model is a more efficient alternative to the standard asset packaging in Red Hat Process Automation Manager and enables KIE containers and KIE bases to be created more quickly, especially when you have large lists of DRL (Drools Rule Language) files and other Red Hat Process Automation Manager assets.
For more information about executable rule models, see Designing a decision service using DRL rules.
To enable Decision Model and Notation (DMN) executable models for DMN assets in your project (if applicable), also add the
kie-dmn-coredependency in thepom.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
In the
~/resourcesdirectory of your Maven project, create aMETA-INF/kmodule.xmlmetadata file with at least the following content:<?xml version="1.0" encoding="UTF-8"?> <kmodule xmlns="http://www.drools.org/xsd/kmodule"> </kmodule>
<?xml version="1.0" encoding="UTF-8"?> <kmodule xmlns="http://www.drools.org/xsd/kmodule"> </kmodule>Copy to Clipboard Copied! Toggle word wrap Toggle overflow This
kmodule.xmlfile is a KIE module descriptor that is required for all Red Hat Process Automation Manager projects. You can use the KIE module to define one or more KIE bases and one or more KIE sessions from each KIE base.For more information about
kmodule.xmlconfiguration, see Section 3.1, “Configuring a KIE module descriptor file”.In the relevant resource in your Maven project, configure a
.javaclass to create a KIE container and a KIE session to load the KIE base:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, the KIE container reads the files to be built from the class path for a
testAppproject. TheKieServicesAPI enables you to access all KIE building and runtime configurations.You can also create the KIE container by passing the project
ReleaseIdto theKieServicesAPI. TheReleaseIdis generated from theGroupId,ArtifactId, andVersion(GAV) values in the projectpom.xmlfile.Copy to Clipboard Copied! Toggle word wrap Toggle overflow In a command terminal, navigate to your Maven project directory and run the following command to build the project from an executable model:
mvn clean install -DgenerateModel=<VALUE>
mvn clean install -DgenerateModel=<VALUE>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
-DgenerateModel=<VALUE>property enables the project to be built as a model-based KJAR instead of a DRL-based KJAR, so that rule assets are built in an executable rule model.Replace
<VALUE>with one of three values:-
YES: Generates the executable model corresponding to the DRL files in the original project and excludes the DRL files from the generated KJAR. -
WITHDRL: Generates the executable model corresponding to the DRL files in the original project and also adds the DRL files to the generated KJAR for documentation purposes (the KIE base is built from the executable model regardless). -
NO: Does not generate the executable model.
Example build command:
mvn clean install -DgenerateModel=YES
mvn clean install -DgenerateModel=YESCopy to Clipboard Copied! Toggle word wrap Toggle overflow For DMN executable models, run the following command:
mvn clean install -DgenerateDMNModel=YES
mvn clean install -DgenerateDMNModel=YESCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the build fails, address any problems described in the command line error messages and try again to validate the files until the build is successful.
-
After you successfully build and test the project locally, deploy the project to the remote Maven repository:
mvn deploy
mvn deployCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3. Packaging and deploying a Red Hat Process Automation Manager project in a Java application Copiar enlaceEnlace copiado en el portapapeles!
If you want to deploy a project from within your own Java application to a configured Process Server, you can use a KieModuleModel instance to programatically create a kmodule.xml file that defines the KIE base and a KIE session, and then add all resources in your project to the KIE virtual file system KieFileSystem.
Prerequisites
- You have a Java application that contains Red Hat Process Automation Manager business assets.
-
Process Server is installed and
kie-serveruser access is configured. For installation options, see Planning a Red Hat Process Automation Manager installation.
Procedure
In your client application, add the following dependencies to the relevant classpath of your Java project to generate an executable rule model from your rule assets:
-
drools-canonical-model: Enables an executable canonical representation of a rule set model that is independent from Red Hat Process Automation Manager -
drools-model-compiler: Compiles the executable model into Red Hat Process Automation Manager internal data structures so that it can be executed by the decision engine
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Executable rule models are embeddable models that provide a Java-based representation of a rule set for execution at build time. The executable model is a more efficient alternative to the standard asset packaging in Red Hat Process Automation Manager and enables KIE containers and KIE bases to be created more quickly, especially when you have large lists of DRL (Drools Rule Language) files and other Red Hat Process Automation Manager assets.
For more information about executable rule models, see Designing a decision service using DRL rules.
To enable Decision Model and Notation (DMN) executable models for DMN assets in your project (if applicable), also add the
kie-dmn-coredependency in thepom.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
<version>is the Maven artifact version for Red Hat Process Automation Manager currently used in your project (for example, 7.18.0.Final-redhat-00002).NoteInstead of specifying a Red Hat Process Automation Manager
<version>for individual dependencies, consider adding the Red Hat Business Automation bill of materials (BOM) dependency to your projectpom.xmlfile. The Red Hat Business Automation BOM applies to both Red Hat Decision Manager and Red Hat Process Automation Manager. When you add the BOM files, the correct versions of transitive dependencies from the provided Maven repositories are included in the project.Example BOM dependency:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about the Red Hat Business Automation BOM, see What is the mapping between Red Hat Process Automation Manager and the Maven library version?.
-
Use the
KieServicesAPI to create aKieModuleModelinstance with the desired KIE base and KIE session. TheKieServicesAPI enables you to access all KIE building and runtime configurations. TheKieModuleModelinstance generates thekmodule.xmlfile for your project.For more information about
kmodule.xmlconfiguration, see Section 3.1, “Configuring a KIE module descriptor file”.Convert your
KieModuleModelinstance into XML and add the XML toKieFileSystem.Creating
kmodule.xmlprogrammatically and adding it toKieFileSystemCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add any remaining Red Hat Process Automation Manager assets that you use in your project to your
KieFileSysteminstance. The artifacts must be in a Maven project file structure.Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, the project assets are added both as a
Stringvariable and as aResourceinstance. You can create theResourceinstance using theKieResourcesfactory, also provided by theKieServicesinstance. TheKieResourcesclass provides factory methods to convertInputStream,URL, andFileobjects, or aStringrepresenting a path of your file system to aResourceinstance that theKieFileSystemcan manage.You can also explicitly assign a
ResourceTypeproperty to aResourceobject when you add project artifacts toKieFileSystem:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use
KieBuilderwithbuildAll( ExecutableModelProject.class )specified to build the content ofKieFileSystemfrom an executable model, and create a KIE container to deploy it:Copy to Clipboard Copied! Toggle word wrap Toggle overflow After
KieFileSystemis built from the executable model, the resultingKieSessionuses constraints based on lambda expressions instead of less-efficientmvelexpressions. To build the project in the standard method without an executable model, do not specify any argument inbuildAll().A build
ERRORindicates that the project compilation failed, noKieModulewas produced, and nothing was added to theKieRepositorysingleton. AWARNINGor anINFOresult indicates that the compilation of the project was successful, with information about the build process.
3.4. Starting a service in Process Server Copiar enlaceEnlace copiado en el portapapeles!
If you have deployed Red Hat Process Automation Manager assets from a Maven or Java project outside of Business Central, you use a Process Server REST API call to start the KIE container (deployment unit) and the services in it. You can use the Process Server REST API to start services regardless of your deployment type, including deployment from Business Central, but projects deployed from Business Central either are started automatically or can be started within the Business Central interface.
Prerequisite
Process Server is installed and kie-server user access is configured. For installation options, see Planning a Red Hat Process Automation Manager installation.
Procedure
In your command terminal, run the following API request to load a service into a KIE container in the Process Server and to start it:
curl --user "<username>:<password>" -H "Content-Type: application/json" -X PUT -d '{"container-id" : "<containerID>","release-id" : {"group-id" : "<groupID>","artifact-id" : "<artifactID>","version" : "<version>"}}' http://<serverhost>:<serverport>/kie-server/services/rest/server/containers/<containerID>
$ curl --user "<username>:<password>" -H "Content-Type: application/json" -X PUT -d '{"container-id" : "<containerID>","release-id" : {"group-id" : "<groupID>","artifact-id" : "<artifactID>","version" : "<version>"}}' http://<serverhost>:<serverport>/kie-server/services/rest/server/containers/<containerID>
Replace the following values:
-
<username>, <password>: The user name and password of a user with the
kie-serverrole. - <containerID>: The identifier for the KIE container (deployment unit). You can use any random identifier but it must be the same in both places in the command (the URL and the data).
- <groupID>, <artifactID>, <version>: The project GAV values.
-
<serverhost>: The host name for the Process Server, or
localhostif you are running the command on the same host as the Process Server. - <serverport>: The port number for the Process Server.
Example:
curl --user "rhpamAdmin:password@1" -H "Content-Type: application/json" -X PUT -d '{"container-id" : "kie1","release-id" : {"group-id" : "org.kie.server.testing","artifact-id" : "container-crud-tests1","version" : "2.1.0.GA"}}' http://localhost:39043/kie-server/services/rest/server/containers/kie1
curl --user "rhpamAdmin:password@1" -H "Content-Type: application/json" -X PUT -d '{"container-id" : "kie1","release-id" : {"group-id" : "org.kie.server.testing","artifact-id" : "container-crud-tests1","version" : "2.1.0.GA"}}' http://localhost:39043/kie-server/services/rest/server/containers/kie1
3.5. Stopping and removing a service in Process Server Copiar enlaceEnlace copiado en el portapapeles!
If you have started Red Hat Process Automation Manager services from a Maven or Java project outside of Business Central, you use a Process Server REST API call to stop and remove the KIE container (deployment unit) containing the services. You can use the Process Server REST API to stop services regardless of your deployment type, including deployment from Business Central, but services from Business Central can also be stopped within the Business Central interface.
Prerequisite
Process Server is installed and kie-server user access is configured. For installation options, see Planning a Red Hat Process Automation Manager installation.
Procedure
In your command terminal, run the following API request to stop and remove a KIE container with services on Process Server:
curl --user "<username>:<password>" -X DELETE http://<serverhost>:<serverport>/kie-server/services/rest/server/containers/<containerID>
$ curl --user "<username>:<password>" -X DELETE http://<serverhost>:<serverport>/kie-server/services/rest/server/containers/<containerID>
Replace the following values:
-
<username>, <password>: The user name and password of a user with the
kie-serverrole. - <containerID>: The identifier for the KIE container (deployment unit). You can use any random identifier but it must be the same in both places in the command (the URL and the data).
-
<serverhost>: The host name for the Process Server, or
localhostif you are running the command on the same host as the Process Server. - <serverport>: The port number for the Process Server.
Example:
curl --user "rhpamAdmin:password@1" -X DELETE http://localhost:39043/kie-server/services/rest/server/containers/kie1
curl --user "rhpamAdmin:password@1" -X DELETE http://localhost:39043/kie-server/services/rest/server/containers/kie1