JBoss Drools Guvnor Example - Examples Java Code Geeks - 2021
JBoss Drools Guvnor Example - Examples Java Code Geeks - 2021
ANDROID CORE JAVA DESKTOP JAVA ENTERPRISE JAVA JAVA BASICS JVM LANGUAGES PYTHON SOFTWARE DEVELOPMENT DEVOPS
Email address:
1. Maven 3.2.3 JOIN US
2. Guvnor 5.1.1 With 1,
unique v
500 au
placed a
related s
Constan
lookout
encoura
So If yo
unique and interesting content t
check out our JCG partners prog
be a guest writer for Java Cod
In order to know Drools Guvnor, we first need to know what is a business rules manager. Business Rules manager allows people to manage
rules in a multi user environment. It is a single point of truth for your business rules. It allows to manage the rules in a controlled fashion. We
can keep track of different versions of the rules, its deployment. It also allows multiple users of different skill levels access to edit rules with
user friendly interfaces. Guvnor is the name of the web and network related components for managing rules with drools.
2. Installing Guvnor
First you need to install JBoss app server from http://jbossas.jboss.org/downloads/. Once your download is complete, unzip the files to a
folder of your choice. To start the JBoss App Server, open the bin folder and double-click on run.bat. Download Drools Guvnor war file.
Rename the war file to guvnor.war and copy to {JBossHome}/server/default/deploy. Start Jboss. Open
http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/Guvnor.html.
Guvnor Login
You don’t need to enter user/password. Simply click on Ok. You will be taken to the welcome screen.
3. Main Features of Guvnor
Browse the main areas. You will see:
1. Knowledge Base
2. QA
3. Package Snapshots
4. Administration
go to the “Knowledge Bases” tab. Click on “Create New” right under the tab and choose “New Package”. Give your package a name – I
choose “banking” – and press Ok. Then “Create new” – “Upload new Model Jar”.
New package
Model Tab
You can either use maven to create jar file or use eclipse File->Export->Java->Jar file option to generate the domain model Jar file.
You can see the model classes in the package tab. Click on ‘Save and validate configuration’ so that the model files become available as facts
to the rules.
Package View
5. Define Rules
Adding a sample rule. Now the model is uploaded, we can start defining rules. To add a rule, you have to create a Category first
(Administration>Category>New Category).
New Category
Once the category is created, will go back to the “Knowledge Bases” tab and choose Create New>New Rule to create our first rule.
Click on the ‘+’ green button to add conditions. To add a condition to the rule, we need to choose fact type as Cart. After choosing this, we’ll
automatically be taken back to the guided rule-editing screen. This is where we define the rule.
Define Rule
1. We will have to click on the ‘+’ sign to insert a new GIVEN/EXPECT, the small green arrow to refine the scenario, and the ‘–’ sign to
remove.
2. We will click on GIVEN to insert a new cart fact and then on Add.
3. Next, we will click on the Add a field button that appears. In the dialog box, select the ‘totalPrice’ field.
4. Next, we will set a constraint for ‘totalPrice’, that is, if it is greater than 5000.
5. Click on the green ‘+’ next to EXPECT. In the New Expectation dialog box that is displayed, click on show list and then choose the added
rule.
6. Change the default (that we expect this rule to fire at least once) to Expect Rules, to fire this many times, and then enter ‘1’ in the new
text box that appears.
7. Save this test scenario using the button at the top of the screen.
8. Finally, we will click on the Run Scenario button, you will get a green bar at the top of the screen saying Results 100%.
Download
You can download the full source code of this example here: DroolsGuvnorExample.zip
Subscribe
This site uses Akismet to reduce spam. Learn how your comment data is processed.
1 COMMENT Oldest
very nice article. i was trying to follow the steps you had mentioned above. had a small challenge
deploying the guvnor.war file in jboss server. below is the exception while deploying the war file.
21:31:30,296 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting
deployment of “guvnor.war” 21:32:30,306 INFO [org.jboss.as.server] (DeploymentScanner-threads
– 1) JBAS015870: Deploy of deployment “guvnor.war” was rolled back with failure message
Operation cancelled 21:32:30,306 ERROR [org.jboss.as.server.deployment.scanner]
(DeploymentScanner-threads – 2) JBAS015052: Did not receive a response to the deployment
operation within the allowed timeout period [60 seconds]. Check the server configuration file and
the server logs to find more… Read more »
0
Reply
Examples Java Code Geeks and all content copyright © 2010-2021, Exelixis Media P.C. | Terms of Use | Privacy Policy | Contact