Discover the power of Drools 6 and Business Rules for developing complex scenarios in your applicationsAbout 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 EngineWho This Book Is ForThis 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 DetailMastering 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 approachApproached 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.

eBook - ePub
Mastering JBoss Drools 6
- 330 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
eBook - ePub
Mastering JBoss Drools 6
About this book
Trusted by 375,005 students
Access to over 1 million titles for a fair monthly price.
Study more efficiently using our study tools.
Information
Mastering JBoss Drools 6
Table of Contents
Mastering JBoss Drools 6
Credits
About the Authors
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Rules Declarative Nature
What are rules?
Rules basic structure
Declarative approach
Imperative versus Declarative implementation
Why do we use rules?
Rules independence
Rule execution chaining
Atomicity of rules
Ordering of rules
Rule execution life cycle
Collaboration with Rules
Involving more people with Rules using a BRMS
Letting the rule engine do its job
Rule engine algorithm
When should we use rules?
Complex scenario, simple rules
Ever-changing scenarios
Example–eShop system
When not to use a rule engine
Summary
2. Writing and Executing Rules
Setting up our environment
Creating our first Drools project
Writing and executing our first rule
Using CDI to bootstrap the Rule Engine
The Rule language
Organizing our projects
Summary
3. Drools Runtime
Understanding the Drools runtime instances
KieModule & KieContainer
Loading rules from the classpath
Loading rules using Maven artifacts (Kie-CI)
KieModule configurations (KieBases, KieSessions & StatelessKieSessions)
KieScanner
Artifacts version resolution
Dealing with unexpected issues and errors
Putting it all together
Summary
4. Improving Our Rule Syntax
Adding external interactions with global variables
Modifying the data in the working memory
The insert keyword
The modify and update keywords
The delete/retract keywords
Rule attributes
Example – controlling which rules will fire
Example – splitting rule groups with agenda group
Other types of rule groups
Rule dates management
Controlling loops in rules
Lock-on-active
Model properties execution control
Declared types
Property-reactive beans
Special Drools operations
Boolean and numeric operations
Regex operations – matches
Collection operations – contains and memberOf
Working memory breakdown: the from clause
Collect from objects
Accumulate keyword
Advanced conditional elements
NOT keyword
EXISTS and FORALL keywords
Drools syntactic sugar
Nested accessors
Inline casts
Null-safe operators
Decorating our objects in memory
Adding traits with the don keyword
Removing traits with the shed keyword
Logical insertion of elements
Handling deviations of our rules
Deviations to our deviations
Rule inheritance
Conditional named consequences
Summary
5. Understanding KIE Sessions
Stateless and stateful Kie Sessions
Stateless Kie Sessions
Stateful Kie Sessions
Kie runtime components
Globals
Globals as a way to parameterize the condition of a pattern
Globals as a way to introduce new information into a session in the LHS
Globals as a way to collect information from a session
Globals as a way to interact with external systems in the RHS
Channels
Queries
On-demand queries
Live queries
Event Listeners
Kie Base components
Functions
Custom operators
Custom accumulate functions
Summary
6. Complex Event Processing
What is complex event processing?
What are events and complex events?
Declaring CEP-based Rules
Semantics of events
Declaring time-based-events in Drools
Temporal operators
Event-driven architecture
Split event sources with entry points
Sliding windows
Length-based sliding windows
Time-based sliding windows
Declared sliding windows
Running CEP-based Scenarios
Stream processing configuration
Continuous versus Discrete rule firing
Testing with the session clock
Drools CEP limitations
Summary
7. Human-Readable Rules
Domain Specific Languages
The Dictionary file
Adding constraints to patterns
Rules files
DSL troubleshooting
A simple scenario
Decision tables
What is a decision table?
Decision tables structure
RuleSet section
RuleTable section
Coming back to our scenario
Decision table troubleshooting
Enhanced decision tables
Rule templates
Rule template structure
Working with rule templates
Spreadsheet data source
Array data source
Objects data source
SQL result set data source
PMML
PMML in Drools
Customer classification decision tree example
Header
DataDictionary
Model
PMML troubleshooting
PMML limitations
Summary
8. Rules' Testing and Troubleshooting
Create loosely coupled DRLs
Prefer KieHelper over a KieContainer classpath
Benefits of using globals
Debugging the left-hand side of a rule
Left-hand side troubleshooting
Compilation errors
Runtime errors
Rules not being triggered
Event listeners
Drools logs
Create simpler versions of a rule
Debugging the right-hand side of a rule
Right-hand side troubleshooting
Compilation errors
Runtime errors
Right-hand side good practices
Dumping the generated Java classes
Reporting a bug in Drools
Summary
9. Introduction to PHREAK
Introducing PHREAK
Object Type Nodes
Alpha Nodes
Alpha Node sharing
Constraint JIT compilation
Beta Nodes
Beta Node sharing
Or between patterns
Special nodes in the network
The Not Node
The Exists Node
The Accumulate Node
The From Node
Queries and backward-chaining
Unification
Positional arguments
Backward reasoning in Drools
The Query Element Node
PHREAK improvements over RETE
Delayed rule evaluation
Set-oriented propagation
Network segmentation
Phreak Inspector
Summary
10. Integrating Rules and Processes
jBPM – the process engine
Simple business process example
Kie Session advanced configurations
Kie Session event listeners
Kie Session Work Items
Understanding our process execution
Drools and jBPM: integration patterns
Accessing the process engine from our rules
Process instances as facts
BPMN2 Business Rule Tasks
Persistence and transactions
How is state persisted?
JPA implementation
Infinispan implementation
Extending persisted data
Transaction management
Summary
11. Integrating Drools with our Apps
Architecture considerations
Asynchronous versus Synchronous Design
Integrating with the rest of an application
Embedding Drools into our application
Knowledge as a Service
CDI integration
Spring integration
Introducing Spring Framework
Kie Spring Config example
Camel integration
Integrating the Apache Camel framework
Creating our Kie endpoints
Kie Execution Server
Configuring Kie Server
Default exposed Kie Server endpoints
Kie Workbench
Drools and beyond: extending our functionality
Summary
Index
Mastering JBoss Drools 6
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2016
Production reference: 1220316
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-862-5
www.packtpub.com
Credits
Authors
Mauricio Salatino
Mariano De Maio
Esteban Aliverti
Reviewer
Mario Fusco
Commissioning Editor
Anthony Albuquerque
Acquisition Editor
Llewellyn Rozario
Content Development Editor
Prashanth G Rao
Technical Editor
Danish Shaikh
Copy Editor
Vibha Shukla
Project Coor...
Table of contents
- Mastering JBoss Drools 6
Frequently asked questions
Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Mastering JBoss Drools 6 by Mauricio Salatino, Mariano De Maio, Esteban Aliverti, Mariano De Maio, Esteban Aliverti in PDF and/or ePUB format, as well as other popular books in Computer Science & Data Processing. We have over one million books available in our catalogue for you to explore.