Part 1 Rules EngineRule engine: The full name is business rule management system, or BRMS in English. The main idea of the rule engine is to separate the business decision part of the application and use predefined semantic modules to write business decisions (business rules), which are configured and managed by users or developers when needed. It should be noted that the rule engine is not a specific technical framework, but refers to a type of system, namely the business rule management system. Java open source rule engines include: Drools, Easy Rules, Mandarax, IBM ILOG . The most widely used and open source one is Drools . Main application scenarios: For some systems with complex business rules and frequently changing business rules, it is more suitable to use rule engines, as follows: Risk control decision system-------risk loan, risk assessment Anti-fraud projects ----- bank loans, credit verification, anti-money laundering Real-time anti-fraud platform - mobile payment, credit card consumption Drools rule engine compositionThe drools rule engine consists of the following parts:
◆Pattern Match (matcher) matches a specific rule, which is completed by it ◆Agenda ◆Execution Engine Drools rule engine conceptsWorking Memory: Working memory. The drools rule engine will obtain data from the Working Memory and perform pattern matching with the rules defined in the rule file, so the application we develop only needs to insert our data into the Working Memory. For example, in this case, we call kieSession.insert(order) to insert the order object into the working memory. Fact: In the drools rule application, the object after inserting a common JavaBean into the Working Memory is a Fact object. For example, the Order object in this case belongs to a Fact object. The Fact object is the bridge or channel for data interaction between our application and the rule engine. Rules: rule base. All the rules defined in the rule file will be loaded into the rule base. Pattern Matcher: Matcher that performs pattern matching on all rules in Rule Base and Fact objects in Working Memory. Successfully matched rules will be activated and placed in Agenda. Agenda: Agenda is used to store rules that are activated after pattern matching by the matcher. Drools basic syntaxRules file composition
A rule usually consists of three parts: attribute, condition (LHS) and result (RHS) Syntax structure: rule: keyword, indicating the start of a rule. The parameter is the unique name of the rule. attributes: rule attributes, which are the parameters between rule and when and are optional. when: Keyword followed by the conditional part of the rule. LHS(Left Hand Side): is the generic name for the conditional part of a rule. It consists of zero or more conditional elements. If LHS is empty, it will be treated as a conditional element that is always true. then: keyword followed by the result part of the rule. RHS (Right Hand Side): is the general name for the consequence or action part of a rule. end: keyword, indicating the end of a rule. Part 2: Rule comparison operators
Part 3 Drools rule attributesThe properties provided in Drools are as follows (partial properties)
Part 4 Project ApplicationIn order to achieve real-time monitoring of the video usage quality of set-top box users, the provincial set-top box soft probe platform uses real-time big data to perform quasi-real-time indicator statistics, and pushes the indicator results to Kafka. The platform's newly added alarm engine consumes Kafka data in real time and realizes real-time alarm judgment through pre-customized expert rules. The final alarm result is notified and fed back to the alarm platform in real time, realizing the life cycle from alarm to alarm recovery. Part 5 Rule Examples |
<<: Ubuntu 23.10 release episode: ISO image urgently "recalled" due to hate speech
Even among the mainstream live streaming platform...
Original title: Planned to be launched this year,...
Recently, my friends often ask me the following q...
According to foreign media reports, in order to m...
Since the push of iOS8.2 did not receive a good m...
3 questions you must know about APP promotion and...
A survey by the Chinese Center for Disease Contro...
Nokia has made too many wrong choices over the ye...
Baidu is currently greatly improving the weight o...
As the undisputed top player in China's onlin...
Feng Gong has created a comedy method of communic...
The bathroom is so small, why is the WiFi signal ...
Perhaps in the near future, the words “Made in In...
During the Internet advertising process, the oper...