Introduction to Rules Engine

1. Introduction to rule engine

​ The rule engine is a component nested in the application, which separates business rules from the application code. The rules engine uses a specific syntax to write business rules.

The benefits of introducing the rule engine backend:

(1) Realize the separation of business logic and business rules, and realize the centralized management of business rules.

(2) Business rules can be modified dynamically to quickly respond to demand changes.

(3) Enable business analysts to participate in editing and maintaining the business rules of the system.

(4) Use the rule editing tool provided by the rule engine to make the implementation of complex business rules simple.

2. Comparison of rule engine selection:

In the current rule engine system, the most used open source rule engine is Drools, and there is also a commercial rule management system BRMS called ILOG JRules. The design and implementation of these two rule engines are relatively complicated, with high learning costs, and are suitable for large-scale application systems. Of course, there is also an excellent rule engine like the paid version of URule.

1.Drools:

Drools is an open source rule engine written in Java language, based on the Apache protocol, based on the RETE algorithm, and was acquired by JBoss in 2005. Drools is an engine designed to solve the separation of business code and business rules. Drools rules are run on Java applications, and the sequence of steps to be executed is determined by the code. In order to achieve this, the Drools rules engine converts business rules into execution trees. Advantages of drools:

1. Simplify the system architecture and optimize the application.
    2. Improve the maintainability and maintenance cost of the system.
    3. Convenient system integration.
    4. Reduce the cost and risk of writing "hard-coded" business rules.

drools official website: https://www.drools.org/

droolsgithub:https://github.com/kiegroup/drools

​ Drools is a business logic integration platform (BLip). It is written in Java. It is an open source project that is extended by JBoss and Red Hat and implements the Rete pattern matching algorithm.

In layman's terms, Drools is a tool that allows us to separate internal business processes and find a collection of logic and data. The two important keywords we need to pay attention to are logic and data. Drools is divided into two main parts: writing and running the system.

  • Production: The production process involves creating a rule file (.DRL file).

  • Runtime: It involves creating working memory and processing activation.

Advantages: 1. The decoupling of policy rules and execution logic facilitates maintenance.

Disadvantages:

​ 1. When the rule size becomes larger, it will become difficult to maintain, and the relative advantage of hard coding will no longer exist.

​ 2. The grammar of the rule is only suitable for flat rules. For the rules of nested conditional semantics (when...then clauses are nested in then), the conditions can only be configured after the Cartesian product combination, which is not conducive to maintenance.

​ Since Drools itself does not provide a visual interface, you need to develop the dynamic configuration page and its functions again after being integrated into the project. The drools rules are text and can be read and then loaded and executed. For example, they are stored in the database. Read from the database. The rules can be written to the database in other ways.

​ Since Drools itself does not provide a visual interface, the calling methods can be divided into the following two:

  • After creating the service, provide api to call directly

  • Secondary development. Cooperate with the front-end (to implement rule editing through the Ant G6 component and pass the drl script in json format), the back-end parses json and integrates quartz or akka task scheduling, and uses spring kafka components to receive data streams from the cluster.

2.Ilog JRules:

IBM WebSphere ILOG JRules is currently the industry's leading business rules management platform. Unlike the traditional practice of IT personnel using hard code to maintain rules, ILOG JRules enables business users to quickly create, modify, test, and deploy business rules without relying on or limited to IT personnel to meet frequent changes Business needs. ILOG JRules provides a complete set of tools to help developers and business personnel carry out the full life cycle management of rules.

Main components:
    1. Rule Studio (RS) is a development environment for developers to model and write rules.
    2. Rule Scenario Manager rule testing tool.
    3. Rule Team Server (RTS) is a Web-based management environment for business personnel to publish, manage, and store rules.
    4. Rule Execution Server (RES) is for operation and maintenance personnel for rule execution and monitoring.

​ The JRules rule engine provides three operating modes: RetePlus, Sequential and FastPath to adapt to different application requirements and achieve optimal performance. In the application based on the business rule engine, it is necessary to rationally organize and arrange business rules according to the characteristics of different applications, and select the appropriate operating mode, which will help to better exert the effectiveness of the rule engine, but at the same time, it is more complicated.

3.Easy Rules:

Easy Rules is a Java rules engine. Its birth was inspired by Martin Fowler's article titled "Should I use a Rules Engine?". Easy Rules provides a rule abstraction to create rules with conditions and actions, and a RulesEngine API that runs a set of rules to evaluate conditions and perform actions.

Features:
    1. Lightweight framework and easy-to-learn API.
    2. Development based on POJO.
    3. Define business rules through efficient abstractions and apply them easily.
    4. Support the creation of compound rules.
    5. The ability to define rules using an expression language.

Official wiki document https://github.com/j-easy/easy-rules/wiki

4.Visual Rules:

Qizheng VisualRules is a business rules management system (BRMS) product that is supported by the innovation fund of the Ministry of Science and Technology and the Ministry of Finance. It is specially developed for the blank situation of the domestic rule engine market and combined with the characteristics of domestic projects.

Visual Rules is a product developed on the basis of the rule engine. It inherits the rule engine's feature that business logic changes can be independent of the program. At the same time, it combines the characteristics of domestic software projects to provide the database layer and interface layer. Provides features that are independent of configuration outside the program, so this product is not only a business rule management system, but also a rapid web development platform based on a rule engine.

​ Features will not be repeated, not open source.

5. URule rule engine

Official address: http://www.bstek.com/products/urule

Git address: https://github.com/youseries/urule.git

URule is a pure Java rule engine. It is based on the RETE algorithm. It provides six wizard-style rule sets, scripted rule sets, decision tables, cross decision tables (provided by the PRO version), decision trees, score cards and decision flows. Various types of rule definition methods, combined with a web-based designer, can quickly implement rule definition, maintenance and release.

URule provides two versions: one is an open source free version based on the Apache-2.0 protocol, the URule open source version is the first Chinese rule engine based on the Apache-2.0 protocol open source; the other is a commercial PRO version

Comparison of main functions between URULE PRO version and open source version
characteristic URULE PRO version URULE Open Source Edition
Guided decision set Have Have
Scripted decision set Have Have
Decision tree Have Have
Decision flow Have Have
Decision table Have Have
Cross decision table Have no
Complex scorecard Have no
File name, project name reconstruction Have no
Parameter name, variable constant name reconstruction Have no
Excel decision table import Have no
Save and load rule set templates Have no
Chinese project name and file name support Have no
Server push knowledge package to client function support Have no
Knowledge package optimization and compression support Have no
Push and pull support for big knowledge packages in client-server mode Have no
Support for the execution group of the rule set Have no
Support for wizard-style condition and action configuration of all nodes in the rule flow Have no
Multi-loop unit support Have no
Support for unconditional execution in loop rules Have no
Import project automatic renaming function Have no
Rule tree construction optimization Have no
Object lookup index support Have no
Support for short-circuit calculation in the rule tree Have no
Rule condition redundant calculation cache support Have no
Solution-based batch scenario testing function Have no
Knowledge package call monitoring Have no
More complete file read and write permission control Have no
Knowledge package version control Have no
Hot deployment of SpringBean and Java classes Have no
Technical Support Have no

Urule Development Guide http://www.bstek.com/resources/doc/

Guess you like

Origin blog.csdn.net/AntdonYu/article/details/106103056