CN114020361B - Chain rule processing method and device based on filter and storage medium - Google Patents

Chain rule processing method and device based on filter and storage medium Download PDF

Info

Publication number
CN114020361B
CN114020361B CN202111321878.1A CN202111321878A CN114020361B CN 114020361 B CN114020361 B CN 114020361B CN 202111321878 A CN202111321878 A CN 202111321878A CN 114020361 B CN114020361 B CN 114020361B
Authority
CN
China
Prior art keywords
rule
filter
request
units
executed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111321878.1A
Other languages
Chinese (zh)
Other versions
CN114020361A (en
Inventor
王福
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Pudong Development Bank Co Ltd
Original Assignee
Shanghai Pudong Development Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Pudong Development Bank Co Ltd filed Critical Shanghai Pudong Development Bank Co Ltd
Priority to CN202111321878.1A priority Critical patent/CN114020361B/en
Publication of CN114020361A publication Critical patent/CN114020361A/en
Application granted granted Critical
Publication of CN114020361B publication Critical patent/CN114020361B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to a chained rule processing method and device based on a filter and a storage medium, wherein the method comprises the following steps: loading a rule unit developed in advance; receiving a user request, wherein the request enters a filter; the filter constructs different responsibility chains based on the loaded rule units according to the service type of the request; and executing the responsibility chain. Compared with the prior art, the method has obvious advantages in a system requiring quick iteration, can be used on line through configuration without stopping the machine for version, and can be used for pre-checking logic rules, so that a large number of invalid requests and performance avalanche of a core logic area under extra-large concurrency are reduced.

Description

Chain rule processing method and device based on filter and storage medium
Technical Field
The present invention relates to rule processing methods, and more particularly, to a chained rule processing method, device and storage medium based on a filter.
Background
Currently, various online transaction scenes of users are more and more, and each scene has a large number of limit rules, such as a number limit, an amount limit, a user limit, a concurrency limit and the like. The java platform provides a Filter interface through which the link-type flow processing can be realized. All rules are edited into links and embedded on nodes executed by the filter, so that the pairing processing of the requests (in and out) can be realized. For example: the user purchases the commodity, firstly deducts the purchasing qualification rule of the user, and fails to deduct the commodity inventory rule due to high concurrency or other reasons, so that the purchasing qualification of the user can be returned through the paired function of the link when the request is returned.
Each rule is a separate execution unit, each unit comprising: five steps of switch-check-logic processing block-success-failure, each of which is invoked regardless of whether there is code.
And (3) a switch: only in the on state will the current rule execute.
And (3) checking: and checking the logic parameter time line of the rule, and executing the logic processing block code only when the check passes.
Success-failure: the corresponding steps are executed according to the processing result (success/failure) of the filter as a whole.
Most of the items currently on the market are directed to the processing of logic rules, basically fixed order, fixed code, and code logic of the strongly coupled core layer. Each time a certain rule is newly added or changed, a larger uncertain factor exists, long-term maintenance and version iteration are very unfavorable, and flexible configuration of the rule is not satisfied.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provide a chained rule processing method, a chained rule processing device and a storage medium based on a filter.
The aim of the invention can be achieved by the following technical scheme:
a filter-based chained rule processing method, the method comprising:
Loading a rule unit developed in advance;
receiving a user request, wherein the request enters a filter;
the filter constructs different responsibility chains based on the loaded rule units according to the service type of the request;
And executing the responsibility chain.
Preferably, the rule unit is developed by using a Groovy script.
Preferably, the rule units are configured with execution sequence numbers, the execution sequence numbers comprise a parent sequence number and a child sequence number, the parent sequence number is responsible for the execution sequence among the rule units, and the child sequence number is responsible for the execution sequence of each child rule inside the rule units.
Preferably, the parent sequence number of the rule unit is specified by the system construction, and the child sequence number is configured according to the service type of the request.
Preferably, the execution sequence number of the rule unit configuration satisfies the following condition: rules that would filter most invalid requests or uncore will execute preferentially.
Preferably, the specific way of executing the responsibility chain is as follows: and sequentially executing the steps of the switch-check-logic code blocks according to the execution sequence number of the rule unit, and sequentially executing the steps of success or failure according to the return result of the filter.
Preferably, when any rule unit in the responsibility chain fails to execute, the return request fails, and the filter sequentially executes the failure methods of the executed rule units.
Preferably, when all rule units in the responsibility chain are completely executed, the business layer logic processing area is entered.
A filter-based chained rule processing apparatus includes a memory for storing a computer program and a processor for implementing the filter-based chained rule processing method when the computer program is executed.
A storage medium having stored thereon a computer program which, when executed by a processor, implements the filter-based chained rule processing method.
Compared with the prior art, the invention has the following advantages:
(1) The Groovy script and the filter technology adopted by the invention are two core functions of java. The Groovy script language has the characteristics of easy maintenance, stability and heavy load, and is matched with the link execution characteristic of a filter to pre-check logic rules, so that a large number of invalid requests and performance avalanche of a core logic area under extra-large concurrency are reduced.
(2) The invention reasonably utilizes the dynamic loading function of Java language, has obvious advantages in a system requiring quick iteration, does not need to stop the machine for publishing, and can be used on line through configuration.
(3) The architecture adopted by the method does not form invasiveness to the existing service function and is independent of the existence of service logic. And has no hard requirement on architecture technology, and is applicable to both Spring Cloud and old SSH architectures.
(4) The rule units mentioned in the invention are all single functions with minimum particles, have small volume, almost have no interaction between rules and have very low coupling degree.
Drawings
FIG. 1 is an overall flow diagram of a filter-based chained rule processing method in accordance with the present invention;
FIG. 2 is a flowchart showing the execution of the responsibility chain according to the present invention.
Detailed Description
The invention will now be described in detail with reference to the drawings and specific examples. Note that the following description of the embodiments is merely an example, and the present invention is not intended to be limited to the applications and uses thereof, and is not intended to be limited to the following embodiments.
Examples
As shown in fig. 1, the present embodiment provides a chained rule processing method based on a filter, which includes:
Loading a rule unit developed in advance;
receiving a user request, wherein the request enters a filter;
the filter constructs different responsibility chains based on the loaded rule units according to the service type of the request;
And executing a responsibility chain.
The rule element is developed using a Groovy script. The rule units are configured with execution sequence numbers, wherein the execution sequence numbers comprise a father sequence number and a son sequence number, the father sequence number is responsible for the execution sequence among the rule units, and the son sequence number is responsible for the execution sequence of each son rule inside the rule units. The parent sequence number of the rule unit is appointed by the system construction, and the child sequence number is configured according to the service type of the request. The execution sequence number of the rule unit configuration satisfies the following condition: rules that would filter most invalid requests or uncore will execute preferentially.
The specific mode for executing the responsibility chain is as follows: and sequentially executing the steps of the switch-check-logic code blocks according to the execution sequence number of the rule unit, and sequentially executing the steps of success or failure according to the return result of the filter. When any rule unit in the responsibility chain fails to execute, the return request fails, and the filter sequentially executes the failure method of the executed rule unit. And when all rule units in the responsibility chain are completely executed, entering a business layer logic processing area.
The following is mainly specific to the loading rule unit, constructing the filter responsibility chain and the user request flow.
1. Loading rule units
The rule unit is developed by adopting a Groovy script, perfectly combined with java, and simultaneously can realize dynamic loading without restarting the application. The impact of the on-line system will be minimized when add/delete/modify operations are performed on regular cells.
Each rule element carries an execution sequence number, which may consist of two parts: parent sequence number and child sequence number. The father sequence number is responsible for the execution sequence of each rule, such as the execution of the check rule before the deduction rule; the child sequence numbers are responsible for the execution sequence in the class rules, such as which of the card number checking rules and the white list checking rules is executed preferentially.
All rule elements behave substantially identically, including switch-check-logic processing block-success-failure several steps for chain invocation. The developer only needs to fill the corresponding codes according to the rule function.
2. Construction of a Filter responsibility chain
Principle of operation of the filter: when a client sends a request to a server, if a corresponding filter intercepts the request, the filter can change the content of the request or reset the related information of the request protocol, and then the request is sent to a Servlet of the server for processing. When servlets respond to the client, the filter can intercept the response, modify or reset the response content, and respond to the client browser. In the above process, the client and the server do not need to know the existence of the filter. A filter chain constructed on the basis of this principle.
First, there needs to be a Filter portal, since the order in which the web applications are launched is: listener- > Filter- > servlet, when initializing a filter, redis information needs to be initialized in the init () logic of the filter because the Redis related Bean has not yet been initialized.
Then, the rule unit information on the chain is acquired through Redis or a database. Since the service configuring the rule unit may not be the same service as the service processing the user request, rule information needs to be pre-stored in the dis or database and then may also be stored in the service memory processing the user request.
And acquiring the loaded rule units according to different service scenes in the system, sequentially executing the steps of switching-checking-logic code blocks according to the execution sequence numbers of the rule units, and sequentially executing the steps of success or failure according to the return results of the filter.
The responsible chain execution steps are shown with reference to fig. 2.
3. User request flow
1) The system receives a user request, requesting entry into the filter.
2) The filter builds different responsibility chains according to the type of service requested.
3) Entering a chain, and circularly executing the steps of switching-checking-logic code blocks of each rule unit on the chain.
4) When any rule unit fails to execute, the return request fails, and the filter sequentially executes the failure methods of the executed rule units.
5) All rules on the chain are executed completely and enter a service layer logic processing area.
6) The filter may sequentially execute the success or failure method of the rule element that has been executed based on the result (success/failure) of the business layer logic processing region.
Based on the above-mentioned chained rule processing method based on the filter, the embodiment also provides a chained rule processing device based on the filter, which comprises a memory and a processor, wherein the memory is used for storing a computer program, and the processor is used for realizing the chained rule processing method based on the filter when executing the computer program.
In addition to this, the present embodiment also provides a storage medium having stored thereon a computer program which, when executed by a processor, implements a filter-based chained rule processing method.
Each rule unit is an independent unit and is basic data of execution of the responsibility chain, and when the rule units are configured, the rule units can be configured in any responsibility chain. The order of execution of the rule units may be set. In theory, the parent sequence number is appointed by the system construction, and the child sequence number can be exchanged at any time. It will typically be able to filter most invalid requests or uncore rules for preferential execution. Each rule on each responsibility chain executed during request is successful and failed, and when the request returns, the corresponding rule is executed again in reverse order, so that logic is clear, and high coupling between the rules is avoided. The method can be applied to any system requiring rule limitation, and the more the rules, the clearer and the clearer the logic description, the stronger the flexibility and the lower the iteration cost.
The above embodiments are merely examples, and do not limit the scope of the present invention. These embodiments may be implemented in various other ways, and various omissions, substitutions, and changes may be made without departing from the scope of the technical idea of the present invention.

Claims (6)

1. A method for processing chained rules based on a filter, the method comprising:
the rule units developed in advance are loaded, the rule units are developed by adopting a Groovy script and combined with java, and meanwhile dynamic loading can be realized;
Receiving a user request, wherein the request enters a filter, when a client sends a request to a server, the corresponding filter intercepts the request, the filter can change the content of the request or reset the related information of a request protocol, then the request is sent to a Servlet of the server for processing, when the Servlet responds to the client, the filter can intercept the response content, and after the response content is modified or reset, the response is responded to a browser of the client, and in the process, the client and the server do not know the existence of the filter; initializing Redis information in init () logic of a filter, and acquiring rule unit information on a chain through the Redis information;
the filter constructs different responsibility chains based on the loaded rule units according to the service type of the request;
executing the responsibility chain;
The rule units are configured with execution sequence numbers, the execution sequence numbers comprise father sequence numbers and child sequence numbers, the father sequence numbers are responsible for the execution sequence among the rule units, and the child sequence numbers are responsible for the execution sequence of each child rule in the rule units;
The specific way of executing the responsibility chain is as follows: sequentially executing the steps of switching-checking-logic code blocks according to the execution sequence number of the rule unit, and executing the steps of success or failure according to the return result of the filter;
When any rule unit in the responsibility chain fails to execute, returning a request failure, and sequentially executing a failure method of the executed rule unit by the filter;
Each rule on each responsibility chain executed during request is executed again in reverse order when the request returns no matter success or failure;
the rule unit is the single function with the smallest particles.
2. The method of claim 1, wherein the parent sequence number of the rule unit is specified by the system in construction, and the child sequence number is configured according to the type of service requested.
3. The method for processing chained rules based on a filter according to claim 1, wherein the execution sequence number of the rule unit configuration satisfies the following condition: rules that would filter most invalid requests or uncore will execute preferentially.
4. The method of claim 1, wherein the service layer logic processing area is entered when all rule units in the responsibility chain are executed completely.
5. A filter-based chained rule processing apparatus comprising a memory for storing a computer program and a processor for implementing the filter-based chained rule processing method according to any one of claims 1 to 4 when the computer program is executed.
6. A storage medium having stored thereon a computer program which, when executed by a processor, implements the filter-based chained rule processing method according to any one of claims 1 to 4.
CN202111321878.1A 2021-11-09 2021-11-09 Chain rule processing method and device based on filter and storage medium Active CN114020361B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111321878.1A CN114020361B (en) 2021-11-09 2021-11-09 Chain rule processing method and device based on filter and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111321878.1A CN114020361B (en) 2021-11-09 2021-11-09 Chain rule processing method and device based on filter and storage medium

Publications (2)

Publication Number Publication Date
CN114020361A CN114020361A (en) 2022-02-08
CN114020361B true CN114020361B (en) 2024-06-21

Family

ID=80062779

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111321878.1A Active CN114020361B (en) 2021-11-09 2021-11-09 Chain rule processing method and device based on filter and storage medium

Country Status (1)

Country Link
CN (1) CN114020361B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110825457A (en) * 2019-11-04 2020-02-21 江苏满运软件科技有限公司 Method and device for processing business in business engine, storage medium and electronic equipment
CN111031133A (en) * 2019-12-12 2020-04-17 京东数字科技控股有限公司 Operation method and device of business engine, storage medium and electronic device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7493614B2 (en) * 2003-03-31 2009-02-17 Microsoft Corporation System architecture and related methods for dynamically adding software components to extend functionality of system processes
US8875158B2 (en) * 2012-03-26 2014-10-28 Nec Laboratories America, Inc. Method for request profiling in service systems with kernel events
CN102883374B (en) * 2012-10-15 2015-04-22 航天恒星科技有限公司 Resource distribution method for satellite communication system
US10713090B2 (en) * 2018-05-17 2020-07-14 American Express Travel Related Services Company, Inc. Context aware prioritization in a distributed environment using tiered queue allocation
CN109241705A (en) * 2018-08-29 2019-01-18 中科鼎富(北京)科技发展有限公司 A kind of software authorization method and system
CN110532041A (en) * 2019-08-29 2019-12-03 深圳前海环融联易信息科技服务有限公司 Regulation engine method for parameter configuration, device, computer equipment and storage medium
CN110766379A (en) * 2019-09-30 2020-02-07 北京字节跳动网络技术有限公司 Business process processing method, device, medium and electronic equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110825457A (en) * 2019-11-04 2020-02-21 江苏满运软件科技有限公司 Method and device for processing business in business engine, storage medium and electronic equipment
CN111031133A (en) * 2019-12-12 2020-04-17 京东数字科技控股有限公司 Operation method and device of business engine, storage medium and electronic device

Also Published As

Publication number Publication date
CN114020361A (en) 2022-02-08

Similar Documents

Publication Publication Date Title
US7900216B2 (en) Creating a modified service request and processing the results of its execution
CN107122289B (en) Method, device and system for system regression testing
US8316079B2 (en) Method and apparatus for reliable mashup
US20170154017A1 (en) Web Application Management
CN106648556B (en) Method and device for front-end and back-end integrated development test
US20090019420A1 (en) Software development
CN103226468B (en) Front end based on business object metadata-back end communications decision
CN104168250B (en) Business Process Control method and device based on CGI frames
CN106095678A (en) Automatization's result inspection method of data bank service operation under windows platform
CN112308515A (en) NDC (network data center) processing system for NDC aggregator and service request processing method thereof
CN115328759A (en) Form verification method and device
CN114020361B (en) Chain rule processing method and device based on filter and storage medium
KR20150133902A (en) System and method for developing of service based on software product line
CN105450449A (en) File operation methods and devices
US20140019515A1 (en) Adaptive business logic configurator
CN107203373B (en) Interface control acquiring method, interface control testing method, interface control acquiring device and interface control testing device
CN113077241B (en) Approval processing method, device, equipment and storage medium
CN115374098A (en) High concurrent payment order anti-duplication method, apparatus, system, device, medium, and program product
CN112667491A (en) Function test method and device of virtual machine
CN112114857B (en) Front-end service management method, front-end server and website server
US9800692B2 (en) Expression based declarative data service execution chaining
KR20210046251A (en) Method and system for supporting survice movement
KR102134711B1 (en) Method and apparatus for managing rule of smartcontract
US11570265B2 (en) Data transmission method and system
US20240160558A1 (en) Automatic testing of interrelated components of a software application

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant