Mastering JBoss Drools 6

Book description

Discover the power of Drools 6 and Business Rules for developing complex scenarios in your applications

About This Book

  • Implement and model different rules using the DRL full syntax

  • Model complex business decisions and domain models in order to automate and improve your operational decisions with the Drools framework

  • A practical, fast-paced, hands-on guide to help you use the different components provided by the Drools Rule Engine

  • Who This Book Is For

    This book is for Java developers and architects who need to have a deep understanding of how to create or integrate your applications with the Drools Rules Framework. The book assumes that you know the Java language well and also have experience with some widely used frameworks, such as Spring. You should also know the basics of Maven-based applications.

    What You Will Learn

  • Automate your application’s decisions, such as promotion applying, discount policies, fraud detection, and more.

  • Quickly get started with writing your first rules using the DRL full syntax.

  • Discover the power of the new syntax components of the rule language.

  • Define inferences in your business rules to simplify complex decisions.

  • Write decision tables, templates,domain-specific languages, and scorecards, and learn how to map them to the Drools framework.

  • Harness the full operational power of Drools through all of its configuration points.

  • Use Drools configurations and architectures for different environments and scenarios.

  • In Detail

    Mastering JBoss Drools 6 will provide you with the knowledge to develop applications involving complex scenarios. You will learn how to use KIE modules to create and execute Business Rules, and how the PHREAK algorithm internally works to drive the Rule Engine decisions. This book will also cover the relationship between Drools and jBPM, which allows you to enrich your applications by using Business Processes. You will be briefly introduced to the concept of complex event processing (Drools CEP) where you will learn how to aggregate and correlate your data based on temporal conditions. You will also learn how to define rules using domain-specific languages, such as spreadsheets, database entries, PMML, and more. Towards the end, this book will take you through the integration of Drools with the Spring and Camel frameworks for more complex applications.

    Style and approach

    Approached from a developer’s perspective, the book teaches you all the advanced concepts of Business Rules applicable examples with helpful screenshots, diagrams, tutorials, and examples.

    Table of contents

    1. Mastering JBoss Drools 6
      1. Table of Contents
      2. Mastering JBoss Drools 6
      3. Credits
      4. About the Authors
      5. About the Reviewer
      6. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      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. Rules Declarative Nature
        1. What are rules?
          1. Rules basic structure
          2. Declarative approach
          3. Imperative versus Declarative implementation
        2. Why do we use rules?
          1. Rules independence
          2. Rule execution chaining
            1. Atomicity of rules
            2. Ordering of rules
          3. Rule execution life cycle
            1. Collaboration with Rules
            2. Involving more people with Rules using a BRMS
          4. Letting the rule engine do its job
            1. Rule engine algorithm
        3. When should we use rules?
          1. Complex scenario, simple rules
          2. Ever-changing scenarios
          3. Example–eShop system
        4. When not to use a rule engine
        5. Summary
      9. 2. Writing and Executing Rules
        1. Setting up our environment
        2. Creating our first Drools project
        3. Writing and executing our first rule
          1. Using CDI to bootstrap the Rule Engine
        4. The Rule language
        5. Organizing our projects
        6. Summary
      10. 3. Drools Runtime
        1. Understanding the Drools runtime instances
          1. KieModule & KieContainer
            1. Loading rules from the classpath
            2. Loading rules using Maven artifacts (Kie-CI)
        2. KieModule configurations (KieBases, KieSessions & StatelessKieSessions)
        3. KieScanner
          1. Artifacts version resolution
          2. Dealing with unexpected issues and errors
          3. Putting it all together
        4. Summary
      11. 4. Improving Our Rule Syntax
        1. Adding external interactions with global variables
        2. Modifying the data in the working memory
          1. The insert keyword
          2. The modify and update keywords
          3. The delete/retract keywords
        3. Rule attributes
          1. Example – controlling which rules will fire
          2. Example – splitting rule groups with agenda group
          3. Other types of rule groups
          4. Rule dates management
        4. Controlling loops in rules
          1. Lock-on-active
          2. Model properties execution control
          3. Declared types
          4. Property-reactive beans
        5. Special Drools operations
          1. Boolean and numeric operations
          2. Regex operations – matches
          3. Collection operations – contains and memberOf
        6. Working memory breakdown: the from clause
          1. Collect from objects
          2. Accumulate keyword
          3. Advanced conditional elements
            1. NOT keyword
            2. EXISTS and FORALL keywords
        7. Drools syntactic sugar
          1. Nested accessors
          2. Inline casts
          3. Null-safe operators
        8. Decorating our objects in memory
          1. Adding traits with the don keyword
          2. Removing traits with the shed keyword
        9. Logical insertion of elements
          1. Handling deviations of our rules
          2. Deviations to our deviations
        10. Rule inheritance
          1. Conditional named consequences
        11. Summary
      12. 5. Understanding KIE Sessions
        1. Stateless and stateful Kie Sessions
          1. Stateless Kie Sessions
          2. Stateful Kie Sessions
        2. Kie runtime components
          1. Globals
            1. Globals as a way to parameterize the condition of a pattern
            2. Globals as a way to introduce new information into a session in the LHS
            3. Globals as a way to collect information from a session
            4. Globals as a way to interact with external systems in the RHS
          2. Channels
          3. Queries
            1. On-demand queries
            2. Live queries
          4. Event Listeners
        3. Kie Base components
          1. Functions
          2. Custom operators
          3. Custom accumulate functions
        4. Summary
      13. 6. Complex Event Processing
        1. What is complex event processing?
          1. What are events and complex events?
        2. Declaring CEP-based Rules
          1. Semantics of events
          2. Declaring time-based-events in Drools
          3. Temporal operators
        3. Event-driven architecture
          1. Split event sources with entry points
          2. Sliding windows
            1. Length-based sliding windows
            2. Time-based sliding windows
            3. Declared sliding windows
        4. Running CEP-based Scenarios
          1. Stream processing configuration
          2. Continuous versus Discrete rule firing
          3. Testing with the session clock
        5. Drools CEP limitations
        6. Summary
      14. 7. Human-Readable Rules
        1. Domain Specific Languages
          1. The Dictionary file
            1. Adding constraints to patterns
          2. Rules files
          3. DSL troubleshooting
          4. A simple scenario
        2. Decision tables
          1. What is a decision table?
          2. Decision tables structure
            1. RuleSet section
            2. RuleTable section
          3. Coming back to our scenario
          4. Decision table troubleshooting
          5. Enhanced decision tables
        3. Rule templates
          1. Rule template structure
          2. Working with rule templates
            1. Spreadsheet data source
            2. Array data source
            3. Objects data source
            4. SQL result set data source
        4. PMML
          1. PMML in Drools
          2. Customer classification decision tree example
            1. Header
            2. DataDictionary
            3. Model
          3. PMML troubleshooting
          4. PMML limitations
        5. Summary
      15. 8. Rules' Testing and Troubleshooting
        1. Create loosely coupled DRLs
        2. Prefer KieHelper over a KieContainer classpath
        3. Benefits of using globals
        4. Debugging the left-hand side of a rule
          1. Left-hand side troubleshooting
            1. Compilation errors
            2. Runtime errors
            3. Rules not being triggered
          2. Event listeners
          3. Drools logs
          4. Create simpler versions of a rule
        5. Debugging the right-hand side of a rule
          1. Right-hand side troubleshooting
            1. Compilation errors
            2. Runtime errors
          2. Right-hand side good practices
          3. Dumping the generated Java classes
        6. Reporting a bug in Drools
        7. Summary
      16. 9. Introduction to PHREAK
        1. Introducing PHREAK
          1. Object Type Nodes
          2. Alpha Nodes
            1. Alpha Node sharing
            2. Constraint JIT compilation
          3. Beta Nodes
            1. Beta Node sharing
            2. Or between patterns
        2. Special nodes in the network
          1. The Not Node
          2. The Exists Node
          3. The Accumulate Node
          4. The From Node
        3. Queries and backward-chaining
          1. Unification
          2. Positional arguments
          3. Backward reasoning in Drools
          4. The Query Element Node
        4. PHREAK improvements over RETE
          1. Delayed rule evaluation
          2. Set-oriented propagation
          3. Network segmentation
        5. Phreak Inspector
        6. Summary
      17. 10. Integrating Rules and Processes
        1. jBPM – the process engine
        2. Simple business process example
          1. Kie Session advanced configurations
            1. Kie Session event listeners
            2. Kie Session Work Items
          2. Understanding our process execution
        3. Drools and jBPM: integration patterns
          1. Accessing the process engine from our rules
          2. Process instances as facts
          3. BPMN2 Business Rule Tasks
        4. Persistence and transactions
          1. How is state persisted?
          2. JPA implementation
          3. Infinispan implementation
          4. Extending persisted data
          5. Transaction management
        5. Summary
      18. 11. Integrating Drools with our Apps
        1. Architecture considerations
          1. Asynchronous versus Synchronous Design
        2. Integrating with the rest of an application
          1. Embedding Drools into our application
          2. Knowledge as a Service
        3. CDI integration
        4. Spring integration
          1. Introducing Spring Framework
          2. Kie Spring Config example
        5. Camel integration
          1. Integrating the Apache Camel framework
          2. Creating our Kie endpoints
        6. Kie Execution Server
          1. Configuring Kie Server
            1. Default exposed Kie Server endpoints
        7. Kie Workbench
        8. Drools and beyond: extending our functionality
        9. Summary
      19. Index

    Product information

    • Title: Mastering JBoss Drools 6
    • Author(s): Mauricio Salatino, Mariano De Maio, Esteban Aliverti
    • Release date: March 2016
    • Publisher(s): Packt Publishing
    • ISBN: 9781783288625