Interface calling method and device, computer readable storage medium and electronic device

By defining anti-duplication annotation and facet layer processing in the interface call method, the data inconsistency and system unavailability caused by interface calls during task execution is solved, the system consistency and availability are achieved, and system flexibility and resource utilization are improved. Rate.

CN113821277BActive Publication Date: 2025-01-07BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010609318.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-29
Publication Date
2025-01-07
Estimated Expiration
2040-06-29

AI Technical Summary

Technical Problem

The prior art If another task calls the same interface method during task execution, it may result in inconsistent data or system unavailability, especially when frequently called.

Method used

By defining anti-duty annotation in the interface call method, entering the facet layer processing, controlling the time window of interface call, preventing concurrent operations, decoupling anti-duty judgment and task processing.

Benefits of technology

The system consistency and availability are achieved, data inconsistency and system crashes caused by repeated calls are avoided, and system flexibility and resource utilization are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113821277B_ABST
    Figure CN113821277B_ABST
Patent Text Reader

Abstract

The present disclosure provides an interface calling method, an interface calling device, a computer-readable storage medium, and an electronic device; and relates to the field of communication technology. The interface calling method comprises: receiving an interface calling request, and obtaining a method entry corresponding to the method to be called according to the interface calling request; when the method contains an anti-duplicate annotation, entering the aspect layer processing according to the anti-duplicate annotation; obtaining the logical judgment result obtained by the processing, and entering the method entry to call the method according to the logical judgment result. The present disclosure can achieve anti-duplicate and anti-concurrency in the interface calling process by defining an anti-duplicate annotation in the method, thereby ensuring the consistency and availability of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of communication technology, and in particular to an interface calling method, an interface calling device, a computer-readable storage medium, and an electronic device. Background Art

[0002] As a shared boundary between systems or between systems and people, interfaces can provide grammatical interoperability support by setting standard specifications, thereby reducing the coupling between interactive applications and increasing the flexibility of task processing.

[0003] However, if another task calls the same interface method during the execution of a task, it will cause problems such as data inconsistency. Alternatively, frequent calls in a short period of time will also cause problems such as system unavailability.

[0004] Therefore, it is necessary to provide an interface calling method, by which anti-duplicate and anti-concurrency can be achieved during the interface calling process, thereby ensuring the consistency and availability of the system.

[0005] The information disclosed in the above background section is only for enhancing the understanding of the background of the present disclosure and therefore may contain information that does not constitute the prior art known to a person of ordinary skill in the art. Summary of the invention

[0006] The embodiments of the present disclosure provide an interface calling method and device, a computer-readable storage medium, and an electronic device, which can implement anti-duplication and anti-concurrency in the interface calling process by defining anti-duplication annotations in the method, thereby ensuring the consistency and availability of the system.

[0007] According to a first aspect of the present disclosure, there is provided an interface calling method, comprising:

[0008] Receive an interface call request, and obtain a method entry corresponding to a method to be called according to the interface call request;

[0009] When the method includes an anti-duplicate annotation, entering the section layer processing according to the anti-duplicate annotation;

[0010] Obtain the logical judgment result obtained by processing, and enter the method entry to call the method according to the logical judgment result.

[0011] In an exemplary embodiment of the present disclosure, the interface call request includes a signature verification string and encrypted task data;

[0012] After receiving the interface call request, the method further includes:

[0013] Obtain the signature verification string and perform a signature verification operation using the corresponding signature verification key;

[0014] When the signature verification succeeds, the encrypted task data is decrypted to obtain the task data.

[0015] In an exemplary embodiment of the present disclosure, the interface call request includes the method name of the method; the receiving the interface call request and obtaining the method entry corresponding to the method to be called according to the interface call request includes:

[0016] Receive the interface call request, and obtain the method name of the method in the interface call request;

[0017] Obtain the method entry corresponding to the method according to the method name.

[0018] In an exemplary embodiment of the present disclosure, when the method includes an anti-duplicate annotation, entering the section layer processing according to the anti-duplicate annotation includes:

[0019] When the method includes an anti-duplicate annotation, a corresponding notification is executed according to the anti-duplicate annotation, wherein the notification is a pre-notification, a surround notification, a post-notification or an exception notification.

[0020] In an exemplary embodiment of the present disclosure, the executing corresponding notification according to the anti-duplicate annotation includes:

[0021] Acquire the attribute value based on the anti-duplicate annotation, and execute the notification according to the attribute value;

[0022] The attribute value includes the method identifier, method group identifier and time window of the method, and the time window is the time interval allowed between two interface call requests.

[0023] In an exemplary embodiment of the present disclosure, the notification is a pre-notification; and executing the notification according to the attribute value includes:

[0024] The time window is obtained, and it is determined whether the time difference between the current request time of the interface call request and the previous request time is greater than or equal to the time window, and a logic determination result is obtained.

[0025] In an exemplary embodiment of the present disclosure, entering the method entry and calling the method according to the logic judgment result includes:

[0026] When the result of the logic judgment is yes, the method entry is entered to call the method.

[0027] According to a second aspect of the present disclosure, there is provided an interface calling device, comprising:

[0028] A receiving module, used to receive an interface call request, and obtain a method entry corresponding to a method to be called according to the interface call request;

[0029] A processing module, used for entering the section layer processing according to the anti-duplicate annotation when the method includes the anti-duplicate annotation;

[0030] The calling module is used to obtain the logical judgment result obtained by processing, and enter the method entry to call the method according to the logical judgment result.

[0031] According to a third aspect of the present disclosure, there is provided an electronic device, including:

[0032] processor;

[0033] A memory for storing executable instructions of the processor; wherein the processor is configured to perform any one of the above methods by executing the executable instructions.

[0034] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, any one of the above methods is implemented.

[0035] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects:

[0036] In the interface calling method provided in the example implementation mode of the present disclosure, first, an interface calling request is received, and the method entry corresponding to the method to be called is obtained according to the interface calling request; then, it is determined whether the method contains an anti-duplicate annotation, and when it contains an anti-duplicate annotation, the corresponding aspect layer is entered for processing according to the anti-duplicate annotation; finally, the logical judgment result obtained by the aspect layer processing is obtained, and the above method is called according to the logical judgment result. On the one hand, by defining anti-duplicate annotations in the method, the problem of data inconsistency in the system caused by repeated calls to the interface can be improved. On the other hand, the above aspect layer processing can control the time window of the interface call by defining notifications, thereby preventing concurrent operations on the interface, and can also solve the system unavailability caused by instantaneous frequent calls. In addition, the aspect layer processing method can decouple the anti-duplicate judgment and task processing, and there is no need to perform logical judgment separately in the method corresponding to each task, which improves the flexibility of the system and saves system resources.

[0037] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0039] Figure 1 A schematic diagram showing an exemplary system architecture of an interface calling method and device to which the embodiments of the present disclosure can be applied;

[0040] Figure 2 A schematic diagram showing the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown;

[0041] Figure 3 A flowchart schematically shows a process of an interface calling method according to an embodiment of the present disclosure;

[0042] Figure 4 A flowchart schematically shows a process of an interface calling method according to an embodiment of the present disclosure;

[0043] Figure 5 A block diagram of an interface calling device according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0044] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, providing these embodiments will make the present disclosure more comprehensive and complete, and will fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.

[0045] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0046] Figure 1 A schematic diagram of a system architecture of an exemplary application environment to which an interface calling method and device according to an embodiment of the present disclosure can be applied is shown.

[0047] like Figure 1 As shown, the system architecture 100 may include one or more of terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc. The terminal devices 101, 102, 103 may be various electronic devices with display screens, including but not limited to desktop computers, portable computers, smart phones, tablet computers, etc. It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.

[0048] The interface calling method provided in the embodiment of the present disclosure can be executed by the terminal devices 101, 102, and 103, and accordingly, the interface calling device can be set in the terminal devices 101, 102, and 103. The interface calling method provided in the embodiment of the present disclosure can also be executed by the server 105, and accordingly, the interface calling device can be set in the server 105. The interface calling method provided in the embodiment of the present disclosure can also be jointly executed by the terminal devices 101, 102, and 103 and the server 105, and accordingly, the interface calling device can be set in the terminal devices 101, 102, and 103 and the server 105, which is not particularly limited in this exemplary embodiment.

[0049] For example, in this example implementation, the calling end can send an interface call request through terminal devices 101, 102, and 103. After receiving the interface call request, terminal devices 101, 102, and 103 will obtain the method entry corresponding to the method to be called through the interface call request. Then, first determine whether the method contains an anti-duplicate annotation, and enter the aspect layer for processing according to the defined anti-duplicate annotation; finally, obtain the logical judgment result obtained by the processing, and enter the above method entry to call the corresponding method according to the logical judgment result.

[0050] Figure 2 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown.

[0051] It should be noted that Figure 2 The computer system 200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0052] like Figure 2 As shown, the computer system 200 includes a central processing unit (CPU) 201, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 202 or a program loaded from a storage part 208 into a random access memory (RAM) 203. Various programs and data required for system operation are also stored in the RAM 203. The CPU 201, the ROM 202, and the RAM 203 are connected to each other via a bus 204. An input / output (I / O) interface 205 is also connected to the bus 204.

[0053] The following components are connected to the I / O interface 205: an input section 206 including a keyboard, a mouse, etc.; an output section 207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 208 including a hard disk, etc.; and a communication section 209 including a network interface card such as a LAN card, a modem, etc. The communication section 209 performs communication processing via a network such as the Internet. A drive 210 is also connected to the I / O interface 205 as needed. A removable medium 211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 210 as needed, so that a computer program read therefrom is installed into the storage section 208 as needed.

[0054] As a shared boundary between systems or between systems and people, interfaces can provide grammatical interoperability support by setting standard specifications, thereby reducing the coupling between interactive applications and increasing the flexibility of task processing.

[0055] However, if another task calls the same interface method during the execution of a task, it will cause problems such as data inconsistency. Alternatively, frequent calls in a short period of time will also cause problems such as system unavailability.

[0056] In order to solve this problem, the inventor tentatively proposed the following three methods:

[0057] The first method is to check the database status based on specific business fields. That is, when a call request is received, the current database status is checked based on the corresponding field, thereby achieving the effect of preventing duplicates and concurrency. However, this method cannot completely prevent duplicates and has problems such as low efficiency.

[0058] The second method is to set a unique index and use the unique constraint to achieve the above-mentioned purpose of anti-replay concurrency. Although this method can achieve complete anti-duplicate, it is strongly dependent on the database unique index. Therefore, this method can only be used when the interface is an insert operation and a unique index field can be selected. However, most actual scenarios cannot meet this requirement, so the universality of this method is poor.

[0059] The third method is to achieve the purpose of anti-replay concurrency by setting distributed locks. However, this method requires frequent locking and unlocking. At the same time, after an exception occurs, since the lock is not released, it can only rely on the cache expiration time, which brings a lot of uncertainty.

[0060] At the same time, among the above three methods, for query interfaces, if the instantaneous calls are too frequent, the system may become unavailable.

[0061] In order to solve the problems existing in the above method, in this exemplary embodiment, the inventor proposes a new technical solution, and the technical solution of the embodiment of the present disclosure is described in detail below:

[0062] This example implementation first provides an interface calling method, such as Figure 3 As shown, the specific steps include:

[0063] Step S310: receiving an interface call request, and obtaining a method entry corresponding to the method to be called according to the interface call request;

[0064] Step S320: When the method includes an anti-duplicate annotation, entering the section layer processing according to the anti-duplicate annotation;

[0065] Step S330: Obtain the logical judgment result obtained through processing, and enter the method entry to call the method according to the logical judgment result.

[0066] In the interface calling method provided in the public example implementation, on the one hand, by defining anti-duplicate annotations in the method, the problem of data inconsistency in the system caused by repeated calls to the interface can be improved. On the other hand, the above-mentioned aspect layer processing can control the time window of the interface call by defining notifications, thereby preventing concurrent operations on the interface, and can also solve the problem of system unavailability caused by instantaneous frequent calls. In addition, the aspect layer processing method can decouple anti-duplicate judgment and task processing, and there is no need to perform separate logical judgments in the methods corresponding to each task, which improves the flexibility of the system and saves system resources.

[0067] Next, in another embodiment, the above steps are described in more detail.

[0068] In step S310, an interface calling request is received, and a method entry corresponding to a method to be called is obtained according to the interface calling request.

[0069] In this example implementation, the interface call request is a request sent by the requesting end to call a method for processing a task. After receiving the interface call request, the receiving end can determine the method entry corresponding to the method to be called by the requesting end based on the request. For example, the interface call request can be a call request for a method such as data query, insertion or modification sent by a user through a terminal device, etc., or it can be a call request for a business method such as order placement, return order, payment or refund sent by an e-commerce platform, or it can be a request to call a method for performing any other operation that meets the above definition, all of which fall within the protection scope of this example implementation.

[0070] The above interface call request may include the method name of the method to be called, and the implementation of obtaining the method entry corresponding to the method to be called according to the interface call request may be as follows: obtaining the method name of the method to be called contained in the above interface call request, and obtaining the method entry corresponding to the method to be called according to the method name. The method corresponds to the operation or processing to be performed, for example, it can be a method for implementing operations such as querying, modifying and inserting data, or it can be a method for performing certain business processing, and this example implementation does not specifically limit this.

[0071] Preferably, the above interface call request may also include the time of the request call, the identifier of the requesting end, the signature verification string and the encrypted task data, as shown in Table 1, defining a request object Request:

[0072] Table 1:

[0073]

[0074] In the above Table 1, the RequestMethod field is the method name, which is used to indicate the interface method to be called. When the above interface call request arrives, the request can be forwarded to the corresponding task processing method through this field.

[0075] The requestTime field is a time identifier, which is used to record the request time of the above interface call request. For example, the format of this field can be "2020-03-22 10:10:20", or other formats that can identify time, which is not specifically limited in this example implementation.

[0076] The requestClient field is used to identify the requesting end that issues the above-mentioned interface call request. For example, the requesting end may be a user terminal device, and the corresponding identifier may be A; the requesting end may also be a certain service platform, and the corresponding identifier may be YW. In addition, the requesting end may also be any other device that issues a call request. In addition to letters, the identifier of the requesting end may also be numbers, special characters, or any combination of letters, numbers, and special characters, or other sequences that can serve as identification. This example implementation does not specifically limit this.

[0077] In addition, in this example implementation, in order to ensure communication security, technical means such as signature verification and encryption and decryption can also be provided to support identity authentication and data encryption in the method call process, which is of great significance in the processing of tasks involving personal privacy and property transactions that have high security requirements. As shown in Table 1, this can be achieved by setting the signature verification field requestSign in the above-mentioned interface call request, which is used for signature verification between the requester and the service provider. The signature verification rule, for example, can be set as follows: the requester and the service provider first agree on a signature key, for example, the key can be md5Key, extract the three parameters of the above-mentioned RequestMethod field, requestTime field and requestClient field in the interface call request, and use the signature key and the obtained parameters to calculate the signature field requestSign through the following formula:

[0078] MD5(requestMethod+requestTime+requestClient+md5Key)

[0079] It should be noted that the above-mentioned signature adopts the MD5 signature method, but the use of other signature methods to generate the above-mentioned signature verification field also falls within the protection scope of this example implementation. Preferably, in this example implementation, as shown in Table 1, the task data can also be encrypted to generate the enCodeRequestData field, which stores the encrypted task data to prevent important information from being intercepted by illegal elements. The encryption process can use the DES symmetric encryption algorithm. The requester and the service provider pre-agree on an encryption key and use the encryption key to encrypt the task data. It should be noted that the encryption process can also adopt other encryption methods, and this example implementation does not specifically limit this.

[0080] In this example implementation, the task data RequestData before encryption in Table 1 may include a task identification field Rfid and a service-related data field Data, as shown in Table 2:

[0081] Table 2

[0082]

[0083] Among them, the Rfld field is used to uniquely identify the task to be processed. For example, if the above-mentioned request end is an e-commerce platform, the tasks processed are mostly order businesses. The unique identifier of the task can be the unique identifier of the corresponding database record such as the order number or the return order number. Through this field, a group of interfaces can be mapped to a business dimension, such as the order payment interface and the order ticketing interface can all correspond to the order dimension, and the return ticket review interface and the refund completion interface all correspond to the return ticket dimension. It should be noted that the above scenario is only an exemplary description, and the protection scope of this example implementation is not limited to this. In addition, the above-mentioned task data also includes a Data field, which is used to store other data related to the task, which needs to be set according to the specific task to be processed.

[0084] In this example implementation, preferably, before forwarding the interface call request to the corresponding method, an interface response Response may be defined for the state of receiving the interface call request, as shown in Table 3. After receiving the call request, feedback on whether the response is successful or not is obtained according to the fields in Table 3:

[0085] Table 3:

[0086]

[0087] For example, in the interface calling method provided in the present example implementation, after receiving the above-mentioned calling request, first, the identity of the requesting end is authenticated according to the above-mentioned signature verification field. When the authentication is passed, the corresponding decryption key is obtained according to the preset encryption algorithm, and the task data is decrypted using the decryption key to obtain the plain text corresponding to the task data. Finally, the corresponding processing method can be called according to the task label and other task data. In this process, if the signature verification, decryption and calling processes are all successfully performed, an interface response Response is returned, the resultCode field is 0, and the resultMsg field is "success". On the contrary, if any link fails, an interface response Response is returned in the corresponding link, the resultCode field is an integer other than 0, and the resultMsg field is "error".

[0088] It should be noted that the above scenario is only an exemplary description, and the protection scope of this example implementation is not limited thereto.

[0089] In step S320, when the method includes an anti-duplicate annotation, the section layer processing is entered according to the anti-duplicate annotation.

[0090] In this example implementation, the anti-duplicate annotation acts on the method to be called by the above interface call request. After obtaining the method entry corresponding to the method to be called according to the interface call request, before calling the method to perform the corresponding task processing, it is first necessary to determine whether it is necessary to enter the aspect layer for processing according to the anti-duplicate annotation. The implementation of this process can be as follows: determine whether the method contains the anti-duplicate annotation; if it contains the anti-duplicate annotation, it is necessary to perform the corresponding aspect layer processing according to the anti-duplicate annotation. On the contrary, if it does not contain the anti-duplicate annotation, the method is directly called to perform the corresponding task processing.

[0091] The above-mentioned task processing process can be divided into two parts, core concerns and cross-cutting concerns, according to different concerns. The core concerns focus on the modules corresponding to the main process of task processing, while the cross-cutting concerns focus on the logic or responsibility that has little to do with the main process of task processing but is commonly called by the above-mentioned modules. For example, for the logging function, the logging code is often horizontally scattered in all object levels and has nothing to do with the core function of the object to which it corresponds. This is also true for other types of code, such as security, exception handling, and transparent persistence. This irrelevant code scattered everywhere is the object of cross-cutting concerns. In addition, the cross-cutting concern can be other defined codes such as permission authentication and transactions, and this example implementation method does not make special limitations on this.

[0092] Aspects are obtained by dissecting the encapsulated objects based on the "crosscutting" technology and encapsulating the common behaviors that affect multiple classes into a reusable module. By defining the aspect layer, the logic or responsibility that is not related to the task but is commonly called by the task module can be encapsulated, which can reduce the system's duplicate code, reduce the coupling between modules, and facilitate future operation and maintenance of the system.

[0093] After defining the aspect layer, you can also process the aspect by defining notifications in the aspect layer. The implementation of the above aspect layer processing process can be as follows: the intercepted method is processed according to the predefined notification. The notification can be a pre-notification, an around notification, a post-notification or an exception notification, and this example implementation does not specifically limit this. Among them, the pre-notification is performed before the method is executed, the post-notification performs a predefined operation on the method after it ends, the time point of the around notification can be any time during the method execution, and the exception notification is an operation added at the point where the method executes abnormally.

[0094] In this example implementation, in order to prevent data inconsistency and system crash and unavailability caused by repeated and frequent calls, the time interval for sending interface call requests can be controlled by defining notifications in the above-mentioned aspect layer. The above-mentioned execution of the corresponding aspect layer processing according to the anti-duplicate annotation is to execute the pre-defined notification according to the anti-duplicate annotation. The implementation of this process can be: obtaining attribute values ​​based on the above-mentioned anti-duplicate annotation, and executing notifications according to the obtained attribute values, wherein the attribute values ​​include the method identifier, method group identifier and time window of the method to be called, as shown in Table 4:

[0095] Table 4:

[0096]

[0097] Among them, lockTimeSplit is the time window allowed between the first interface call request and the second interface call request. For example, the time window can be defined as 1000, where 1000 corresponds to 1 second. methodMark is the method mark corresponding to the task processing required for the interface call request, such as the method mark corresponding to the business requirement of completing order payment. methodGroup is the method group mark to which the called method belongs. For example, the same group to which the required business processing methods belong, such as order payment, and order ticketing can be identified as a group at the same time. lockKeyTimeOut is the expiration time of the cache, which prevents too much cache from requesting too much space, thereby improving space utilization and saving system resources. It should be noted that the above scenario is only an exemplary description, and the protection scope of this example implementation is not limited to this.

[0098] In this example implementation, the above notification can be a pre-notification, and a logical judgment result is obtained according to the above time window before executing the task processing. In this process, it is also necessary to define a key lockKey, which is used to prevent duplication and concurrency during the interface call process. The naming rule of the key name key of this key is methodMark+methodGroup+rfId. The key value lockValue is the current time+lockTimeSplit. Preferably, the key variable can be stored in a distributed cache system, so that no matter which machine the interface call hits, lockValue can be obtained for judgment. It should be noted that the above scenario is only an exemplary description, and the protection scope of this example implementation is not limited to this.

[0099] In summary, in a specific embodiment of the present example implementation, when the called method contains an anti-duplicate annotation, the implementation of the corresponding aspect layer processing according to the anti-duplicate annotation can be as follows: when the above method contains an anti-duplicate annotation, obtain the attribute value defined in the anti-duplicate annotation, and assemble the above lockKey according to the obtained attribute value: methodMark+methodGroup+rfId; determine whether the assembled key lockKey exists in the above distributed cache system, if not, insert the key lockKey, and set lockValue to the current time+lockTimeSplit; if it exists, compare the corresponding key value lockValue with the time of this interface call request to obtain a logical judgment result. It should be noted that the above scenario is only an exemplary description, and the protection scope of the present example implementation is not limited to this.

[0100] In step S330, the logic judgment result obtained by processing is obtained, and the method entry is entered to call the method according to the logic judgment result.

[0101] In this example implementation method, after a logical judgment result is obtained through the process of step S320, the method corresponding to the method interface call is entered according to the logical judgment result. For example, it can be as follows: when the request time of this interface call request is greater than or equal to the above key value lockValue, call the corresponding method and update the key value lockValue to the current time of this call + lockTimeSplit; when the above logical judgment result is that the request time of this interface call request is less than the above key value lockValue, it proves that this interface call request falls within the time window, and directly returns a response of interface call failure. It should be noted that the above scenario is only an exemplary description, and the protection scope of this example implementation is not limited to this.

[0102] In a specific embodiment of this exemplary implementation, preferably, the above interface calling method can be used for business processing of an e-commerce platform to perform the overall process of the business processing, such as Figure 4 As shown, the following steps may be included:

[0103] Step S410: receiving an interface call request.

[0104] In this step, an interface call request requestMethod is received, which includes the method name requestMethod, the time requestTime, the request end identifier requestClient, the signature string requestSign and the encrypted business data enCodeRequestData, wherein the business data includes the business unique identifier rfId and other related business data data.

[0105] Step S420: Authenticate the requesting end.

[0106] In this step, the requesting end that initiates the call request, that is, the e-commerce platform client, is authenticated according to the signature verification field in the above interface call request. If the authentication succeeds, proceed to step S430; if the authentication fails, jump to step S491.

[0107] Step S430: decrypt the encrypted business data.

[0108] In this step, after the identity authentication of the requesting end is used, the encrypted business data is decrypted using the pre-agreed key to obtain the business object.

[0109] Step S440: forward the interface call request to the corresponding method.

[0110] In this step, the corresponding business processing method is then found according to the requestMethod field in the above interface call request, and the interface call request is forwarded to the corresponding method.

[0111] Step S450: Determine whether the method contains anti-duplicate annotations.

[0112] In the interface calling method provided in this example implementation, anti-duplicate annotations are added to the business methods that have the logic or responsibility of common calls and the corresponding attribute values ​​are set. The attributes may include the time window lockTimeSplit, the method mark methodMark, the method group mark groupMethd, and the cache expiration time lockKeyTimeOut. In this specific application scenario, the attribute value can be set to "lockTimeSplit = 3000, methodMark = doBusiness, groupMethd = pay, lockKeyTimeOut = 10000", where the time window 1000 represents 1 second, and 3000 means that the time window is 3 seconds. Based on the above parameters, a key lockKey must be defined for anti-duplicate and anti-concurrency during the interface call process. The naming rule of the key name key of this key is methodMark+methodGroup+rfId. The key value lockValue is the current time + lockTimeSplit.

[0113] In this step, after forwarding the interface call request to the corresponding method, it is determined whether the method contains the above-mentioned anti-duplicate annotation. If the judgment result is that the method contains the anti-duplicate annotation, it proceeds to step S460; otherwise, if the method does not contain the anti-duplicate annotation, it directly jumps to step S490 to enter the business processing.

[0114] Step S460: Enter the section to perform anti-duplication processing.

[0115] In this step, the attributes lockTimeSplit, method mark methodMark, method group mark groupMethd defined in the above anti-duplicate annotation are obtained, and the business unique mark rfId in the interface call request is obtained, and the corresponding key lockKey key name methodMark+methodGroup+rfId is assembled.

[0116] Step S470: Determine whether lockKey exists in the system.

[0117] In this step, after obtaining the key name of the key lockKey, the key lockKey is searched and determined in the distributed storage system. If the key exists, the process proceeds to step S471; if not, the process jumps to step S472.

[0118] Step S471: Take out the value lockValue existing in lockKey.

[0119] In this step, after the key lockKey is found in the above-mentioned distributed storage system, the key value lockValue stored therein is retrieved, and the process proceeds to step S480.

[0120] Step S472: Set the value of lockKey lockValue to the current time + lockTimeSplit.

[0121] In this step, when the key value does not exist, the value of lockKey lockValue is set to the time of the current interface call request plus the time window, which is used to subsequently determine whether the time interval between the next interface call request and this request exceeds the preset time window, and enter step S490 after the setting is completed.

[0122] Step S480: Determine whether the current time is less than lockKey.

[0123] In this step, it is determined whether the current time is less than lockKey. If the result is less than lockKey, it proves that the current interface call request is within the time window of the last call request. In order to prevent frequent calls from causing system unavailability and data inconsistency, the process proceeds to step S491 and returns a request failure. Otherwise, it proves that the time window has passed since the last call, and the process jumps to step S490 to enter business processing.

[0124] Step S490: Enter business processing.

[0125] Step S491: Return request failure.

[0126] Furthermore, this exemplary embodiment provides an interface calling device. Figure 5 As shown, the interface calling device 500 may include a receiving module 510, a processing module 520 and a calling module 530. Among them:

[0127] The receiving module 510 may be used to receive an interface call request, and obtain a method entry corresponding to a method to be called according to the interface call request;

[0128] The processing module 520 may be used to enter the section layer processing according to the anti-duplicate annotation when the method includes the anti-duplicate annotation;

[0129] The calling module 530 can be used to obtain the processed logical judgment result, and enter the method entry to call the method according to the logical judgment result.

[0130] In this example implementation, the interface calling device may further include a signature verification unit and a decryption unit, wherein the signature verification unit is used to authenticate the requesting end of the calling method, and the decryption unit is used to decrypt the encrypted task data. The specific signature verification and decryption process has been described in detail in the corresponding steps of the interface calling method, so it will not be repeated here.

[0131] In addition, the above-mentioned receiving module may also include an acquisition unit, which is used to determine the method entry corresponding to the method to be called according to the received interface call request after receiving the interface call request, and its implementation may be: receiving the interface call request, and obtaining the method name corresponding to the method to be called contained in the interface call request; and obtaining the corresponding method entry according to the method name. It should be noted that the above-mentioned scenario is only an exemplary description, and the protection scope of this example implementation is not limited to this.

[0132] In this example implementation, the processing module includes a section layer processing unit, which encapsulates the common behaviors of each method in the task processing process and abstracts them into a section class. The section layer processing unit is mainly used to process the encapsulated common behaviors in the section layer. The implementation can be: when the called method contains an anti-duplicate annotation, the corresponding notification is executed according to the anti-duplicate annotation, where the notification can be a pre-notification, a surround notification, a post-notification or an exception notification. Specifically, the attribute value can be obtained based on the anti-duplicate annotation, and the notification defined above can be executed according to the attribute value, where the attribute value includes the method identifier, the method group identifier and the time window of the method, and the time window is the time interval allowed between two interface call requests.

[0133] The processing module may also include a logic judgment unit for obtaining the time window, judging whether the time difference between the current interface call request and the previous one is greater than or equal to the time window, and obtaining a logic judgment result accordingly. It should be noted that the above scenario is only an exemplary description, and the protection scope of this example implementation is not limited to this.

[0134] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0135] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiment. For example, the electronic device may implement Figure 3-4 The various steps shown, etc.

[0136] It should be noted that the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0137] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. An interface calling method, characterized in that: include: Receive an interface call request, and obtain a method entry corresponding to a method to be called according to the interface call request; The interface call request includes a signature verification string and encrypted task data; After receiving the interface call request, the method further includes: Obtain the signature verification string and perform a signature verification operation using the corresponding signature verification key; When the signature verification succeeds, the encrypted task data is decrypted to obtain the task data; When the method contains an anti-duplicate annotation, the section layer processing is entered according to the anti-duplicate annotation; the section layer processing is used to: determine whether the time difference between the current interface call request and the previous one is greater than or equal to the time window; the time window is the time interval allowed between two interface call requests; obtain the logical judgment result obtained by the processing, when the logical judgment result is yes, enter the method entry to call the method; when the logical judgment result is no, determine that the interface call request has failed; The attribute values ​​defined in the anti-duplicate annotation include the method identifier, the method group identifier and the time window of the method.

2. The interface calling method according to claim 1, characterized in that: The interface call request includes the method name of the method; the receiving the interface call request and obtaining the method entry corresponding to the method to be called according to the interface call request includes: Receive the interface call request, and obtain the method name of the method in the interface call request; Obtain the method entry corresponding to the method according to the method name.

3. The interface calling method according to claim 2, characterized in that: When the method includes an anti-duplicate annotation, entering the section layer processing according to the anti-duplicate annotation includes: When the method includes an anti-duplicate annotation, a corresponding notification is executed according to the anti-duplicate annotation, wherein the notification is a pre-notification, a surround notification, a post-notification or an exception notification.

4. The interface calling method according to claim 3, characterized in that: The corresponding notification is executed according to the anti-duplicate annotation, including: An attribute value is obtained based on the anti-duplicate annotation, and the notification is executed according to the attribute value.

5. The interface calling method according to claim 4, characterized in that: The notification is a pre-notification; and executing the notification according to the attribute value includes: The time window is obtained, and it is determined whether the time difference between the current request time of the interface call request and the previous request time is greater than or equal to the time window, and a logic determination result is obtained.

6. An interface calling device, characterized in that: include: A receiving module, used to receive an interface call request, and obtain a method entry corresponding to a method to be called according to the interface call request; The interface call request includes a signature verification string and encrypted task data; after receiving the interface call request, the receiving module is further used to: Obtain the signature verification string and perform a signature verification operation using the corresponding signature verification key; When the signature verification succeeds, the encrypted task data is decrypted to obtain the task data; A processing module, used for entering aspect layer processing according to the anti-duplicate annotation when the method contains an anti-duplicate annotation; the aspect layer processing is used for: judging whether the time difference between the current interface call request and the previous one is greater than or equal to a time window; the time window is the time interval allowed between two interface call requests; wherein the attribute value defined in the anti-duplicate annotation includes the method identifier, method group identifier and the time window of the method; The calling module is used to obtain the logical judgment result obtained by processing, and when the logical judgment result is yes, enter the method entry to call the method; when the logical judgment result is no, determine that the interface call request fails.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

8. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 5 by executing the executable instructions.

Citation Information

Patent Citations

  • Background request retransmission prevention method and device, computer device and storage medium

    CN110502527A