Chapter 7. Rules and Processes

Table of Contents

Why Use Rules in Processes?
Why Integrate Rules and Processes in a Single Engine?
Approach
Teaching a Rules Engine About Processes
Inversion of Control
Example
Evaluating a Set of Rules in Your Process
Using Rules for Evaluating Constraints
Assignment Rules
Describing Exceptional Situations Using Rules
Modularizing Concerns Using Rules
Rules for Altering Process Behavior Dynamically
Integrated Tooling
Domain-specific Rules and Processes

Drools Flow is a workflow and process engine that allows advanced integration of processes and rules. This chapter discusses the integration of rules and processes, ranging from simple to advanced scenarios.

Why Use Rules in Processes?

Workflow languages that depend purely on process constructs (like nodes and connections) to describe the business logic of applications tend to be quite complex. While these workflow constructs are very well suited to describe the overall control flow of an application, it can be very difficult to describe complex logic and exceptional situations. Therefore, executable processes tend to become very complex. We believe that, by extending a process engine with support for declarative rules in combination with these regular process constructs, this complexity can be kept under control.

  1. Simplicity: Complex decisions are usually easier to specify using a set of rules. Rules can pinpoint complex business logic more easily, using their advanced constraint language. Multiple rules can be combined, each describing a part of the business logic.

  2. Agility: Rules and processes can have a separate life cycle. This means that we can change the rules describing some crucial decision points without having to change the process itself. Rules can be added, removed or modified to fine-tune the behavior of the process to the constantly evolving requirements and environment.

  3. Different scope: Rules can be reused across processes or outside processes. Therefore, your business logic is not locked inside your processes.

  4. Declarativeness: Focus on describing "what" instead of "how".

  5. Granularity: It is easy to write simple rules that handle specific circumstances. Processes are more suited to describe the overall control flow but tend to become very complex if they also need to describe a lot of exceptional situations.

  6. Data-centric: Rules can easily handle large data sets.

  7. Performance: Rule evaluation is optimized.

  8. Advanced condition and action language: Rule languages support advanced features like custom functions, collections, conditional elements, including quantifiers, etc.

  9. High-level: By using DSLs, business editors, decision tables, and decision trees, your business logic could be described in a way that can be understood (and possibly even modified) by business users.