Method for realizing transaction power verification in financial system scene
By using custom annotations and interceptors in combination with factory mode in the financial system, Redis distributed locks are used to achieve idempotence verification, which solves the performance and consistency issues in transaction idempotence verification and improves system performance and scalability. Simplified development process and maintenance.
Patent Information
- Application Number
- CN202410688972.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-06
AI Technical Summary
In financial systems, existing technologies have performance bottlenecks, data consistency issues, insufficient scalability, and insufficient real-time performance in transaction idempotence verification, especially in high-concurrency scenarios, resulting in reduced system performance and increased maintenance complexity. .
It uses custom annotations and interceptors combined with factory mode to achieve idempotence verification through Redis distributed locks, supports multiple data storage methods, avoids repeated database operations, and improves response speed and processing capabilities.
Simplify the development process, improve development efficiency and system performance, reduce maintenance complexity, ensure data accuracy and consistency, and improve system processing capabilities and scalability.
Smart Images

Figure CN118608152A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial systems, and in particular to a method for implementing transaction power verification in a financial system scenario. Background Art
[0002] During the construction and maintenance phase of financial systems, it is crucial to ensure the stability and reliability of the system. In particular, we must take extra precautions when it comes to transaction interfaces for change and account management. These transaction interfaces are usually responsible for handling key operations such as fund transfers and account balance updates, so they have extremely high requirements for accuracy.
[0003] In order to ensure that these transaction interfaces can be executed correctly, we need to implement idempotency verification. Idempotence means that no matter whether an operation is executed once or multiple times, the final result should be the same. In the context of financial transactions, this means that even if the transaction request is submitted repeatedly, the system should be able to identify and prevent such repeated behavior, thereby avoiding duplicate transaction results.
[0004] To achieve this, developers need to design transaction interfaces with strong validation capabilities. This may include setting unique transaction identifiers, recording transaction status, and implementing logical checks in the system to ensure that if a transaction has been processed, any subsequent identical requests will be rejected or ignored.
[0005] By verifying the idempotence of change and accounting transaction interfaces during the construction and operation of financial systems, we can effectively prevent the problem of duplicate transaction submission, thereby protecting the security and integrity of financial transactions.
[0006] Disadvantages of built-in verification scheme for logic code
[0007] The main disadvantages of this approach include:
[0008] Performance issues: Each request needs to query the database to check whether the serial number exists, which may cause a large number of database accesses, thus affecting system performance. Especially in high-concurrency scenarios, such frequent database operations may become a performance bottleneck.
[0009] Data consistency issues: If a failure occurs between checking whether the serial number exists and actually processing the business (such as a server crash or network interruption), data inconsistency may occur. Even if the serial number exists, the business may not be processed normally due to a failure.
[0010] Scalability issues: If the amount of business to be processed increases, or if a variety of different businesses need to be processed, this approach may require a lot of modifications and expansions, which will increase the complexity and difficulty of maintenance.
[0011] Real-time problem: If the serial number status update in the database is not real-time, it may lead to misjudgment. For example, a business has been processed, but the status in the database has not been updated. At this time, another identical request is received. This method may incorrectly reject the request.
[0012] Disadvantages of the business serial number distribution solution
[0013] The main disadvantages of using the business serial number generator solution include:
[0014] Performance bottleneck: All business requests need to go through a centralized number generator to obtain serial numbers, which may cause the number generator to become a bottleneck of the system. Especially in high-concurrency scenarios, access to the number generator may limit the overall throughput of the system.
[0015] System complexity: Introducing a centralized number generator will increase the complexity of the system. This additional component needs to be maintained and managed, and its high availability and consistency must be ensured.
[0016] Synchronization overhead: If the implementation of the number transmitter is synchronous, it may block the business process during peak hours, resulting in reduced efficiency. Summary of the invention
[0017] In view of the above problems, the present invention is proposed to provide a method for implementing transaction power verification in a financial system scenario that overcomes the above problems or at least partially solves the above problems.
[0018] According to one aspect of the present invention, a method for implementing transaction power verification in a financial system scenario is provided, the verification method comprising:
[0019] Declare basic interceptors and custom annotations;
[0020] During the transaction execution process, idempotency judgment is performed and the results are recorded. During repeated transaction execution, the same results are returned.
[0021] Optionally, the declarative-based interceptor and custom annotation specifically include: using custom annotations to mark methods that require idempotency verification.
[0022] Optionally, the method of using custom annotations to mark the need for idempotency verification specifically includes: declaring a section, and implementing idempotency logic verification processing based on annotation parameters.
[0023] Optionally, the method of using custom annotations to mark the need for idempotency verification also includes:
[0024] It supports multiple data storage methods, including Redis cache and database, and uses the factory mode to implement idempotence verification.
[0025] Optionally, the verification of idempotence using the factory mode specifically includes:
[0026] First, define a custom annotation to mark the method that needs idempotency check, and then declare a section to process the method with @Idempotent annotation;
[0027] In the aspect, the verification processing of the idempotence logic is implemented according to the annotated parameters, and then an idempotence verification factory class is implemented to create corresponding verification instances according to various data storage methods.
[0028] Optionally, during the transaction execution process, idempotency judgment is performed to record the result, and during repeated transaction execution, the same result is returned, specifically including:
[0029] The developer added a special annotation to the system method that needs to verify idempotency. The purpose of this annotation is to perform idempotency verification.
[0030] The annotation also contains a key field, which is the idempotent serial number;
[0031] When a request arrives at the system and triggers this method, the system starts the logic of an aspect;
[0032] In the logic of this aspect, the system uses Redis distributed lock to determine whether the idempotent serial number exists;
[0033] If the serial number does not exist, the system will proceed to the next transaction process.
[0034] Optionally, the idempotent serial number is used to uniquely identify a transaction to ensure that each transaction is unique.
[0035] The present invention provides a transaction idempotency verification method in a financial system scenario, the verification method comprising: declaring a basic interceptor and a custom annotation; during the transaction execution process, performing idempotency judgment and recording the result, and returning the same result during repeated transaction execution. By using the cache to quickly determine whether a request has been processed, repeated database operations are avoided, and the response speed and processing capacity of the system are improved.
[0036] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0038] Figure 1 A schematic diagram of a basic class for declaring idempotent processing provided in an embodiment of the present invention;
[0039] Figure 2 A schematic diagram of the idempotent logic judgment return provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0041] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.
[0042] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0043] This solution uses annotation declaration. The first step is to declare basic interceptors, custom annotations, etc. The second step is to perform idempotent judgment and record results during transaction execution, and return the same results during repeated transaction execution.
[0044] like Figure 1 As shown, declare the idempotent processing base class:
[0045] Use custom annotations to mark methods that require idempotency verification. By declaring an aspect, the idempotency logic verification process is implemented based on the annotation parameters. In order to support different data storage methods, such as Redis cache and database, the factory mode is used to implement idempotency verification.
[0046] First, define a custom annotation to mark the method that needs to be idempotent checked, and then declare a section to process the method with @Idempotent annotation. In the section, we can implement the idempotency logic verification processing according to the annotation parameters, and then implement an idempotency verification factory class to create corresponding verification instances according to different data storage methods.
[0047] like Figure 2 As shown, the idempotent logic judgment returns:
[0048] The developer added a special annotation to the system method that needs to verify idempotency. The purpose of this annotation is to perform idempotency verification. At the same time, this annotation also contains a key field, which is the idempotency serial number. This serial number is used to uniquely identify a transaction. Its existence can ensure that each transaction is unique and will not cause data inconsistency due to repeated operations.
[0049] When a request arrives at the system and triggers this method, the system will start an aspect logic. In this aspect logic, the system will use the Redis distributed lock method to determine whether the idempotent serial number exists. If the serial number does not exist, the system will proceed to the next transaction processing. This step may include operations such as reading, calculating, and writing data. The specific operation content depends on business needs.
[0050] After the transaction is processed, the system will return the processing result. This result is correctly processed to ensure the accuracy and consistency of the data.
[0051] During the design and development process, the present invention fully considers the problems existing in the above solutions and adopts a unified interceptor strategy for idempotence verification. The implementation of this strategy brings two significant benefits.
[0052] This unified interceptor strategy solves the inconvenience faced by developers when writing business codes. Previously, developers needed to embed idempotency checking logic in business codes, which not only increased coding complexity but also reduced development efficiency. Now, by unifying idempotency checking logic into one interceptor, developers can focus on implementing business logic without having to worry about the details of idempotency checking, which improves development efficiency and code quality.
[0053] The present invention also introduces the concept and technology of distributed cache middleware. The introduction of distributed cache middleware makes it more convenient and efficient to handle the idempotency verification problem. Distributed cache middleware can provide high-performance data access services, so that when performing idempotency verification, data can be quickly read and written, thereby improving the overall processing speed.
[0054] The present invention adopts a unified interceptor strategy and introduces distributed cache middleware, which not only frees R&D personnel from the cumbersome idempotence verification logic, but also improves the efficiency and effect of handling idempotence verification problems, providing strong support for software development and operation and maintenance.
[0055] Beneficial effects: Simplified development process: The unified interceptor annotation eliminates the need for developers to repeatedly write idempotent logic when writing interfaces. They can implement idempotence verification simply by adding annotations, thus simplifying the development process and improving development efficiency.
[0056] Improve system performance: Utilize the high performance characteristics of Redis to quickly determine whether a request has been processed through caching, avoiding repeated database operations, thereby improving the system's response speed and processing capabilities. For other scenarios where a database may be used, the system uses a factory model to support expansion in multiple scenarios.
[0057] Easy to maintain and expand: Unified interceptors and annotations make the implementation of idempotence more centralized and standardized, facilitating subsequent maintenance and expansion.
[0058] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for implementing transaction power verification in a financial system scenario, characterized in that: The verification method comprises: Declare basic interceptors and custom annotations; During the transaction execution process, idempotency judgment is performed and the results are recorded. During repeated transaction execution, the same results are returned.
2. According to a method for implementing transaction power verification in a financial system scenario according to claim 1, it is characterized in that: The interceptors and custom annotations based on the declaration specifically include: Use custom annotations to mark methods that require idempotency checks.
3. According to claim 2, a method for implementing transaction power verification in a financial system scenario is characterized in that: The method of using custom annotations to mark the need for idempotency verification specifically includes: Declare a section to implement idempotency logic verification based on annotated parameters.
4. According to a method for implementing transaction power verification in a financial system scenario according to claim 2, it is characterized in that: The method of using custom annotations to mark the need for idempotency verification also includes: It supports multiple data storage methods, including Redis cache and database, and uses the factory mode to implement idempotence verification.
5. According to claim 4, a method for implementing transaction power verification in a financial system scenario is characterized in that: The verification of idempotence using the factory pattern specifically includes: First, define a custom annotation to mark the method that needs idempotency check, and then declare a section to process the method with @Idempotent annotation; In the aspect, the verification processing of the idempotence logic is implemented according to the annotated parameters, and then an idempotence verification factory class is implemented to create corresponding verification instances according to various data storage methods.
6. According to a method for implementing transaction power verification in a financial system scenario according to claim 1, it is characterized in that: During the transaction execution process, the idempotency judgment is performed to record the results. During the repeated transaction execution process, the same results are returned, specifically including: The developer added a special annotation to the system method that needs to verify idempotency. The purpose of this annotation is to perform idempotency verification. The annotation also contains a key field, which is the idempotent serial number; When a request arrives at the system and triggers this method, the system starts the logic of an aspect; In the logic of this aspect, the system uses Redis distributed lock to determine whether the idempotent serial number exists; If the serial number does not exist, the system will proceed to the next transaction process.
7. According to claim 6, a method for implementing transaction power verification in a financial system scenario is characterized in that: The idempotent serial number is used to uniquely identify a transaction, ensuring that each transaction is unique.
