Chapter 2. Writing Basic Rules

In this chapter we'll start writing our first rules in Drools. We'll go through some basics needed to write and execute rules. We'll learn the necessary keywords of the Drools rule language.

But before all this we have to set up our development environment. If you haven't already done so, please refer to Appendix A, Setting up the Development Environment, on development environment setup.

Rule basics

We'll now write our first Drools rule. Let's say that we have the Account bean that has one property called balance. For every Account bean whose balance is less than 100, we want to write a message to the standard output:

package droolsbook; rule "basic rule" when Account( balance < 100 ) // condition then System.out.println("Account ...

Get Drools JBoss Rules 5.X Developer's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.