Transaction processing method and device based on mutual exclusion semaphore, and electronic equipment
By using mutex semaphores in the transaction processing system to control the processing order of transaction requests, the problem of inaccurate transaction processing time is solved and more efficient transaction processing is achieved.
Patent Information
- Application Number
- CN202411544798.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, the time for processing transactions cannot be accurately determined, resulting in low efficiency of transaction processing.
By receiving the target transaction request sent by the target terminal, the mutually exclusive semaphore is obtained based on the target transaction identification and product identification, the target data is determined, and the mutually exclusive semaphore is released after the transaction processing is completed.
Improve the accuracy of determining transaction processing time, reduce invalid waiting time, and improve business efficiency.
Smart Images

Figure CN119473642A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology, and in particular to a transaction processing method based on mutually exclusive semaphores, a device thereof, and an electronic device. Background Art
[0002] During the transaction process, if multiple transactions attempt to access and modify the same data resource at the same time, data inconsistency or transaction failure (i.e. mutually exclusive transactions) may occur. For example, in the end-of-day batch processing transactions and repayment transactions, in the repayment transaction, the minimum calculation unit is the day to calculate the cost of using funds (i.e. interest). The interest can be collected on the repayment day of each fixed period to calculate the interest payable for the current period. If the product supports early settlement of loans, customers can choose to return the remaining funds on any day including the repayment day. At this time, the system needs to provide a trial calculation method for early settlement so that customers can clearly know the total amount of funds that actually need to be returned on that day. However, in the online transaction mode, due to the huge daily transaction volume, the system interest accrual and related data processing (i.e. end-of-day batch processing transactions) cannot be completed instantly. At this time, if the customer makes an early repayment, the amount calculated by the system may have a deviation of 1 day's interest. Therefore, in order to prevent customers from making repayment transactions on non-repayment days, a repayment restriction function is added to the client to prevent customers from initiating repayment requests within a specific time. This repayment restriction time is called the repayment dark period.
[0003] Since the repayment dark period controls the permission and interception of transactions through time periods, its main function is to prevent repayment transactions from occurring during the time period when the system performs day-end batch processing. The setting of this time period should cover the entire day-end batch interval in which the calculation of interest accrual and other data from the previous day is completed (i.e., repayment transactions are closed from the beginning of the day-end batch to the end of the day-end batch).
[0004] In the related art, there are two methods for setting a dark period: (1) setting the end-of-day batch end time of the product that consumes the most time in data processing as the end time of the dark period, setting and performing transaction control at the front end to ensure the accuracy of repayment transactions for all products. However, as the number of products increases, the difference in data magnitude between products increases. This method will lead to poor customer experience and transaction backlogs, and will cause customer complaints, making the product lose competitiveness; (2) setting an independent dark period for each product to ensure the accuracy of repayment transactions while sacrificing the least transaction time. This method has a high maintenance cost (i.e., each product needs to continuously adjust the dark period time according to the dynamic changes in transaction volume), and the manually set date is inaccurate, resulting in a waste of time.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiment of the present invention provides a transaction processing method based on mutually exclusive semaphores, a device thereof, and an electronic device, so as to at least solve the technical problem in the related art that the time for processing a transaction cannot be accurately determined, resulting in low efficiency of transaction processing.
[0007] According to one aspect of an embodiment of the present invention, a transaction processing method based on a mutex semaphore is provided, comprising: receiving a target transaction request sent by a target terminal, wherein the target transaction request carries at least a target transaction identifier and a target transaction product identifier; obtaining a mutex semaphore based on the target transaction identifier and the target transaction product identifier, wherein the mutex semaphore is used to control the processing order of different transaction requests; determining target data based on the target transaction identifier and the target transaction product identifier, wherein the target data is transaction data required for the target transaction indicated by the target transaction identifier; processing the target transaction based on the target data, and releasing the mutex semaphore when it is detected that the processing of the target transaction is completed.
[0008] Furthermore, before receiving the target transaction request sent by the target terminal, it includes: determining the priority level of transactions corresponding to each transaction type based on the business requirements of different transaction types, and obtaining a transaction priority file; and constructing a preset nested dictionary library based on the transaction product identifier, transaction identifier and transaction data corresponding to each transaction.
[0009] Furthermore, before receiving the target transaction request sent by the target terminal, it also includes: in the case of receiving multiple transaction requests initiated by multiple user terminals at the same time, determining the priority level of each transaction request based on the transaction priority file; characterizing the transaction request indicated by the highest priority level as the target transaction request, and in the case of the target transaction request being processed, selecting the transaction request indicated by the next priority level as the target transaction request, wherein the next priority level refers to the highest priority level except the highest priority level.
[0010] Furthermore, before receiving the target transaction request sent by the target terminal, it also includes: constructing the mutex semaphore; based on the mutex semaphore, encapsulating a preset acquisition function, and representing the input parameters of the preset acquisition function as a first transmission parameter, wherein the first transmission parameter at least includes: a transaction product identifier and a transaction identifier; based on the mutex semaphore, encapsulating a preset release function, and representing the input parameters of the preset release function as a second transmission parameter, wherein the second transmission parameter at least includes: a transaction product identifier and a transaction identifier.
[0011] Furthermore, the step of acquiring a mutex semaphore based on the target transaction identifier and the target transaction product identifier includes: calling the preset acquisition function, and passing the target transaction identifier and the target transaction product identifier into the preset acquisition function to acquire the mutex semaphore; if the mutex semaphore is not successfully acquired, calling the preset acquisition function based on a preset time interval until the mutex semaphore is successfully acquired.
[0012] Furthermore, based on the target transaction identifier and the target transaction product identifier, the step of determining the target data includes: based on the preset nested dictionary library, querying the transaction data corresponding to the target transaction product identifier and the target transaction identifier to obtain the target transaction data; and characterizing the target transaction data as the target data.
[0013] Furthermore, when it is detected that the target transaction processing is completed, the step of releasing the mutex semaphore includes: when it is detected that the target transaction processing is completed, calling the preset release function; passing the target transaction identifier and the target transaction product identifier into the preset release function to release the mutex semaphore.
[0014] Furthermore, the transaction processing method also includes: in the case of receiving a transaction data update request, calling the preset acquisition function, and acquiring the mutex semaphore through the preset acquisition function, wherein the transaction data update request carries a transaction data identifier; in the case of successfully acquiring the mutex semaphore, updating the transaction data indicated by the transaction data identifier; in the case of completing the transaction data update, calling the preset release function, and releasing the mutex semaphore through the preset release function.
[0015] According to another aspect of an embodiment of the present invention, a transaction processing device based on a mutex semaphore is also provided, comprising: a receiving unit, configured to receive a target transaction request sent by a target terminal, wherein the target transaction request carries at least a target transaction identifier and a target transaction product identifier; an acquiring unit, configured to acquire a mutex semaphore based on the target transaction identifier and the target transaction product identifier, wherein the mutex semaphore is used to control the processing order of different transaction requests; a determining unit, configured to determine target data based on the target transaction identifier and the target transaction product identifier, wherein the target data is transaction data required for the target transaction indicated by the target transaction identifier; and a releasing unit, configured to process the target transaction based on the target data, and release the mutex semaphore when it is detected that the processing of the target transaction is completed.
[0016] Furthermore, the transaction processing device includes: a first determination module, which is used to determine the priority level of transactions corresponding to each transaction type based on business requirements of different transaction types before receiving the target transaction request sent by the target terminal, and obtain a transaction priority file; a first construction module, which is used to construct a preset nested dictionary library based on the transaction product identifier, transaction identifier and transaction data corresponding to each transaction.
[0017] Furthermore, the transaction processing device also includes: a second determination module, used to determine the priority level of each transaction request based on the transaction priority file before receiving the target transaction request sent by the target terminal, when multiple transaction requests initiated simultaneously by multiple user terminals are received; a first processing module, used to characterize the transaction request indicated by the highest priority level as the target transaction request, and when the processing of the target transaction request is completed, select the transaction request indicated by the next priority level as the target transaction request, wherein the next priority level refers to the highest priority level except the highest priority level.
[0018] Furthermore, the transaction processing device also includes: a second construction module, used to construct the mutex semaphore before receiving the target transaction request sent by the target terminal; a first encapsulation module, used to encapsulate a preset acquisition function based on the mutex semaphore, and represent the input parameters of the preset acquisition function as a first transmission parameter, wherein the first transmission parameter at least includes: a transaction product identifier and a transaction identifier; a second encapsulation module, used to encapsulate a preset release function based on the mutex semaphore, and represent the input parameters of the preset release function as a second transmission parameter, wherein the second transmission parameter at least includes: a transaction product identifier and a transaction identifier.
[0019] Furthermore, the acquisition unit includes: a first acquisition module, used to call the preset acquisition function, and pass the target transaction identifier and the target transaction product identifier into the preset acquisition function to obtain the mutex semaphore; a first calling module, used to call the preset acquisition function based on a preset time interval until the mutex semaphore is successfully acquired if the mutex semaphore is not successfully acquired.
[0020] Furthermore, the determination unit includes: a first query module, used to query the transaction data corresponding to the target transaction product identifier and the target transaction identifier based on the preset nested dictionary library to obtain target transaction data; a first characterization module, used to characterize the target transaction data as the target data.
[0021] Furthermore, the release unit includes: a second calling module, used to call the preset release function when it is detected that the target transaction processing is completed; a first releasing module, used to pass the target transaction identifier and the target transaction product identifier into the preset release function to release the mutex semaphore.
[0022] Furthermore, the transaction processing device also includes: a second acquisition module, which is used to call the preset acquisition function when a transaction data update request is received, and obtain the mutex semaphore through the preset acquisition function, wherein the transaction data update request carries a transaction data identifier; a first update module, which is used to update the transaction data indicated by the transaction data identifier when the mutex semaphore is successfully acquired; and a second release module, which is used to call the preset release function when the transaction data update is completed, and release the mutex semaphore through the preset release function.
[0023] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned transaction processing methods based on mutex semaphores.
[0024] In the present invention, the financial institution system receives a target transaction request sent by a target terminal, obtains a mutex semaphore based on a target transaction identifier and a target transaction product identifier, determines target data based on the target transaction identifier and the target transaction product identifier, processes the target transaction based on the target data, and releases the mutex semaphore when it is detected that the target transaction processing is completed, thereby solving the technical problem in the related art that the time for processing a transaction cannot be accurately determined, resulting in low efficiency in transaction processing.
[0025] In the present invention, the financial institution system can obtain a mutex semaphore through the target transaction identifier and the target transaction product identifier carried by the target transaction request sent by the target terminal. At this time, other transactions are in a waiting state. After obtaining the mutex semaphore, the target data required for the target transaction can be determined according to the target transaction identifier and the target transaction product identifier, and the business logic of the target transaction can be processed according to the target data. When the business logic processing of the target transaction is completed, the mutex semaphore is released, which improves the accuracy of determining the transaction processing time and reduces invalid waiting time, thereby achieving the technical effect of improving business efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0027] Figure 1 is a flowchart of an optional transaction processing method based on a mutex semaphore according to an embodiment of the present invention;
[0028] Figure 2 is a schematic diagram of an optional transaction processing device based on a mutex semaphore according to an embodiment of the present invention;
[0029] Figure 3 The present invention is a hardware structure block diagram of an electronic device (or mobile device) for a transaction processing method based on a mutually exclusive semaphore according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) collected and involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with the relevant laws, regulations and standards of the relevant regions, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set between the system and the relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0033] In the present invention, since the financial institution system may encounter force majeure factors that cause the end-of-day batch processing time to exceed the dark period deadline, each product is required to delay the dark period end date at the front end (i.e., extend the time for sequential processing between mutually exclusive transactions) to ensure transaction accuracy. This is time-consuming and there is a risk that the dark period end time cannot be controlled. Therefore, the present invention proposes a transaction processing method based on mutually exclusive semaphores, which does not require manual maintenance, basically improves the time accuracy from hours to milliseconds, and reduces invalid waiting time.
[0034] The present invention is described in detail below in conjunction with various embodiments.
[0035] Embodiment 1
[0036] According to an embodiment of the present invention, an embodiment of a transaction processing method based on a mutex semaphore is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] Figure 1 is a flowchart of an optional transaction processing method based on a mutex semaphore according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0038] Step S101: receiving a target transaction request sent by a target terminal, wherein the target transaction request carries at least a target transaction identifier and a target transaction product identifier.
[0039] Optionally, the financial institution system can receive a target transaction request (such as a repayment transaction request) sent by a target terminal (such as a user's mobile phone), and the target transaction request carries at least a target transaction identifier (such as a repayment transaction identifier) and a target transaction product identifier (such as a repayment transaction product identifier).
[0040] In this embodiment, the target transaction identifier can be a transaction name (such as repayment trial calculation, end-of-day batch, etc.), which is used to identify the transaction type, and the target transaction product identifier can be a product name (such as product A, product B), which is used to identify the financial product type of the transaction.
[0041] In an optional embodiment, the target transaction identifier may be a string of numbers and letters (such as D101). Due to the large number of products of financial institutions, the target transaction product identifier may also be a string of numbers and letters (such as A1).
[0042] Step S102, based on the target transaction identifier and the target transaction product identifier, a mutex semaphore is obtained, wherein the mutex semaphore is used to control the processing order of different transaction requests.
[0043] Optionally, the mutex semaphore can be used to control the processing order of different transaction requests. The mutex semaphore can be obtained according to the target transaction identifier and the target transaction product identifier. For example, the initial mutex semaphore can be set to 0. After the target transaction obtains the mutex semaphore, the mutex semaphore can be controlled to be added by 1. At this time, the mutex semaphore is 1. Other transactions cannot obtain the mutex semaphore based on the transaction identifier and the transaction product identifier.
[0044] Step S103, determining target data based on the target transaction identifier and the target transaction product identifier, wherein the target data is transaction data required for the target transaction indicated by the target transaction identifier.
[0045] Optionally, different transactions and different products have corresponding transaction data (i.e. target data, such as accounting date, etc.), and the target data (i.e. transaction data required for the target transaction indicated by the target transaction identifier) can be determined based on the target transaction identifier and the target transaction product identifier.
[0046] Exemplarily, in a loan transaction, a serial number (such as a loan number, a transaction serial number, etc.) can be used as target data to ensure the uniqueness of the transaction. When a serial number needs to be generated for a loan transaction, a request can be made to obtain a mutex semaphore, and based on the transaction identifier and the transaction product identifier carried by the loan transaction request, the financial institution system can generate a serial number (i.e., target data) from the database according to certain rules.
[0047] Step S104, processing the target transaction based on the target data, and releasing the mutex semaphore when it is detected that the target transaction processing is completed.
[0048] Optionally, in a financial transaction system, the system needs to perform subsequent business logic processing on the transaction based on the target data required by the transaction request sent by the target terminal (such as calculating the customer's repayment amount based on the accounting date in a repayment transaction), and return the processed results (such as successful repayment) to the target terminal.
[0049] In this embodiment, when the target transaction processing is completed, the system needs to release the acquired mutex semaphore (such as controlling the semaphore to be reduced by 1 so that the mutex semaphore is restored to a state where it can be acquired (such as 0)) so that other transactions can acquire the semaphore and thus acquire the target data.
[0050] For example, when a customer initiates a repayment request, the financial institution system needs to process the repayment transaction. The system can obtain a semaphore and then obtain relevant target data for transaction processing. When the repayment transaction operation is completed, the system can release the mutex semaphore, allowing other customers to obtain the semaphore to perform transaction operations.
[0051] In summary, the financial institution system can receive the target transaction request sent by the target terminal, and obtain the mutex semaphore according to the target transaction identifier and the target transaction product identifier, and then determine the target data required for the target transaction according to the target transaction identifier and the target transaction product identifier. Thereafter, the target transaction is processed according to the determined target data, and the mutex semaphore is released when it is detected that the target transaction processing is completed, thereby shortening the transaction waiting time and reducing the waste of time, thereby solving the technical problem in the related technology that the time for processing the transaction cannot be accurately determined, resulting in low efficiency of transaction processing.
[0052] In order to determine the transaction priority file and construct a preset nested dictionary library, in the transaction processing method based on mutually exclusive semaphores provided in Example 1 of the present application, based on the business requirements of different transaction types, the priority level of transactions corresponding to each transaction type is determined to obtain the transaction priority file; based on the transaction product identifier, transaction identifier and transaction data corresponding to each transaction, a preset nested dictionary library is constructed.
[0053] Optionally, different transactions may generate diverse demands due to their different characteristics, scales, urgency, risk levels and impacts on customers and business. For example, in a financial institution system, the business demand for end-of-day batch transactions is greater than the business demand for repayment transactions. The priority level of transactions corresponding to each transaction type can be determined based on the business demands of different transaction types (such as the priority level of end-of-day batch transactions is greater than the priority level of repayment transactions), and a transaction priority file can be obtained, which contains the priority levels of all transactions.
[0054] In this embodiment, by constructing a preset nested dictionary library (a preset nested dictionary library for storing transaction product identifiers, transaction identifiers, and transaction data), transaction data of different transaction types can be classified and stored according to their product identifiers and transaction identifiers.
[0055] Exemplarily, the preset nested dictionary library may be expressed as follows: {'transaction identification 1 (such as D101)': {'product identification 1 (such as A1)': 'transaction data 1 (such as accounting date)'}}.
[0056] In order to accurately determine the target transaction request, it is necessary to first determine the priority level of each transaction request. In the transaction processing method based on mutually exclusive semaphores provided in the first embodiment of the present application, when multiple transaction requests initiated simultaneously by multiple user terminals are received, the priority level of each transaction request is determined based on the transaction priority file; the transaction request indicated by the highest priority level is characterized as the target transaction request, and when the target transaction request is processed, the transaction request indicated by the next priority level is selected as the target transaction request, wherein the next priority level refers to the highest priority level except the highest priority level.
[0057] Optionally, when multiple transaction requests are received simultaneously from multiple user terminals, the priority level of each transaction request is determined according to the transaction priority file (such as the priority level of a transfer transaction is greater than the priority level of a term loan issuance transaction). At this time, the financial institution system can characterize the transaction request indicated by the highest priority level (such as a transfer transaction) as the target transaction request.
[0058] In this embodiment, when the processing of the target transaction request is completed, a transaction request (such as a term loan issuance transaction) indicated by the next priority level (i.e., the highest priority level except the highest priority level) can be selected as the next target transaction request.
[0059] In order to accurately encapsulate the preset acquisition function and the preset release function, in the transaction processing method based on mutually exclusive semaphores provided in Example 1 of the present application, a mutually exclusive semaphore is constructed; based on the mutually exclusive semaphore, the preset acquisition function is encapsulated, and the input parameters of the preset acquisition function are represented as first transmission parameters, wherein the first transmission parameters at least include: a transaction product identifier and a transaction identifier; based on the mutually exclusive semaphore, the preset release function is encapsulated, and the input parameters of the preset release function are represented as second transmission parameters, wherein the second transmission parameters at least include: a transaction product identifier and a transaction identifier.
[0060] Optionally, before acquiring key resources (i.e., target data), a mutex semaphore may be constructed (e.g., the initial value of the mutex semaphore is set to 0) to control the priority order of two transactions that cannot be processed simultaneously in acquiring key resources. At this time, any transaction request may acquire the mutex semaphore. After the target transaction request acquires the mutex semaphore, the value of the mutex semaphore may be increased by 1. At this time, the value of the mutex semaphore becomes 1, and other transaction requests may not acquire the mutex semaphore. After the target transaction request releases the mutex semaphore, the value of the mutex semaphore may be decreased by 1 to restore it to the initial value of 0.
[0061] Exemplarily, before transaction A is processed, a semaphore is acquired. At this time, transaction B cannot acquire the semaphore and therefore cannot acquire the required target data. After transaction A is processed, the semaphore is released. At this time, transaction B can acquire the semaphore and thereby acquire the required target data. This can achieve the purpose of dynamically and accurately connecting the time taken by transaction A and the time allowed for processing by transaction B (i.e., ensuring that after transaction A completes the required processing time, transaction B can start processing based on the end time of transaction A).
[0062] In this embodiment, a preset acquisition function (i.e., a preset function for acquiring a mutex semaphore and target data) can be encapsulated based on a mutex semaphore, and the input parameters of the preset acquisition function (such as a transaction product identifier and a transaction identifier) can be represented as a first transmission parameter; a preset release function (i.e., a preset function for releasing a mutex semaphore and target data) can be encapsulated, and the input parameters of the preset release function (such as a transaction product identifier and a transaction identifier) can be represented as a second transmission parameter.
[0063] In order to successfully acquire a mutex semaphore, in the transaction processing method based on a mutex semaphore provided in Example 1 of the present application, a preset acquisition function is called, and the target transaction identifier and the target transaction product identifier are passed into the preset acquisition function to acquire the mutex semaphore; if the mutex semaphore is not successfully acquired, the preset acquisition function is called based on a preset time interval until the mutex semaphore is successfully acquired.
[0064] Optionally, the mutex semaphore can be acquired by calling a preset acquisition function and passing the target transaction identifier and the target transaction product identifier into the preset acquisition function. If the mutex semaphore is not successfully acquired (i.e., the mutex semaphore has been acquired by other transactions but has not been released), the preset acquisition function can be called continuously at a preset time interval (i.e., a very short time interval set in advance, such as 0.01s) to query whether the mutex semaphore is released (i.e., query whether the value of the mutex semaphore becomes 0) until the mutex semaphore is successfully acquired. At this time, the mutex semaphore is increased by 1 and becomes 1, and other transactions cannot acquire the mutex semaphore.
[0065] In an optional embodiment, since both the end-of-day batch transactions and the repayment trial settlement transactions need to obtain the accounting date (i.e., target data) before processing, for example, the priority of the end-of-day batch transactions is higher than that of the repayment trial settlement transactions. At this time, the end-of-day batch transactions obtain the semaphore, and at the same time, the repayment trial settlement transaction can call the accounting date acquisition method (i.e., the preset acquisition function), pass in the repayment trial settlement (i.e., target transaction identifier) parameter and the product code (i.e., target transaction product identifier) parameter, and continuously call the preset acquisition function at preset time intervals to query whether the mutex semaphore is released. After the end-of-day batch transactions release the mutex semaphore, the repayment trial settlement transaction can successfully obtain the mutex semaphore for subsequent transaction processing.
[0066] In order to accurately obtain the target data, in the transaction processing method based on mutually exclusive semaphores provided in Example 1 of the present application, based on a preset nested dictionary library, the transaction data corresponding to the target transaction product identifier and the target transaction identifier are queried to obtain the target transaction data; the target transaction data is represented as the target data.
[0067] Optionally, when calling the preset acquisition function, the target transaction identification parameter and the target transaction product identification parameter need to be passed in, and the transaction data (ie, target data) corresponding to the target transaction identification and the target transaction product identification can be queried in the preset nested dictionary library.
[0068] In this embodiment, different target transaction identifiers and target transaction product identifiers have different target data, and the relationship between them is one-to-one corresponding.
[0069] It should be noted that transactions of the same type as the target transaction (ie, transactions of the same transaction type, same transaction product type, but with different customers) can share the target data of the target transaction.
[0070] In order to accurately release the mutex semaphore, in the transaction processing method based on the mutex semaphore provided in the first embodiment of the present application, when it is detected that the target transaction processing is completed, the preset release function is called; the target transaction identifier and the target transaction product identifier are passed into the preset release function to release the mutex semaphore.
[0071] Optionally, after acquiring the target data, the business logic of the target transaction can be processed according to the target data to complete the processing of the target transaction. When it is detected that the target transaction processing is completed, the preset release function can be called, and the target transaction identifier and the target transaction product identifier are passed into the preset release function to release the mutex semaphore. At this time, the mutex semaphore is reduced by 1 and becomes 0, which can be acquired by other transaction requests.
[0072] Exemplarily, after the end-of-day batch transaction is processed, the preset release function (such as the accounting date release method) can be called, and the end-of-day batch transaction identifier and the end-of-day batch transaction product identifier are passed in. At this time, the end-of-day batch transaction releases the semaphore, and the repayment trial transaction can obtain the accounting date of the product.
[0073] In order to improve the accuracy of updating transaction data, in the transaction processing method based on mutex semaphore provided in Example 1 of the present application, when a transaction data update request is received, a preset acquisition function is called, and the mutex semaphore is acquired through the preset acquisition function, wherein the transaction data update request carries a transaction data identifier; when the mutex semaphore is successfully acquired, the transaction data indicated by the transaction data identifier is updated; when the transaction data update is completed, the preset release function is called, and the mutex semaphore is released through the preset release function.
[0074] Optionally, when the financial institution system needs to update transaction data, it can receive a request to update the transaction data of the financial institution system, and call a preset acquisition function to obtain a mutex semaphore. When the mutex semaphore is successfully acquired, the transaction data indicated by the transaction data identifier carried in the transaction data update request is updated. When the transaction data update is completed, the preset release function is called, and the mutex semaphore is released through the preset release function.
[0075] In an embodiment of the present invention, a target transaction request sent by a target terminal is received, and a mutex semaphore is obtained according to a target transaction identifier and a target transaction product identifier. When the target transaction successfully obtains the mutex semaphore, other transactions are in a waiting query state. Then, the target data can be queried in a preset nested dictionary library according to the target transaction identifier and the target transaction product identifier to determine the target transaction and the target data indicated by the target transaction product. Then, the target transaction can be processed according to the target data, and when it is detected that the target transaction processing is completed, the mutex semaphore is released, thereby improving the accuracy of determining the transaction processing time, reducing invalid waiting time, and achieving the technical effect of improving business efficiency.
[0076] The following is a detailed description in conjunction with another embodiment.
[0077] Embodiment 2
[0078] A transaction processing device based on mutually exclusive semaphores provided in this embodiment includes multiple implementation units, each of which corresponds to each implementation step in the above-mentioned embodiment 1.
[0079] Figure 2 is a schematic diagram of an optional transaction processing device based on a mutex semaphore according to an embodiment of the present invention, such as Figure 2As shown, the transaction processing device based on mutually exclusive semaphores may include: a receiving unit 20 , an acquiring unit 21 , a determining unit 22 , and a releasing unit 23 .
[0080] The receiving unit 20 is used to receive a target transaction request sent by a target terminal, wherein the target transaction request carries at least a target transaction identifier and a target transaction product identifier;
[0081] An acquisition unit 21 is used to acquire a mutex semaphore based on a target transaction identifier and a target transaction product identifier, wherein the mutex semaphore is used to control the processing order of different transaction requests;
[0082] A determination unit 22, configured to determine target data based on a target transaction identifier and a target transaction product identifier, wherein the target data is transaction data required for a target transaction indicated by the target transaction identifier;
[0083] The release unit 23 is used to process the target transaction based on the target data, and release the mutex semaphore when it is detected that the target transaction processing is completed.
[0084] The above-mentioned transaction processing device based on mutually exclusive semaphores can receive the target transaction request sent by the target terminal through the receiving unit 20, obtain the mutually exclusive semaphore based on the target transaction identifier and the target transaction product identifier through the acquisition unit 21, determine the target data based on the target transaction identifier and the target transaction product identifier through the determination unit 22, process the target transaction based on the target data through the release unit 23, and release the mutually exclusive semaphore when it is detected that the target transaction processing is completed.
[0085] Optionally, the transaction processing device includes: a first determination module, used to determine the priority level of transactions corresponding to each transaction type based on business requirements of different transaction types before receiving the target transaction request sent by the target terminal, and obtain a transaction priority file; a first construction module, used to construct a preset nested dictionary library based on the transaction product identifier, transaction identifier and transaction data corresponding to each transaction.
[0086] Optionally, the transaction processing device also includes: a second determination module, used to determine the priority level of each transaction request based on the transaction priority file before receiving the target transaction request sent by the target terminal, when multiple transaction requests initiated simultaneously by multiple user terminals are received; a first processing module, used to characterize the transaction request indicated by the highest priority level as the target transaction request, and when the target transaction request is processed, select the transaction request indicated by the next priority level as the target transaction request, wherein the next priority level refers to the highest priority level except the highest priority level.
[0087] Optionally, the transaction processing device also includes: a second construction module, used to construct a mutex semaphore before receiving the target transaction request sent by the target terminal; a first encapsulation module, used to encapsulate a preset acquisition function based on the mutex semaphore, and represent the input parameters of the preset acquisition function as a first transmission parameter, wherein the first transmission parameter includes at least: a transaction product identifier and a transaction identifier; a second encapsulation module, used to encapsulate a preset release function based on the mutex semaphore, and represent the input parameters of the preset release function as a second transmission parameter, wherein the second transmission parameter includes at least: a transaction product identifier and a transaction identifier.
[0088] Optionally, the acquisition unit includes: a first acquisition module, used to call a preset acquisition function, and pass the target transaction identifier and the target transaction product identifier to the preset acquisition function to obtain a mutex semaphore; a first calling module, used to call the preset acquisition function based on a preset time interval until the mutex semaphore is successfully acquired if the mutex semaphore is not successfully acquired.
[0089] Optionally, the determination unit includes: a first query module, used to query the transaction data corresponding to the target transaction product identifier and the target transaction identifier based on a preset nested dictionary library to obtain the target transaction data; and a first characterization module, used to characterize the target transaction data as target data.
[0090] Optionally, the release unit includes: a second calling module, used to call a preset release function when detecting that the target transaction processing is completed; a first releasing module, used to pass the target transaction identifier and the target transaction product identifier to the preset release function to release the mutex semaphore.
[0091] Optionally, the transaction processing device also includes: a second acquisition module, which is used to call a preset acquisition function when a transaction data update request is received, and obtain a mutex semaphore through the preset acquisition function, wherein the transaction data update request carries a transaction data identifier; a first update module, which is used to update the transaction data indicated by the transaction data identifier when the mutex semaphore is successfully acquired; and a second release module, which is used to call a preset release function when the transaction data update is completed, and release the mutex semaphore through the preset release function.
[0092] The above-mentioned transaction processing device based on mutually exclusive semaphores may also include a processor and a memory. The above-mentioned receiving unit 20, acquisition unit 21, determination unit 22, release unit 23, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0093] The processor includes a kernel, which retrieves the corresponding program unit from the memory. The kernel can be set to one or more, and release the mutex semaphore when the target transaction processing is detected to be completed by adjusting the kernel parameters.
[0094] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (fl ash RAM), and the memory includes at least one storage chip.
[0095] According to another aspect of an embodiment of the present invention, a computer program product is also provided, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, implementing any of the above-mentioned transaction processing methods based on mutually exclusive semaphores.
[0096] When the computer program product is executed on a data processing device, it is suitable for executing a program that is initialized with the following method steps: receiving a target transaction request sent by a target terminal, obtaining a mutex semaphore based on a target transaction identifier and a target transaction product identifier, determining target data based on the target transaction identifier and the target transaction product identifier, processing the target transaction based on the target data, and releasing the mutex semaphore when it is detected that the target transaction processing is completed.
[0097] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the above-mentioned transaction processing method based on mutex semaphores.
[0098] Figure 3 1 is a hardware structure block diagram of an electronic device (or mobile device) for a transaction processing method based on a mutually exclusive semaphore according to an embodiment of the present invention. Figure 3 As shown, the electronic device may include one or more processors (e.g., Figure 3 The processor 302a, processor 302b, ..., processor 302n, etc., which may include but are not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 304 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 3The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 3 More or fewer components as shown, or with Figure 3 Different configurations shown.
[0099] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0100] The embodiments or examples of the present disclosure are not exhaustive, but are only illustrative of some embodiments or examples, and are not intended to be specific limitations on the scope of protection of the present disclosure. In the absence of contradiction, each step in a certain embodiment or example can be implemented as an independent example, and the steps can be combined arbitrarily. For example, the scheme after removing some steps in a certain embodiment or example can also be implemented as an independent example, and the order of the steps in a certain embodiment or example can be arbitrarily exchanged. In addition, the optional methods or optional examples in a certain embodiment or example can be combined arbitrarily; in addition, the various embodiments or examples can be combined arbitrarily, for example, some or all steps of different embodiments or examples can be combined arbitrarily, and a certain embodiment or example can be combined arbitrarily with the optional methods or optional examples of other embodiments or examples.
[0101] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0102] In the several embodiments provided by the present invention, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0103] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0104] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0105] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0106] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A transaction processing method based on mutually exclusive semaphores, characterized in that: include: Receiving a target transaction request sent by a target terminal, wherein the target transaction request carries at least a target transaction identifier and a target transaction product identifier; Based on the target transaction identifier and the target transaction product identifier, a mutex semaphore is acquired, wherein the mutex semaphore is used to control the processing order of different transaction requests; Determine target data based on the target transaction identifier and the target transaction product identifier, wherein the target data is transaction data required for the target transaction indicated by the target transaction identifier; The target transaction is processed based on the target data, and the mutex semaphore is released when it is detected that the processing of the target transaction is completed.
2. The transaction processing method based on mutually exclusive semaphores according to claim 1, characterized in that: Before receiving the target transaction request sent by the target terminal, including: Based on the business requirements of different transaction types, determine the priority level of transactions corresponding to each transaction type, and obtain a transaction priority file; Based on the transaction product identifier, transaction identifier and transaction data corresponding to each transaction, a preset nested dictionary library is constructed.
3. The transaction processing method based on mutually exclusive semaphores according to claim 2 is characterized in that: Before receiving the target transaction request sent by the target terminal, it also includes: In the case of receiving multiple transaction requests initiated simultaneously by multiple user terminals, determining the priority level of each of the transaction requests based on the transaction priority file; The transaction request indicated by the highest priority level is characterized as the target transaction request, and when the processing of the target transaction request is completed, the transaction request indicated by the next priority level is selected as the target transaction request, wherein the next priority level refers to the highest priority level except the highest priority level.
4. The transaction processing method based on mutually exclusive semaphores according to claim 1, characterized in that: Before receiving the target transaction request sent by the target terminal, it also includes: Constructing the mutual exclusion semaphore; Based on the mutually exclusive semaphore, a preset acquisition function is encapsulated, and an input parameter of the preset acquisition function is characterized as a first transmission parameter, wherein the first transmission parameter at least includes: a transaction product identifier and a transaction identifier; Based on the mutually exclusive semaphore, a preset release function is encapsulated, and the input parameters of the preset release function are represented as second transmission parameters, wherein the second transmission parameters at least include: a transaction product identifier and a transaction identifier.
5. The transaction processing method based on mutually exclusive semaphores according to claim 4 is characterized in that: The step of acquiring a mutex semaphore based on the target transaction identifier and the target transaction product identifier includes: Calling the preset acquisition function, and passing the target transaction identifier and the target transaction product identifier into the preset acquisition function to acquire the mutex semaphore; In the case that the mutex semaphore is not successfully acquired, the preset acquisition function is called based on a preset time interval until the mutex semaphore is successfully acquired.
6. The transaction processing method based on mutually exclusive semaphores according to claim 2, characterized in that: The step of determining target data based on the target transaction identifier and the target transaction product identifier includes: Based on the preset nested dictionary library, query the transaction data corresponding to the target transaction product identifier and the target transaction identifier to obtain the target transaction data; The target transaction data is characterized as the target data.
7. The transaction processing method based on mutually exclusive semaphores according to claim 4 is characterized in that: When it is detected that the target transaction processing is completed, the step of releasing the mutex semaphore comprises: When it is detected that the target transaction processing is completed, calling the preset release function; The target transaction identifier and the target transaction product identifier are passed into the preset release function to release the mutex semaphore.
8. The transaction processing method based on mutually exclusive semaphores according to claim 4, characterized in that: The transaction processing method further includes: In the case of receiving a transaction data update request, calling the preset acquisition function, and acquiring the mutex semaphore through the preset acquisition function, wherein the transaction data update request carries a transaction data identifier; In case of successfully acquiring the mutex semaphore, updating the transaction data indicated by the transaction data identifier; When the transaction data is updated, the preset release function is called, and the mutex semaphore is released through the preset release function.
9. A transaction processing device based on mutually exclusive semaphores, characterized in that: include: A receiving unit, configured to receive a target transaction request sent by a target terminal, wherein the target transaction request carries at least a target transaction identifier and a target transaction product identifier; an acquisition unit, configured to acquire a mutex semaphore based on the target transaction identifier and the target transaction product identifier, wherein the mutex semaphore is used to control the processing order of different transaction requests; a determining unit, configured to determine target data based on the target transaction identifier and the target transaction product identifier, wherein the target data is transaction data required for the target transaction indicated by the target transaction identifier; The release unit is used to process the target transaction based on the target data, and release the mutex semaphore when it is detected that the processing of the target transaction is completed.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the transaction processing method based on mutex semaphores as described in any one of claims 1 to 8.