Drools sample



Keywords: introduction, eclipse plugin, drools runtime, create a drools program, frequently used terms, rules writing, rule syntax, sample drools program, debugging.
Description: Drools Sample Drools Program - Learn Drools in simple and easy steps starting from its Introduction, Eclipse Plugin, Drools Runtime, Create a Drools Program, Frequently Used Terms, Rules Writing, Rule Syntax, Sample Drools Program, Debugging.

Depending upon the city and the kind of product (Combination of City and Product), find out the local tax related to that city.

We will have two DRL files for our Drools project. The two DRL files will signify two cities in consideration (Pune and Nagpur) and four types of products (groceries, medicines, watches, and luxury goods).

  • The tax on medicines in both the cities is considered as zero.
  • For groceries, we have assumed a tax of Rs 2 in Pune and Rs 1 in Nagpur.

We have used the same selling price to demonstrate different outputs. Note that all the rules are getting fired in the application.

We have written the DRL files based on city, as it gives us extensibility to add any number of rule files later if new cities are being added.

To demonstrate that all the rules are getting triggered from our rule files, we have used two item types (medicines and groceries); and medicine is tax-free and groceries are taxed as per the city.

For both Pune and Nagpur, when the item is a medicine, the local tax is zero; whereas when the item is a grocery product, the tax is as per the city. More rules can be added in the DRL files for other products. This is just a sample program.

Thereafter, add the import statement in the DRL file to call the writeHello method from the DRL file. In the following code block, the changes in the DRL file Pune.drl are highlighted in yellow.

The difference now in the output is marked in yellow which shows the output of the static method in the Java class.

The advantage to call a Java method is that we can write any utility/helper function in Java and call the same from a DRL file.






Photogallery Drools sample:


Chapter 9. Examples


JBoss Drools  Decision Tables | My Experiments with Technology


Chapter 4. Authoring Assets


Chapter 6. Authoring


Setting up Drools Guvnor | Integrating Stuff


Chapter 19. Examples


JBoss Drools Hello World complete step by step example


JBoss Drools  Decision Tables | My Experiments with Technology


JBoss Drools Hello World complete step by step example


CEP made easyR  Drools with R using RStudio | emergile


DROOLS-Debug-Start.png


Jboss Drools Business Rules Sample Chapter 4 Guided Rules With The Gu


Drools Planner User Guide


Chapter 4. KIE


Chapter 2. Creating a New Drools Project


Drools Documentation


Jboss Drools Business Rules Sample Chapter 4 Guided Rules With The Gu


DROOLS-Debug.png


JBoss Drools Hello World complete step by step example


Eclipse Maven Drools 5.5.0.Final Example  Java Developer Resources


Getting started with Drools Flow | Software Passion