Tutorials and Examples for New Users
If you're just getting started with Drools and you'd like to see some working examples or need information about writing Java-based DRL files, then this is a good place to start. We've collected our most basic introductory documentation for new users and anyone evaluating Drools. If you have an idea for documentation that you'd like covered, please let us know.
Getting Examples Running
Running examples from CVS via Maven:
Running examples from CVS via Ant:
Running examples using precompiled jars from the command line:
Examples Alphabetically
Also shown are the maven/ant goals for the examples
- Benchmarks
- manners-benchmark
- waltz-benchmark
- Conway's Game Of Life Example
- conway-java
- conway-dsl
- Escalation Example
- escalation-java
- Fibonacci Example
- fibonacci-java
- fibonacci-python
- fibonacci-groovy
- fibonacci-java-jndi
- fibonacci-java-serialized
- fibonacci-groovy-jndi
- fibonacci-groovy-serialized
- fibonacci-native
- Hello World Example
- helloworld-native
- helloworld-java
- helloworld-groovy
- helloworld-python
- House Example
- house
- Miss Manners Example
- manners-jsr94
- manners-native
- manners-java
- manners-groovy
- Pet Store Example
- petstore-java
- petstore-groovy
- Prime Factors Example
- primefactors-java
- primefactors-java-verbose
- State Example
- state-java
- state-groovy
- state-python
Tutorials Alphabetically
Tutorials and Examples by Category
Working with DRL Files
Conflict Resolution
Conflict Resolution is used to prioritize activations within the Agenda. This is normally done through the use of Salience values.
Recursion
Recursion is where one rule can assert, modify and retract facts causing itself to be run.
Application Data
Application Data is used to introduce information without having to assert it into the Working Memory.
Event Model
An Event Model is implemented to allow listeners to be executed when certain events occur; assertObject, modifyObject and retractObject events and also fire events just before and just after the execution of consequence blocks.
Temporal Rules
A Duration can given to specify the length of time a rule must be true before it fires:
JSR-94: Java Rule Engine API
Drools is a JSR-94 compliant rule engine.
For instructions on how to run Drools under the JSR-94 Technology Compatibility Kit, please see:
Large # of Rules / Large # of Facts
The Prime Factors example was created to demonstrate Drools' ability to work with a large number of rules and a large number of facts. While the example is coded to work with 170 rules and 1000 facts, the example code can easily be extended to work with any arbitrarily large number of rules and/or facts.
GUI and Swing
While drools itself does not provide a GUI API it does provide the ability to link a GUI with a rules engine via Application Data and make a reference available to the JFrame to the Working Memory.
GUI is demonstrated in the following examples:
