Este contenido no está disponible en el idioma seleccionado.
Chapter 6. Executing rules
After you create rules in Business Central, you can build and deploy your project and execute rules locally or on Process Server to test your rules.
Procedure
-
In Business Central, go to Menu
Design Projects and click the project name. - In the upper-right corner, click Build and then Deploy to build the project and deploy it to Process Server. If the build fails, address any problems described in the Alerts panel at the bottom of the screen. For more information about deploying projects, see Packaging and deploying a Red Hat Process Automation Manager project.
Open the
pom.xmlfile of your client application and add the following dependencies, if not added already:-
kie-ci: Enables your client application to load Business Central project data locally usingReleaseId -
kie-server-client: Enables your client application to interact remotely with assets on Process Server -
slf4j: (Optional) Enables your client application to use Simple Logging Facade for Java (SLF4J) to return debug logging information after you interact with Process Server
Example dependencies for Red Hat Process Automation Manager 7.0 in a client application
pom.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteFor available versions of these artifacts, search the group ID and artifact ID in the MVNRepository online and select the Redhat GA tab where applicable. For more information about Maven dependencies and using the Bill of Materials (BOM) in Red Hat Process Automation Manager, see What is the mapping between Red Hat Process Automation Manager and Maven library version?.
-
Ensure that the dependencies for artifacts containing model classes are defined in the client application
pom.xmlfile exactly as they appear in thepom.xmlfile of the deployed project. If dependencies for model classes differ between the client application and your projects, execution errors can occur.To view the project
pom.xmlin Business Central, select any existing asset in the project and then in the Project Explorer menu on the left side of the screen, click the Customize View gear icon and select Repository Viewpom.xml. For example, the following is a
Personclass dependency as it appears in both the client and deployed projectpom.xmlfiles:<dependency> <groupId>com.sample</groupId> <artifactId>Person</artifactId> <version>1.0.0</version> </dependency>
<dependency> <groupId>com.sample</groupId> <artifactId>Person</artifactId> <version>1.0.0</version> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you added the
slf4jdependency to the client applicationpom.xmlfile for debug logging, create asimplelogger.propertiesfile on the relevant classpath (for example, insrc/main/resources/META-INFin Maven) with the following content:org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.defaultLogLevel=debugCopy to Clipboard Copied! Toggle word wrap Toggle overflow In your client application, create a
.javamain class containing the necessary imports and amain()method to load the knowledge base, insert facts, and execute the rules.For example, a
Personobject in a project contains getter and setter methods to set and retrieve the first name, last name, hourly rate, and the wage of a person. The followingWagerule in a project calculates the wage and hourly rate values and displays a message based on the result:Copy to Clipboard Copied! Toggle word wrap Toggle overflow To test this rule locally outside of Process Server (if desired), configure the
.javaclass to import KIE services, a KIE container, and a KIE session, and then use themain()method to fire all rules against a defined fact model:Executing rules locally
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To test this rule on Process Server, configure the
.javaclass with the imports and rule execution information similarly to the local example, and additionally specify KIE services configuration and KIE services client details:Executing rules on Process Server
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the configured
.javaclass from your project directory. You can run the file in your development platform (such as Red Hat JBoss Developer Studio) or in the command line.Example Maven execution (within project directory):
mvn clean install exec:java -Dexec.mainClass="com.sample.app.RulesTest"
mvn clean install exec:java -Dexec.mainClass="com.sample.app.RulesTest"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java execution (within project directory)
javac -classpath "./$DEPENDENCIES/*:." RulesTest.java java -classpath "./$DEPENDENCIES/*:." RulesTest
javac -classpath "./$DEPENDENCIES/*:." RulesTest.java java -classpath "./$DEPENDENCIES/*:." RulesTestCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Review the rule execution status in the command line and in the server log. If any rules do not execute as expected, review the configured rules in the project and the main class configuration to validate the data provided.