CN116302623A - Idempotent control method, device, equipment and storage medium based on interaction request - Google Patents

Idempotent control method, device, equipment and storage medium based on interaction request Download PDF

Info

Publication number
CN116302623A
CN116302623A CN202310286212.XA CN202310286212A CN116302623A CN 116302623 A CN116302623 A CN 116302623A CN 202310286212 A CN202310286212 A CN 202310286212A CN 116302623 A CN116302623 A CN 116302623A
Authority
CN
China
Prior art keywords
target
request
interactive request
client
interactive
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.)
Pending
Application number
CN202310286212.XA
Other languages
Chinese (zh)
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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202310286212.XA priority Critical patent/CN116302623A/en
Publication of CN116302623A publication Critical patent/CN116302623A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/004Error avoidance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/215Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2445Data retrieval commands; View definitions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24558Binary matching operations
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application belongs to the technical field of data processing, and particularly discloses an idempotent control method, a device, computer equipment and a storage medium based on an interaction request. By the method, when the server repeatedly receives the same request, repeated interactive requests are removed through the database duplicate removal mechanism, idempotent control is achieved, development efficiency of the docking partner is improved, and the problem of low development efficiency in the conventional business cooperation docking is solved.

Description

Idempotent control method, device, equipment and storage medium based on interaction request
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to an idempotent control method, apparatus, computer device, and storage medium based on an interaction request.
Background
With the development of business, on-line business cooperation is more and more, the number of interfaces and the request amount are large when the interfaces are used for carrying out API (Application Programming Interface ) with the partner, the interfaces are quick and accurate, and are safe, and the effective identity needs to be identified and whether repeated operation caused by repeated requests or network jitter is known in the interaction process, so that idempotent control is generated. However, the market is not only complex but also quite incomplete, and each individual is a different standard. In the business cooperation docking with hundreds of partners, no annoyance is left for various standard communication compatibility schemes, and idempotent control strategies are designed in combination with the needs of the various partners, so that most of the existing scenes can be met, and the various companies are prevented from wasting energy. Therefore, how to solve the problem of low development efficiency in the business cooperation docking is a urgent need.
Disclosure of Invention
The application provides an idempotent control method, device, computer equipment and storage medium based on an interaction request, so as to improve development efficiency in business cooperation docking.
In a first aspect, the present application provides an idempotent control method based on an interactive request, the method comprising: acquiring a target interaction request of a target client, and matching the target interaction request with an interaction request in a preset time period in an interaction request list according to a first idempotent control strategy to generate a matching result; judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result; if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request.
In a second aspect, the present application further provides an idempotent control device based on an interaction request, where the idempotent control device includes:
the interactive request matching module is used for acquiring a target interactive request of a target client, matching the target interactive request with the interactive request in a preset time period in an interactive request list according to a first idempotent control strategy, and generating a matching result;
the interactive request list judging module is used for judging whether an interactive request matched with the target interactive request exists in the interactive request list or not based on the matching result;
and the database deduplication module is used for clearing the interactive request matched with the target interactive request based on a database deduplication rule if the interactive request matched with the target interactive request exists in the interactive request list, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request.
In a third aspect, the present application also provides a computer device comprising a memory and a processor; the memory is used for storing a computer program; the processor is configured to execute the computer program and implement the idempotent control method as described above when the computer program is executed.
In a fourth aspect, the present application also provides a computer readable storage medium storing a computer program which, when executed by a processor, causes the processor to implement an idempotent control method as described above.
The application discloses an idempotent control method, a device, computer equipment and a storage medium based on an interaction request, wherein the idempotent control method comprises the steps of obtaining a target interaction request of a target client, matching the target interaction request with the interaction request in a preset time period in an interaction request list according to a first idempotent control strategy, and generating a matching result; judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result; if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request. By the method, when the server repeatedly receives the same request, repeated interactive requests are removed through the database duplicate removal mechanism, idempotent control is achieved, development efficiency of the docking partner is improved, and the problem of low development efficiency in the conventional business cooperation docking is solved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a first embodiment of an idempotent control method based on an interactive request provided by an embodiment of the present application;
FIG. 2 is a flow chart illustrating a second embodiment of an idempotent control method based on an interactive request provided by an embodiment of the present application;
FIG. 3 is a flow chart illustrating a third embodiment of an idempotent control method based on an interactive request provided by an embodiment of the present application;
FIG. 4 is a fourth embodiment of an idempotent control method based on an interactive request provided by an embodiment of the present application;
FIG. 5 is a schematic block diagram of an idempotent control device based on an interactive request provided by an embodiment of the present application;
fig. 6 is a schematic block diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The flow diagrams depicted in the figures are merely illustrative and not necessarily all of the elements and operations/steps are included or performed in the order described. For example, some operations/steps may be further divided, combined, or partially combined, so that the order of actual execution may be changed according to actual situations.
It is to be understood that the terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
The embodiment of the application provides an idempotent control method and device based on an interaction request, computer equipment and a storage medium. The idempotent control method can be applied to a server, and repeated interactive requests are removed through a database duplicate removal mechanism, so that idempotent control is realized. The server may be an independent server or a server cluster.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a flowchart of a first embodiment of an idempotent control method based on an interactive request according to an embodiment of the present application. The idempotent control method can be applied to a server, and repeated interactive requests are removed through a database deduplication mechanism, so that idempotent control is realized.
As shown in fig. 1, the idempotent control method specifically includes steps S101 to S103.
S101, acquiring a target interaction request of a target client, and matching the target interaction request with an interaction request in a preset time period in an interaction request list according to a first idempotent control strategy to generate a matching result;
s102, judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result;
and S103, if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request.
In a specific embodiment, there are three main methods for deduplication operation in a database (deleting an SQL statement repeatedly recorded in the database):
(1) A rowid method;
(2) A group by method;
(3) The disartition method.
1. By the rowid method:
according to the rowid attribute of the Oracle band, whether repeated sentences exist or not can be judged;
(1) Look up the same data for name in tables 1 and 2:
Select*from table1 a
Where rowid!=(select max(rowid)
from table2 b
Where a.name1=b.name1
And a.name2=b.name2......)
(2) All data in table 1 and table 2 for which the name is the same are deleted:
Delete from table1 a
Where rowid!=(select max(rowid)
From table2 b
Where a.name1=b.name1
And a.name2=b.name2.......)
2. by group by method
The method is mainly used for grouping statistics and is generally used in an aggregation function;
(1) Checking data
Select count (num), max (name) from student lists the number of duplicate records in the table and the attributes of the student's name.
Group by num
The number of times of num list occurrence in the table is more than one time after the number of times of num list (num) is counted and grouped according to num.
(2) Deleting data
Delete from student
Group by num
Having count(num)>1
Data for all duplicates in num column of the/(delete) table
3. By distict method
The method is generally used for removing the duplicate of a smaller table, filtering redundant duplicate records and returning non-duplicate records or fields;
(1)select distinct name
From student。
specifically, the time when the interactive request sent by the client is received is taken as the starting time, and a period of time before and after the starting time is taken as a preset period of time, for example, 3 seconds before and after the starting time, so as to judge whether the interactive request received by the server is a repeated request caused by misoperation or network delay of a user.
The embodiment discloses an idempotent control method, a device, a computer device and a storage medium based on an interaction request, wherein the idempotent control method comprises the steps of obtaining a target interaction request of a target client, matching the target interaction request with the interaction request in a preset time period in an interaction request list according to a first idempotent control strategy, and generating a matching result; judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result; if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request. By the method, when the server repeatedly receives the same request, repeated interactive requests are removed through the database duplicate removal mechanism, idempotent control is achieved, development efficiency of the docking partner is improved, and the problem of low development efficiency in the conventional business cooperation docking is solved.
Based on the embodiment shown in fig. 1, the idempotent control method further comprises, after said step S102:
and if the interactive request matched with the target interactive request does not exist in the interactive request list, executing a processing instruction corresponding to the target interactive request based on a second idempotent control strategy, and feeding back a processing result corresponding to the processing instruction to realize idempotent control of the interactive request.
In a specific embodiment, for a high concurrency scenario, repeated requests may exist for many times at the same time, and the requests are unchanged at a server, and the request idempotent needs to adopt a setnx mechanism of redis, and a command returns 0 to be successful, 1 to be failed, and because the service uniqueness of each partner may be repeated, the identification of a client unique identity and a server api needs to be added in service flow.
In Redis, so-called SETNX is an abbreviation for [ SET if Not exists ], i.e. it is only provided when not present, with which the effect of the lock can be achieved. For example, there is currently an interface for querying a database, since the call amount of the query database is relatively large, a cache is added, and after the cache is set to expire, the problem is that when the concurrency amount is relatively large, if there is no lock mechanism, a large number of concurrent requests penetrate the cache to directly query the database at the moment of expiration of the cache, so that avalanche effect is caused, if there is a lock mechanism, only one request can be controlled to update the cache, and other requests either wait or use the expired cache as required.
The interactive feedback instruction may be:
if the interactive feedback instruction is 0, the idempotent control is successful;
and if the interactive feedback instruction is 1, the idempotent control fails.
In a specific embodiment, the target client requests the service end first, and can obtain a unique field capable of representing the requested service, store the field in the redis in a SETNX mode and set a corresponding timeout time according to the service, and if the setting is successful, prove that the request is the first request, execute subsequent service logic; if the setting fails, the current request is executed on behalf of having been executed, and the return is made directly.
The target client first sends a request to acquire the token, the server generates a globally unique ID as the token to be stored in redis, and the ID is returned to the target client. The target client must carry the token when calling the service request for the second time, the server checks the token, if the check is successful, the service is executed, and the token in redis is deleted; if the verification fails, indicating that the redis has no corresponding token, indicating repeated operation, and directly returning the appointed result to the target client.
The embodiment discloses an idempotent control method, a device, a computer device and a storage medium based on an interaction request, wherein the idempotent control method comprises the steps of obtaining a target interaction request of a target client, matching the target interaction request with the interaction request in a preset time period in an interaction request list according to a first idempotent control strategy, and generating a matching result; judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result; if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request. By the method, when the server repeatedly receives the same request, repeated interactive requests are removed through the database duplicate removal mechanism, idempotent control is achieved, development efficiency of the docking partner is improved, and the problem of low development efficiency in the conventional business cooperation docking is solved.
Referring to fig. 2, fig. 2 is a schematic flow chart of a second embodiment of an idempotent control method based on an interactive request according to an embodiment of the present application. The idempotent control method can be applied to a server, and the instruction is fed back to the target client through the database optimistic lock mechanism, so that idempotent control is realized.
As shown in fig. 2, the idempotent control method further includes steps S1011 to S1013 before the step S101.
S1011, when the target interaction request is received, a self-checking instruction is sent to the target client based on a third idempotent control strategy so as to judge whether an interaction request matched with the target interaction request exists in a history interaction request table through the target client;
s1012, receiving a self-checking result fed back by the target client based on the self-checking instruction;
and S1013, if the self-checking result is that the interactive request matched with the target interactive request exists in the history interactive request table, refusing to execute a processing instruction corresponding to the target interactive request, and feeding back a corresponding executed reminding message to the target client so as to realize idempotent control of the interactive request.
In a specific embodiment, a history interaction request table is stored in the client, and each interaction request sent to the server is compared with the history interaction request table, so that it is determined that in a preset time, no interaction request identical to the currently sent interaction request exists.
In the embodiment, the optimistic lock refers to the fact that when the database is operated (updating operation), the idea is optimistic, and the operation is considered to not cause conflict, when the data is operated, no other special processing is performed (i.e. no locking is performed), and after updating, whether the conflict exists is judged. For example, when data in a table is operated (updated), a version field is added to the data table, and each time the operation is performed, the version number of that record is added to 1. That is, firstly, inquiring the record to obtain a version field, if the record is to be operated (updated), firstly judging whether the value of version is equal to the value of version when just inquired, if so, indicating that no other program is operated during the period, and then updating the value of version field by 1; if the version value at the moment is found to be unequal to the version value just acquired during updating, the updating operation is not performed when other programs are operated on during the period.
Referring to fig. 3, fig. 3 is a schematic flow chart of a third embodiment of an idempotent control method based on an interactive request according to an embodiment of the present application. The idempotent control method can be applied to a server, and an instruction is fed back to a target client through an SETNX mechanism, so that idempotent control is realized.
As shown in fig. 3, the idempotent control method further includes steps S1014 to S1016 before the step S101.
S1014, when the target interaction request sent by the target client is received, acquiring a target application program interface API identifier of the target client;
s1015, judging whether the target client is a legal client or not according to a preset client registration information list and the target API identifier;
s1016, if the target client is an illegal client, refusing to execute the interaction request sent by the target client.
In particular embodiments, the API (Application Programming Interface, application program interface) is a predefined interface (e.g., function, HTTP interface) or a convention that refers to the engagement of different components of a software system. To provide a set of routines that applications and developers can access based on certain software or hardware without having to access source code or understand the details of the internal operating mechanisms. One of the main functions of the API is to provide a generic set of functions. The API is also a middleware for providing data sharing for various platforms. In programming practice, the programming interface is designed to divide the responsibilities of the software system reasonably. The good interface design can reduce the mutual dependence of all parts of the system, improve the cohesion of the constituent units and reduce the coupling degree among the constituent units, thereby improving the maintainability and the expandability of the system.
The embodiment discloses an idempotent control method, a device, a computer device and a storage medium based on an interaction request, wherein the idempotent control method comprises the steps of obtaining a target interaction request of a target client, matching the target interaction request with the interaction request in a preset time period in an interaction request list according to a first idempotent control strategy, and generating a matching result; judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result; if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request. By the method, when the server repeatedly receives the same request, repeated interactive requests are removed through the database duplicate removal mechanism, idempotent control is achieved, development efficiency of the docking partner is improved, and the problem of low development efficiency in the conventional business cooperation docking is solved.
Referring to fig. 4, fig. 4 is a flowchart of a fourth embodiment of an idempotent control method based on an interactive request according to an embodiment of the present application. The idempotent control method can be applied to a server, and the instruction is fed back to the target client through the database optimistic lock mechanism, so that idempotent control is realized.
As shown in fig. 4, after the step S1016 of the idempotent control method, the method specifically includes:
s1017, if the target client is the legal client, when receiving a Token acquisition instruction sent by the target client, sending a target Token to the target client, and storing the target Token into a remote dictionary service Redis;
s1018, when a secondary interaction request sent by the target client is received, acquiring a current token in the secondary interaction request, and comparing the current token with the target token stored in the Redis;
s1019, if the current token is the target token, judging that the target client is the legal client.
In a specific embodiment, the valid time of the token is that the issued token can be used normally only in the ttl time (authentication, user information acquisition, etc.), after the valid time is passed, the token is discarded, placed in a blacklist, and the authentication of the routing middleware will fail.
The refresh time refers to whether a previously issued token (which has been disabled at this time) can be used in exchange for a new token, the validity time of the new token, or the ttl, within the refresh_ttl time. Subsequent authentication verifies that a new token needs to be used to pass normally. The process is repeated by exchanging the token which is about to expire before for a new token until after refresh_ttl, the whole process will be invalid, the old token is not supporting exchanging for the new token, and the user login operation must be executed to issue the new token.
Based on the embodiment shown in fig. 4, this embodiment specifically further includes:
when a secondary interaction request sent by the target client is received, a target token in the secondary interaction request is acquired;
acquiring the current request time corresponding to the target token, and judging whether the target token is effective or not according to the effective time of the target token and the current request time prestored in a remote dictionary service Redis;
and if the target token is valid, judging that the target client is the legal client.
Based on all the above embodiments, the present embodiment further includes:
and obtaining an idempotent annotation, and generating the first idempotent control strategy, the second idempotent control strategy and/or the third idempotent control strategy through the idempotent annotation.
Referring to fig. 5, fig. 5 is a schematic block diagram of an idempotent control device based on an interactive request according to an embodiment of the present application, where the idempotent control device is configured to execute the aforementioned idempotent control method. Wherein the idempotent control device can be configured at a server.
As shown in fig. 5, the idempotent control device 400 includes:
the interactive request matching module 10 is configured to obtain a target interactive request of a target client, and match the target interactive request with an interactive request in a preset time period in an interactive request list according to a first idempotent control policy, so as to generate a matching result;
an interactive request list judging module 20, configured to judge whether an interactive request matched with the target interactive request exists in the interactive request list based on the matching result;
and the database deduplication module 30 is configured to, if there is an interaction request matching the target interaction request in the interaction request list, clear the interaction request matching the target interaction request based on a database deduplication rule, and reserve and execute a processing instruction corresponding to the target interaction request to implement idempotent control of the interaction request.
Further, the interactive request matching module 10 specifically includes:
the interactive request matching unit is used for acquiring a target interactive request of the target client, and matching the target interactive request with the interactive request in a preset time period in the interactive request list according to a first idempotent control strategy to generate a matching result.
Further, the interactive request list determining module 20 specifically includes:
and the interactive request list judging unit is used for judging whether an interactive request matched with the target interactive request exists in the interactive request list or not based on the matching result.
Further, the database deduplication module 30 specifically includes:
and the database deduplication unit is used for clearing the interactive request matched with the target interactive request based on a database deduplication rule if the interactive request matched with the target interactive request exists in the interactive request list, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request.
Further, the idempotent control device 400 further includes an SETNX idempotent control module, specifically including:
and the SETNX idempotent control unit is used for executing a processing instruction corresponding to the target interaction request based on a second idempotent control strategy if the interaction request matched with the target interaction request does not exist in the interaction request list, and feeding back a processing result corresponding to the processing instruction so as to realize idempotent control of the interaction request.
Further, the idempotent control device 400 further includes an optimistically locked idempotent control feedback module, specifically including:
the self-checking instruction sending unit is used for sending a self-checking instruction to the target client based on a third idempotent control strategy when the target interaction request is received, so that whether an interaction request matched with the target interaction request exists in a history interaction request table or not is judged through the target client;
the self-checking result receiving unit is used for receiving self-checking result calculation fed back by the target client based on the self-checking instruction;
and the interactive request execution unit is used for refusing to execute the processing instruction corresponding to the target interactive request and feeding back the corresponding executed reminding message to the target client side so as to realize the idempotent control of the interactive request if the self-checking result is that the interactive request matched with the target interactive request exists in the historical interactive request table.
Further, the idempotent control device 400 further includes a client identification module, specifically including:
the API identification acquisition unit is used for acquiring a target application program interface API identification of the target client when receiving the target interaction request sent by the target client;
the legal client judging unit is used for judging whether the target client is a legal client or not according to a preset client registration information list and the target API identifier;
an illegal client rejecting unit, configured to reject execution of the interaction request sent by the target client if the target client is an illegal client;
further, the idempotent control device 400 further includes a token verification module, specifically including:
the Token distribution unit is used for sending a target Token to the target client and storing the target Token into a remote dictionary service Redis when receiving a Token acquisition instruction sent by the target client if the target client is the legal client;
the token verification unit is used for acquiring a current token in the secondary interaction request when the secondary interaction request sent by the target client is received, and comparing the current token with the target token stored in the Redis;
and the legal client judgment unit is used for judging that the target client is the legal client if the current token is the target token.
Further, the idempotent control device 400 further includes a secondary request module, specifically including:
the secondary receiving token unit is used for acquiring a target token in the secondary interaction request when the secondary interaction request sent by the target client is received;
the token validity period judging unit is used for acquiring the current request time corresponding to the target token and judging whether the target token is valid or not according to the valid time of the target token and the current request time prestored in a remote dictionary service Redis;
and the validity period legal judging unit is used for judging that the target client is the legal client if the target token is valid.
Further, the idempotent control device 400 further includes an automatic calling module, specifically including:
and the automatic calling unit is used for acquiring the idempotent notes and generating the first idempotent control strategy, the second idempotent control strategy and/or the third idempotent control strategy through the idempotent notes.
It should be noted that, for convenience and brevity of description, the specific working process of the apparatus and each module described above may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The apparatus described above may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 6.
Referring to fig. 6, fig. 6 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device may be a server.
With reference to FIG. 6, the computer device includes a processor, memory, and a network interface connected by a system bus, where the memory may include a non-volatile storage medium and an internal memory.
The non-volatile storage medium may store an operating system and a computer program. The computer program comprises program instructions that, when executed, cause the processor to perform any of the idempotent control methods based on the interactive requests.
The processor is used to provide computing and control capabilities to support the operation of the entire computer device.
The internal memory provides an environment for the execution of a computer program in a non-volatile storage medium that, when executed by the processor, causes the processor to perform any of a variety of idempotent control methods based on interactive requests.
The network interface is used for network communication such as transmitting assigned tasks and the like. It will be appreciated by those skilled in the art that the structure shown in fig. 6 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
It should be appreciated that the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein in one embodiment the processor is configured to run a computer program stored in the memory to implement the steps of:
acquiring a target interaction request of a target client, and matching the target interaction request with an interaction request in a preset time period in an interaction request list according to a first idempotent control strategy to generate a matching result;
judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result;
if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request.
In one embodiment, based on the matching result, after determining whether there is an interactive request matching the target interactive request in the interactive request list, the method is further used for implementing:
and if the interactive request matched with the target interactive request does not exist in the interactive request list, executing a processing instruction corresponding to the target interactive request based on a second idempotent control strategy, and feeding back a processing result corresponding to the processing instruction to realize idempotent control of the interactive request.
In one embodiment, a target interaction request of a target client is obtained, and the target interaction request is matched with an interaction request in a preset time period in an interaction request list according to a first idempotent control strategy, and before a matching result is generated, the method is further used for realizing:
when the target interaction request is received, based on a third idempotent control strategy, a self-checking instruction is sent to the target client so as to judge whether an interaction request matched with the target interaction request exists in a history interaction request table through the target client;
receiving a self-checking result fed back by the target client based on the self-checking instruction;
and if the self-checking result is that the interactive request matched with the target interactive request exists in the history interactive request table, refusing to execute a processing instruction corresponding to the target interactive request, and feeding back a corresponding executed reminding message to the target client so as to realize idempotent control of the interactive request.
In one embodiment, a target interaction request of a target client is obtained, and the target interaction request is matched with an interaction request in a preset time period in an interaction request list according to a first idempotent control strategy, and before a matching result is generated, the method is further used for realizing:
when the target interaction request sent by the target client is received, acquiring a target application program interface API identifier of the target client;
judging whether the target client is a legal client or not according to a preset client registration information list and the target API identifier;
and if the target client is an illegal client, refusing to execute the interaction request sent by the target client.
In one embodiment, after determining whether the target client is a legal client according to a preset client registration information list and the target API identifier, the method is further used for implementing:
if the target client is the legal client, when receiving a Token acquisition instruction sent by the target client, sending a target Token to the target client, and storing the target Token into a remote dictionary service Redis;
when a secondary interaction request sent by the target client is received, acquiring a current token in the secondary interaction request, and comparing the current token with the target token stored in the Redis;
and if the current token is the target token, judging that the target client is the legal client.
In one embodiment, the idempotent control method is also used to implement:
when a secondary interaction request sent by the target client is received, a target token in the secondary interaction request is acquired;
acquiring the current request time corresponding to the target token, and judging whether the target token is effective or not according to the effective time of the target token and the current request time prestored in a remote dictionary service Redis;
and if the target token is valid, judging that the target client is the legal client.
In one embodiment, the idempotent control method is also used to implement:
and obtaining an idempotent annotation, and generating the first idempotent control strategy, the second idempotent control strategy and/or the third idempotent control strategy through the idempotent annotation.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, the computer program comprises program instructions, and the processor executes the program instructions to realize any idempotent control method provided by the embodiment of the application.
The computer readable storage medium may be an internal storage unit of the computer device according to the foregoing embodiment, for example, a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, which are provided on the computer device.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. An idempotent control method based on an interaction request is characterized by comprising the following steps:
acquiring a target interaction request of a target client, and matching the target interaction request with an interaction request in a preset time period in an interaction request list according to a first idempotent control strategy to generate a matching result;
judging whether an interaction request matched with the target interaction request exists in the interaction request list or not based on the matching result;
if the interactive request matched with the target interactive request exists in the interactive request list, clearing the interactive request matched with the target interactive request based on a database duplication removal rule, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request.
2. The idempotent control method according to claim 1, wherein after determining whether there is an interactive request matching the target interactive request in the interactive request list based on the matching result, further comprising:
and if the interactive request matched with the target interactive request does not exist in the interactive request list, executing a processing instruction corresponding to the target interactive request based on a second idempotent control strategy, and feeding back a processing result corresponding to the processing instruction to realize idempotent control of the interactive request.
3. The idempotent control method according to claim 1, wherein the obtaining the target interactive request of the target client, and according to the first idempotent control policy, matching the target interactive request with the interactive request in the preset time period in the interactive request list, and before generating the matching result, further comprises:
when the target interaction request is received, based on a third idempotent control strategy, a self-checking instruction is sent to the target client so as to judge whether an interaction request matched with the target interaction request exists in a history interaction request table through the target client;
receiving a self-checking result fed back by the target client based on the self-checking instruction;
and if the self-checking result is that the interactive request matched with the target interactive request exists in the history interactive request table, refusing to execute a processing instruction corresponding to the target interactive request, and feeding back a corresponding executed reminding message to the target client so as to realize idempotent control of the interactive request.
4. The idempotent control method according to claim 1, wherein the obtaining the target interactive request of the target client, and according to the first idempotent control policy, matching the target interactive request with the interactive request in the preset time period in the interactive request list, and before generating the matching result, further comprises:
when the target interaction request sent by the target client is received, acquiring a target application program interface API identifier of the target client;
judging whether the target client is a legal client or not according to a preset client registration information list and the target API identifier;
and if the target client is an illegal client, refusing to execute the interaction request sent by the target client.
5. The idempotent control method of claim 4, wherein after determining whether the target client is a legitimate client according to a preset client registration information list and the target API identifier, further comprising:
if the target client is the legal client, when receiving a Token acquisition instruction sent by the target client, sending a target Token to the target client, and storing the target Token into a remote dictionary service Redis;
when a secondary interaction request sent by the target client is received, acquiring a current token in the secondary interaction request, and comparing the current token with the target token stored in the Redis;
and if the current token is the target token, judging that the target client is the legal client.
6. The idempotent control method of claim 4, further comprising:
when a secondary interaction request sent by the target client is received, a target token in the secondary interaction request is acquired;
acquiring the current request time corresponding to the target token, and judging whether the target token is effective or not according to the effective time of the target token and the current request time prestored in a remote dictionary service Redis;
and if the target token is valid, judging that the target client is the legal client.
7. The idempotent control method according to claims 1-6, further comprising:
and obtaining an idempotent annotation, and generating the first idempotent control strategy, the second idempotent control strategy and/or the third idempotent control strategy through the idempotent annotation.
8. An idempotent control device based on an interactive request, characterized in that the idempotent control device comprises:
the interactive request matching module is used for acquiring a target interactive request of a target client, matching the target interactive request with the interactive request in a preset time period in an interactive request list according to a first idempotent control strategy, and generating a matching result;
the interactive request list judging module is used for judging whether an interactive request matched with the target interactive request exists in the interactive request list or not based on the matching result;
and the database deduplication module is used for clearing the interactive request matched with the target interactive request based on a database deduplication rule if the interactive request matched with the target interactive request exists in the interactive request list, and reserving and executing a processing instruction corresponding to the target interactive request so as to realize idempotent control of the interactive request.
9. A computer device, the computer device comprising a memory and a processor;
the memory is used for storing a computer program;
the processor for executing the computer program and for implementing the idempotent control method according to any one of claims 1 to 7 when the computer program is executed.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by a processor, causes the processor to implement the idempotent control method according to any one of claims 1 to 7.
CN202310286212.XA 2023-03-14 2023-03-14 Idempotent control method, device, equipment and storage medium based on interaction request Pending CN116302623A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310286212.XA CN116302623A (en) 2023-03-14 2023-03-14 Idempotent control method, device, equipment and storage medium based on interaction request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310286212.XA CN116302623A (en) 2023-03-14 2023-03-14 Idempotent control method, device, equipment and storage medium based on interaction request

Publications (1)

Publication Number Publication Date
CN116302623A true CN116302623A (en) 2023-06-23

Family

ID=86797556

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310286212.XA Pending CN116302623A (en) 2023-03-14 2023-03-14 Idempotent control method, device, equipment and storage medium based on interaction request

Country Status (1)

Country Link
CN (1) CN116302623A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116594598A (en) * 2023-06-30 2023-08-15 北京新里程叮铃科技有限公司 Information interaction method and device of service system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116594598A (en) * 2023-06-30 2023-08-15 北京新里程叮铃科技有限公司 Information interaction method and device of service system
CN116594598B (en) * 2023-06-30 2023-09-29 北京新里程叮铃科技有限公司 Information interaction method and device of service system

Similar Documents

Publication Publication Date Title
US10936578B2 (en) Client-driven commit of distributed write transactions in a database environment
CN107070919B (en) Idempotency for database transactions
US6012059A (en) Method and apparatus for replicated transaction consistency
CN106598992B (en) Database operation method and device
CN111522631B (en) Distributed transaction processing method, device, server and medium
CN104793988A (en) Cross-database distributed transaction implementation method and device
US8600933B2 (en) Multi-master attribute uniqueness
US10318520B2 (en) System and method for reducing communications overhead in a distributed transactions environment by modifying implementation of the transaction end function
JP2008524694A (en) Techniques for providing locks for file operations in database management systems
WO2023045617A1 (en) Transaction data processing method and apparatus, device and medium
Hirve et al. Archie: a speculative replicated transactional system
CN104219235A (en) Distributed transaction requesting method and device
CN116302623A (en) Idempotent control method, device, equipment and storage medium based on interaction request
US20080082534A1 (en) Method and system for providing locking behavior
US8996484B2 (en) Recursive lock-and-propagate operation
US8990440B2 (en) Reusing system configuration information and metadata for related operations
CN109522043A (en) Method and device for managing configuration data and storage medium
US20130006920A1 (en) Record operation mode setting
CN112328637B (en) High-speed distributed data caching method, device, computer equipment and storage medium
CN113168405B (en) Database management service providing system
CN114553521A (en) Remote memory access method, device, equipment and medium
US10216590B2 (en) Communication control determination of storing state based on a requested data operation and a schema of a table that stores therein data to be operated by the data operation
CN115131097A (en) Order anti-duplication method and device
CN113448493B (en) Method, electronic device and computer readable medium for backing up data
WO2022108792A1 (en) Accelerating transactions from a trusted source

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