You are previewing JBoss Drools Business Rules.
O'Reilly logo
JBoss Drools Business Rules

Book Description

Capture, automate, and reuse your business processes in a clear English language that your computer can understand.

  • An easy-to-understand JBoss Drools business rules tutorial for non-programmers

  • Automate your business processes such as order processing, supply management, staff activity, and more

  • Prototype, test, and implement workflows by themselves using business rules that are simple statements written in an English-like language

  • Discover advanced features of Drools to write clear business rules that execute quickly

  • For confident users of Excel or other business software, this book is everything you need to learn JBoss Drools business rules and successfully automate your business.

In Detail

In business, a lot of actions are trigged by rules: "Order more ice cream when the stock is below 100 units and temperature is above 25° C", "Approve credit card application when the credit background check is OK, past relationship with the customer is profitable, and identity is confirmed", and so on. Traditional computer programming languages make it difficult to translate this "natural language" into a software program. But JBoss Rules (also known as Drools) enables anybody with basic IT skills and an understanding of the business to turn statements such as these into running computer code.

This book will teach you to specify business rules using JBoss Drools, and then put them into action in your business. You will be able to create rules that trigger actions and decisions, based on data that comes from a variety of sources and departments right across your business. Regardless of the size of your business, you can make your processes more effective and manageable by adopting JBoss Rules.

Banks use business rules to process your mortgage (home loan) application, and to manage the process through each step (initial indication of amount available, actual application, approval of the total according to strict rules regarding the amount of income, house value, previous repayment record, swapping title deeds, and so on).

Countries such as Australia apply business rules to visa applications (when you want to go and live there)—you get points for your age, whether you have a degree or masters, your occupation, any family members in the country, and a variety of other factors.

Supermarkets apply business rules to what stock they should have on their shelves and where—this depends upon analyzing factors such as how much shelf space there is, what location the supermarket is in, what people have bought the week before, the weather forecast for next week (for example, ice cream in hot weather), and what discounts the manufacturers are giving.

This book shows how you can use similar rules and processes in your business or organization. It begins with a detailed, clear explanation of business rules and how JBoss Rules supports them.

You will then see how to install and get to grips with the essential software required to use JBoss Rules. Once you have mastered the basic tools, you will learn how to build practical and effective of the business rule systems.

The book provides clear explanations of business rule jargon. You will learn how to work with Decision Tables, Domain-Specifi c Languages (DSL)s, the Guvnor and JBoss Integrated Development Environment (IDE), workflow and much more.

By the end of the book you will know exactly how to harness the power of JBoss Rules in your business.

Table of Contents

  1. JBoss Drools Business Rules
  2. Credits
  3. Foreword
  4. About the author
  5. About the reviewer
  6. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this is book for
    4. Conventions
    5. Reader Feedback
    6. Customer Support
      1. Errata
      2. Piracy
      3. Questions
  7. 1. Drooling over JBoss Rules
    1. Who are you? What's your problem?
      1. Does this sound like where you work?
    2. Life or death business rules
      1. What would you do?
    3. Business rules in your organization
      1. Exercise — rules in your organization
      2. The chocolate factory
      3. Build your own rule engine in Excel
      4. Why can't the tech guys write the rules for me?
    4. Why existing solutions don't cut it
    5. Rule engines to the rescue
      1. Other rules (Microsoft Outlook)
    6. Meet JBoss Rules
      1. A bit more on open source
      2. The JBoss Rules community
        1. Where to get help
        2. How to ask for help
    7. The bigger picture
      1. Members of your team
    8. How do I write the rules
    9. Introducing the BRMS (Guvnor)
    10. Parts of the solution
      1. Rules editor
      2. Rules compiler
      3. Runtime
      4. Fact model
      5. Java
      6. Rule repository
      7. Rest of the system
    11. When not to use a rule engine
    12. Summary
  8. 2. Getting the software
    1. What are we going to install?
      1. Who should install it?
      2. Installing Java
      3. Installing JBoss
        1. Actual install
      4. Installing the BRMS/Guvnor
      5. Installing Eclipse
      6. Installing the Drools plug-in
        1. Finding the plug-in
      7. Installing Maven
      8. Installing sample projects for this book
        1. Setting up the sample project in Eclipse
        2. Getting Maven and Eclipse to work together
      9. Troubleshooting
    2. Summary
  9. 3. Meet the Guvnor
    1. Taking a tour with the Guvnor
      1. Getting started
      2. General navigation
        1. The search screen
      3. Administration
        1. Loading the samples
        2. What did we just do?
        3. More on the admin page
        4. Rules
          1. Process
          2. The model
          3. Guided rules
          4. Technical rules
          5. Creating a new rule
        5. Packages
        6. Deployment
        7. QA—Quality Analysis
          1. Automating testing in Guvnor
          2. The analysis page
        8. Hello World example
          1. Writing the rule
          2. Firing the rule
          3. What just happened?
    2. Summary
  10. 4. Guided Rules with the Guvnor
    1. Passing information in and out
    2. Building the fact model
    3. Importing the fact model into Guvnor
      1. Guided rules using the fact model
      2. The step-by-step answer
    4. Running this scenario
    5. What just happened?
    6. Summary
  11. 5. From Guvnor to JBoss IDE
    1. A more powerful rule
      1. Have a go
      2. Updating the rule—step by step
        1. The When part
        2. Looking behind the curtain—a text-based rule
      3. A small problem...
        1. Rule attributes
      4. More on the guided editor
        1. Possible comparisons
        2. Condition types
        3. Add more options
        4. Multiple field constraints
        5. The Then part
        6. More rule options and attributes
      5. Text editing
      6. Introduction to the JBoss IDE
      7. Hello World in the JBoss IDE editor
        1. What just happened?
          1. The business explanation
          2. The technical explanation
      8. Try it yourself
    2. Summary
  12. 6. More rules in the JBoss IDE
    1. Rule syntax
      1. Patterns for the When part
      2. Patterns for the Then part
      3. Shipping chocolate bars
      4. The problem (and remind me why I need business rules)
        1. Why rules scale better—a reminder
      5. Getting and building the sample
        1. Rules
        2. ChocolateShipment.java
        3. CustomerOrder.java
        4. OompaLoompaDate
        5. The RuleRunner file
        6. MultipleRulesExample
      6. Running the sample
        1. Console
      7. More powerful rule syntax
        1. Lefthand side
          1. not
          2. Contains and memberOf
          3. matches and Soundslike
          4. in
          5. exists
          6. forall
          7. collect/accumulate
          8. eval
          9. from
        2. Righthand side—Then
      8. Guided editor in the JBoss IDE
    2. Summary
  13. 7. Testing your Rules
    1. Testing when building rules
      1. Making testing interesting
      2. Testing using Guvnor
      3. Testing using FIT
        1. Getting FIT
        2. The FIT requirements document
          1. Logo and the first paragraph
          2. First step—setup
          3. Second step—values in
          4. Third step—click on the Go button
          5. Fourth step—check the results
          6. Clear (an optional step)
          7. Print a summary (an optional step)
          8. Footer
        3. Running FIT on our sample
        4. What just happened?
        5. What can go wrong?
      4. The FIT plumbing
      5. What is unit testing?
        1. Why unit test?
        2. Unit testing the Chocolate Shipments sample
        3. What just happened?
      6. What if it goes wrong?
        1. Failures and errors
        2. Testing an entire package
    2. Summary
  14. 8. Data and Rules in Excel
    1. Reading data from Excel
      1. Business rules for this sample
      2. Getting and running the sample
        1. Input
        2. Rules
        3. Running the sample
        4. What's going on?
        5. Under the covers
        6. More on Cells and Ranges
      3. Sophisticated, but repetitive rules
      4. Some Excel magic
      5. Decision tables behind the scenes
        1. Header information
        2. RuleTable—Evaluate the buy trades
        3. RuleTable—Execute the buy trades
        4. Other rule tables
        5. Mixing rules and decision tables
      6. Running the Chocolate Trading example
        1. What just happened?
        2. Have a go
    2. Summary
  15. 9. Domain Specific Language (DSL) and RuleFlow
    1. What is a Domain Specific Language (DSL)?
      1. Expanders
        1. The DSL format
        2. Other DSL editing options
        3. Writing DSLs
        4. Meet the sample
      2. Running the DSL example
        1. Guvnor and DSL-based rules
    2. Ruleflow
      1. Ruleflow is not workflow
      2. That Homeloan example again
      3. Linking rules to Ruleflow
      4. A quick introduction to stateful applications
        1. Stateful rules and Ruleflow
    3. Summary
  16. 10. Deploying Rules in Real Life
    1. One size fits all architecture
      1. What needs to be deployed?
      2. Rules as code or data?
      3. Deployment process
        1. What's a repository?
      4. Deploying rules
      5. Push or pull?
      6. Loading our rules
        1. Looking inside RuleRunner.java
        2. Helper methods
      7. Public methods
        1. Stateless
        2. Stateful
      8. Alternative method—RuleAgent
      9. Web deployment
        1. Maven for packaging
    2. Summary
  17. 11. Looking under the Cover
    1. Rule engine concepts
      1. Facts or objects
      2. Working memory
      3. Pattern matching, Agenda, and Activations
      4. Conflict resolution
      5. A more dynamic Agenda
      6. Truth maintenance
    2. Back to the future (with chocolate shipping)
    3. Logging working memory
      1. Looking at the working memory log
      2. Drools Audit Log Viewer
    4. Rete algorithm
      1. Rete in action
      2. Debugging rules
        1. Debugging rules in the Eclipse IDE
        2. Rules debug perspective
        3. Other Drools views while debugging
      3. When to log, when to test, and when to debug
    5. Summary
  18. 12. Advanced Drools Features
    1. Pigeons, Drools, and Complex Event Processing
      1. Implementing Complex Event Processing using Fusion
      2. More powerful events
    2. Inline beans
      1. Loading data when your beans don't exist—Smooks
    3. From pigeons to biscuits—Drools Solver for your local supermarket
      1. How Drools Solver works
        1. Implementing a Solver
        2. More information on Solver
      2. Forward and backward chaining
      3. Changing the conflict resolution methodology
      4. Standard rule engine API—JSR 94
        1. Other rule engines
    4. New API
      1. Drools flow—a full workflow engine
      2. New features in Guvnor
      3. Does this still sound like where you work?
    5. Summary