0%

Book Description

For Java developers this is the ultimate guide to coding business rules using the Drools platform. It’s a chance to get a deep grounding in it all through a logical step by step approach using many real-life examples.

  • 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

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.5 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.

Table of Contents

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