Drools JBoss Rules 5.X Developer’s Guide

Drools JBoss Rules 5.X Developer’s Guide
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Learn the power of Drools as a platform for writing your business rules
  • Integrate Drools into your Java business application using the Spring framework
  • Through real-world examples and solutions, you will be taken from novice to expert

Book Details

Language : English
Paperback : 338 pages [ 235mm x 191mm ]
Release Date : May 2013
ISBN : 1782161260
ISBN 13 : 9781782161264
Author(s) : Michal Bali
Topics and Technologies : All Books, Application Development, JBoss, Open Source

Table of Contents

Chapter 1: Programming Declaratively
Chapter 2: Writing Basic Rules
Chapter 3: Validating
Chapter 4: Transforming Data
Chapter 5: Creating Human-readable Rules
Chapter 6: Working with Stateful Session
Chapter 7: Complex Event Processing
Chapter 8: Defining Processes with jBPM
Chapter 9: Building a Sample Application
Chapter 10: Testing
Chapter 11: Integrating
Chapter 12: Learning about Performance
Appendix A: Setting Up the Development Environment
Appendix B: Creating Custom Operators
Appendix C: Dependencies of Sample Application
    • Chapter 2: Writing Basic Rules
      • Rule basics
        • Executing rules
      • Rule syntax
        • Rule concepts
          • Variables in rules
          • Types
          • Comments
        • Package
          • Imports
          • Global variables
          • Functions
          • Type declarations
          • Dialect
        • Rule condition
          • The and element
          • The or element
          • The not element
          • The exists element
          • The eval element
          • The return element
          • The inline eval element
          • Null-safe dereferencing operator
          • The keyword - this
          • Free form expressions
          • Working with collections
        • Rule consequence
        • Rule attributes
          • The salience (priority) attribute
          • The no-loop attribute
          • Dialect
      • Summary
      • Chapter 3: Validating
        • Banking domain model
        • Problem definition
        • Analysis
        • Design
        • Validation package
          • Object required type rules
          • Testing
            • Batch execution
          • Minimal account balance rule
          • Student account rule
          • Unique account number rule
        • Implementation
        • Validation service
        • Summary
        • Chapter 4: Transforming Data
          • Process overview
          • Getting the data
            • Loading facts into the rule session
          • Writing transformation rules
            • Testing
            • Address normalization
            • Testing the findAddress rule
            • Unknown country
            • Currency conversion
            • One account allowed
          • Transformation results
          • Implementation of the data loading
            • Database setup
            • Project setup
            • iBatis configuration
            • Running iBatis
            • Alternative data loading
          • Summary
          • Chapter 5: Creating Human-readable Rules
            • Domain-specific language
              • DSL as an interface
              • DSL for validation rules
              • File formats
                • The DSL file format
                • The DRL file format
                • The DSLR file format
              • DSL for multiple constraints in a condition
              • Named capture groups
              • The transformation functions
              • DSL for data transformation rules
            • The decision tables
              • Advantages of a decision table
              • Disadvantages of a decision table
              • Calculating the interest rate
                • Project setup
                • Testing
                • Comma separated values
              • Rule templates
            • jBPM
              • Drools agenda
              • Methods for managing the rule execution order
              • The ruleflow-group attribute
                • Start event
                • End event
                • Script task
                • Rule task
                • Gateway — diverging
                • Gateway – converge
              • Example – defining an execution order
              • Rules
              • KnowledgeBase set up
              • Tests
            • Summary
            • Chapter 6: Working with Stateful Session
              • StatefulKnowledgeSession
              • Validation using stateful session
                • Design overview
                • Stateful Validation Service
                • Integration testing
                • Logical assertions
                • Keeping the validation report up-to-date
                  • The collect conditional element
                • Serialization
                  • Knowledge session recreation
                  • Testing
                  • Session serialization
                  • Full session serialization
              • Summary
              • Chapter 7: Complex Event Processing
                • CEP and ESP
                • Drools Fusion
                • Fraud detection
                  • Problem description
                  • Design and modeling
                  • Fraud detection rules
                    • Notification
                    • Monitoring averageBalanceQuery
                    • Two large withdrawals
                    • Sequence of increasing withdrawals
                    • High activity
                • Summary
                • Chapter 8: Defining Processes with jBPM
                  • Loan approval service
                    • Model
                  • Loan approval process
                    • Invalid loan application form
                      • E-mail work item
                      • Error event
                    • The size of the loan
                      • Test for a small loan
                    • Rating Calculation
                      • Subprocess
                      • Subprocess diagram
                      • Rating a calculation subprocess test
                      • Setting the rating using an on-exit action
                    • Decisions on rating
                      • Testing the Rating? node
                    • The Transfer Funds work item
                      • The work item definition
                      • Work item registration
                      • Work item handler
                      • Work item handler registration
                      • Testing the transfer work item
                    • Human task
                      • Test for the human task
                    • Final approval
                      • Test for the Approve Event node
                    • Banking service
                    • Disadvantages of a process
                  • Summary
                  • Chapter 9: Building a Sample Application
                    • Users
                    • Architecture
                    • Technologies used
                      • Additional Drools projects used
                        • Libraries used
                    • Business logic
                    • Design
                    • Configuration
                      • JPA annotations for domain objects
                      • JPA configuration
                      • Spring framework configuration
                      • Web application setup
                      • Deployment
                    • Repositories
                    • Validation
                      • Services
                      • Transactions
                      • Presentation layer
                        • Localized messages
                        • Customer save form controller
                      • The Complex Event Processing service
                    • Loan approval
                      • The Loan Request form
                      • Process persistence
                      • Task list
                        • Transactions
                      • Working on a task
                        • Problem 1 – joinTransaction
                        • Problem 2 – processing does not continue
                      • Loan approval event
                    • Summary
                    • Chapter 10: Testing
                      • Writing unit tests for rules
                      • Rule integration testing
                      • Rule acceptance testing
                        • Creating a test scenario
                        • Running a test scenario
                        • Running all test scenarios
                      • Static analysis of rules
                      • Troubleshooting techniques
                        • Event listeners
                        • Debugging
                        • Source of generated classes
                    • Summary
                      • Chapter 11: Integrating
                        • Dynamic KnowledgeBase loading
                          • KnowedgeAgent
                        • External artifact building
                          • Building with Ant
                        • Drools Camel server
                          • Interest rate calculation example
                            • The server
                            • The client
                        • Spring framework integration
                        • Standards
                        • Summary
                        • Chapter 12: Learning about Performance
                          • Rete algorithm
                            • Node types
                              • The Rete node
                              • EntryPointNode
                              • ObjectTypeNode
                              • AlphaNode
                              • LeftInputAdapterNode
                              • TerminalNode
                              • BetaNode
                              • More complex example
                              • EvalConditionNode and FromNode
                            • Retracting or modifying a fact
                            • Initial fact
                          • Node sharing
                            • Example
                          • Node indexing
                            • The AlphaNode indexing
                              • Computation complexity
                            • The BetaNode indexing
                              • Example
                          • Left and right unlinking
                          • The KnowledgeBase partitioning
                            • Parallel execution
                          • Summary

                              Michal Bali

                              Michal Bali, freelance software developer, has more than 8 years of experience working with Drools and has an extensive knowledge of Java, JEE. He designed and implemented several systems for a major dental insurance company. He is an active member of the Drools community and can be contacted at michalbali@gmail.com.

                              Code Downloads

                              Download the code and support files for this book.

                              Submit Errata

                              Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                              - 3 submitted: last submission 08 May 2014

                              Errata type: Typo | Page number: 19

                              Inside the tip, the sentence " The StatefulKnowledgeSessionis object is also used to set a session's global variables."

                              Should be: The StatefulKnowledgeSession object is also used to set a session's global variables.

                              Errata type: Grammar | Page number: 36

                              The no-loop attribute has quite limited use as it prevents only the rule to active itself.

                              Should be:

                              The no-loop attribute has quite limited use as it prevents only the rule from activating itself

                              Errata type: Technical | Page number: 276

                              In Figure 2, The first node is labeled incorrectly as "Rate Node" rather than 

                              "Rete Node".

                              Sample chapters

                              You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                              Frequently bought together

                              Drools JBoss Rules 5.X Developer’s Guide +    Practical Mobile Forensics =
                              50% Off
                              the second eBook
                              Price for both: $45.60

                              Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                              What you will learn from this book

                              • Quickly get started writing your first rules
                              • Produce decision tables
                              • Write a domain-specific language to make rules more understandable
                              • Create a stateful service
                              • Harness the power of flows through process services
                              • Fit it all together in a sample web application that uses layered architecture, transactions, Spring, and Hibernate
                              • Properly test your applications with Guvnor

                              In Detail

                              Writing business rules has always been a challenging task. Business rules tend to change often leading to a maintenance nightmare. This book shows you various ways to code your business rules using Drools, the open source Business Rules Management System.

                              Drools JBoss Rules 5.X Developer’s Guide shows various features of the Drools platform by walking the reader through several real-world examples. Each chapter elaborates on different aspects of the Drools platform. The reader will also learn about the inner workings of Drools and its implementation of the Rete algorithm.

                              The book starts with explaining rule basics, then builds on this information by going through various areas like human readable rules, rules for validation, and stateful rules, using examples from the banking domain. A loan approval process example shows the use of the jBPM module. Parts of a banking fraud detection system are implemented with the Drools Fusion module which is the complex event processing part of Drools. Finally, more technical details are shown detailing the inner workings of Drools, the implementation of the ReteOO algorithm, indexing, node sharing, and partitioning.


                              The chapters in the book present real-life examples, usually starting with an introduction to the problem, and a discussion of the possible solution. Then the solution is implemented in a step by step fashion implementing several rules.

                              Who this book is for

                              The book is for Java developers who want to create rule-based business logic using the Drools platform.

                              Code Download and Errata
                              Packt Anytime, Anywhere
                              Register Books
                              Print Upgrades
                              eBook Downloads
                              Video Support
                              Contact Us
                              Awards Voting Nominations Previous Winners
                              Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                              Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software