Disclosure of Invention
The present application aims to solve at least one of the technical problems in the related art to some extent.
Therefore, a first objective of the present application is to provide a transaction processing method, where the transaction mapping relationship is stored based on the storage state of a mapping relationship cache server, and for query operation, the probability that the mapping relationship cache server does not have the transaction mapping relationship can be reduced, polling operation on a database is avoided, and pressure on the database is reduced; in addition, the probability of transaction anti-repeat failure can be reduced.
A second object of the present application is to provide a transaction processing device.
A third object of the present application is to propose another transaction processing device.
A fourth object of the present application is to propose a transaction processing system.
A fifth object of the present application is to propose a non-transitory computer-readable storage medium.
To achieve the above object, an embodiment of a first aspect of the present application provides a transaction processing method, including: receiving a transaction service request; acquiring a transaction mapping relation to be stored according to the transaction service request; judging whether a preset mapping relation cache server is in a storage limiting state or not; if the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches delay time, storing the transaction mapping relation to the mapping relation cache server; judging whether response information returned by the mapping relation cache server when the storage is successful is received in a preset time period; and if the response information is received within a preset time period, determining that the transaction mapping relation is successfully stored.
The transaction processing method of the embodiment of the application receives a transaction service request; acquiring a transaction mapping relation to be stored according to the transaction service request; judging whether a preset mapping relation cache server is in a storage limiting state or not; if the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches delay time, storing the transaction mapping relation to the mapping relation cache server; judging whether response information returned by the mapping relation cache server when the storage is successful is received in a preset time period; and if the response information is received within a preset time period, determining that the transaction mapping relation is successfully stored. The method stores the transaction mapping relation based on the storage state of the mapping relation cache server, can reduce the probability of no transaction mapping relation in the mapping relation cache server for query operation, avoids polling operation on the database, and reduces the pressure on the database; in addition, the probability of transaction anti-re-failure can be reduced.
To achieve the above object, a second aspect of the present application provides a transaction processing apparatus, including: a receiving module for receiving a transaction service request; the acquisition module is used for acquiring a transaction mapping relation to be stored according to the transaction service request; the judging module is used for judging whether a preset mapping relation cache server is in a storage limiting state or not; the storage module is used for storing the transaction mapping relation to a delay queue when the mapping relation cache server is in a storage limiting state; the storage module is further configured to store the transaction mapping relationship to the mapping relationship cache server when the transaction mapping relationship in the delay queue reaches a delay time; the judging module is also used for judging whether response information returned by the mapping relation cache server when the mapping relation cache server is successfully stored is received in a preset time period; and the determining module is used for determining that the transaction mapping relation is successfully stored when the response information is received in a preset time period.
The transaction processing device of the embodiment of the application receives a transaction service request; acquiring a transaction mapping relation to be stored according to the transaction service request; judging whether a preset mapping relation cache server is in a storage limiting state or not; if the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches delay time, storing the transaction mapping relation to the mapping relation cache server; judging whether response information returned by the mapping relation cache server when the storage is successful is received in a preset time period; and if the response information is received in a preset time period, determining that the transaction mapping relation is successfully stored. The device can realize the storage of the transaction mapping relation based on the storage state of the mapping relation cache server, can reduce the probability of no transaction mapping relation in the mapping relation cache server for the query operation, avoids the polling operation on the database, and reduces the pressure on the database; in addition, the probability of transaction anti-repeat failure can be reduced.
To achieve the above object, a third aspect of the present application provides another transaction processing device, including: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the transaction processing method as described above when executing the program.
In order to achieve the above object, a fourth aspect of the present application provides a transaction processing system. The method comprises the following steps: the system comprises an application transaction platform, a mapping relation cache server and a database; the application transaction platform is connected with the mapping relation cache server and the database; the application transaction platform is provided with a delay queue and is used for acquiring a transaction mapping relation to be stored; when the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches delay time, sending the transaction mapping relation to the mapping relation cache server; when response information returned by the mapping relation cache server is received in a preset time period, determining that the transaction mapping relation is successfully stored; the transaction mapping relationship includes: the corresponding relation between the transaction serial number and the database storage address; the mapping relation cache server is used for storing a transaction mapping relation and returning response information to the application transaction platform when the transaction mapping relation is successfully stored; and the database is used for storing the transaction data corresponding to the transaction serial number in the database storage address.
In order to achieve the above object, a fifth aspect of the present application provides a non-transitory computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the transaction processing method as described above.
Additional aspects and advantages of the present application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the present application.
Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary and intended to be used for explaining the present application and should not be construed as limiting the present application.
The following describes a transaction processing method and apparatus according to an embodiment of the present application with reference to the drawings. Fig. 1 is a schematic flow chart of a transaction processing method according to an embodiment of the present disclosure. As shown in fig. 1, the transaction processing method includes the following steps:
step 101, a transaction service request is received.
The execution main body of the transaction processing method is a transaction processing device, the transaction processing device can be specifically an application transaction platform in a transaction processing system, a routing module can be embedded in the application transaction platform, and the routing module can execute the transaction processing method. In the embodiment of the present application, a transaction processing apparatus is taken as an application transaction platform for example.
In the embodiment of the application, when a transaction service occurs in the transaction platform, for example, storage and query of transaction data, a routing module in the transaction platform may receive a transaction service request.
In this embodiment, a schematic structural diagram of a transaction processing system may be as shown in fig. 2, and the transaction processing system may include: an application transaction platform, a mapping relation cache server (such as a Redis cluster server) and a database; the application transaction platform is connected with the mapping relation cache server and the database.
The application transaction platform is provided with a delay queue for acquiring a transaction mapping relation to be stored; when the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches the delay time, the transaction mapping relation is sent to a mapping relation cache server; when response information returned by the mapping relation cache server is received in a preset time period, determining that the transaction mapping relation is successfully stored; wherein, the transaction mapping relationship may include: the corresponding relation between the transaction serial number and the database storage address;
the mapping relation cache server is used for storing the transaction mapping relation and returning response information to the application transaction platform when the transaction mapping relation is successfully stored;
and the database is used for storing the transaction data corresponding to the transaction serial number in the database storage address.
And 102, acquiring a transaction mapping relation to be stored according to the transaction service request.
In the embodiment of the application, the transaction mapping relationship may be a corresponding relationship between a transaction serial number and a database storage address, a routing module in a transaction platform is applied, after receiving a transaction service request, the transaction serial number may be obtained by packet capture according to the transaction service request, and then, the transaction serial number and a preset mapping relationship generation policy are combined to generate the corresponding relationship between the transaction serial number and the database storage address. The preset mapping relationship generation policy may be, but is not limited to, a one-to-one mapping relationship, and in order to ensure uniqueness of the transaction serial number, the transaction serial number may be a self-increment ID, or may be generated according to a certain rule according to time, which is not limited in the present application.
In addition, after the corresponding relation between the transaction serial number and the database storage address is generated, whether the state of the database corresponding to the database storage address is in a non-fault state or not can be judged, and if the state of the database corresponding to the database storage address is in the non-fault state, the corresponding relation between the transaction serial number and the database storage address is determined as the transaction mapping relation to be stored. And if the state of the database corresponding to the database storage address is a fault state, combining the transaction serial number and a preset mapping relation generation strategy to regenerate the transaction mapping relation corresponding to the transaction serial number until the state of the database corresponding to the database storage address in the generated transaction mapping relation is a non-fault state.
It should be noted that each database may include a plurality of data tables, and the storage address of the database may quickly locate the position of the specific data table where the transaction data is stored in the database, so as to facilitate the query of the transaction data.
Step 103, judging whether a preset mapping relation cache server is in a storage limiting state;
andstep 104, if the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue.
In the embodiment of the application, after the transaction mapping relation to be stored is obtained, whether the mapping relation cache server can store the transaction mapping relation can be judged, and if the mapping relation cache server is in a storage limiting state, the transaction mapping relation is stored in the delay queue. Wherein restricting the storage state may include: a master-slave switching state, and a fault state.
For example, when the mapping relation cache server is in active-standby switching, the transaction mapping relation is stored in the delay queue. In this embodiment, the delay queue may be used to delay the storage time of the transaction mapping. For example, the time for switching between the master and the slave of the mapping relation cache server is about 30s, the delay time of the delay queue may be set to 30s, and the like, so that when the transaction mapping relation of the delay queue reaches the delay time, the mapping relation cache server is not in the storage-limited state, and the routing module may store the transaction mapping relation into the mapping relation cache server, thereby enabling the transaction mapping relation to be stored. It should be noted that the mapping relation cache server may be, but is not limited to, a Redis server, and may also be a Redis cluster server. The Redis cluster server may include a plurality of Redis servers, one of which serves as a primary server and the others serve as backup servers. The main-standby switching state of the Redis cluster server means that when the main server fails, one server needs to be selected from the standby servers as the main server, and the former main server is used as the standby server. In addition, the failure state of the Redis cluster server can be an interface failure of the Redis cluster server, a network failure and the like, so that the Redis cluster server cannot receive data temporarily.
And 105, storing the transaction mapping relation to the mapping relation cache server when the transaction mapping relation in the delay queue reaches the delay time.
Further, after the transaction mapping relation is placed in the delay queue, when the time of the transaction mapping relation in the delay queue reaches the delay time, the routing module tries to store the transaction mapping relation in the mapping relation cache server until the transaction mapping relation is successfully stored in the mapping relation cache server. It should be noted that the routing module may try to store the transaction mapping relationship in the mapping relationship cache server for multiple times, and each storage operation may be delayed by a certain time, for example, delayed by 1min and 1min30s for a re-operation.
And step 106, judging whether response information returned by the mapping relation cache server when the mapping relation cache server is successfully stored is received in a preset time period.
In the embodiment of the application, after the routing module successfully stores the transaction mapping relationship in the mapping relationship cache server, the mapping relationship cache server sends the response information to the routing module within a preset time period. Therefore, after the transaction mapping relation is stored in the mapping relation cache server, the routing module can judge whether response information returned by the mapping relation cache server when the transaction mapping relation is stored successfully is received or not within preset time.
And step 107, if the response information is received within the preset time period, determining that the transaction mapping relation is successfully stored.
Specifically, if the routing module receives response information sent by the mapping relation cache server within a preset time period, it may be determined that the transaction mapping relation is successfully stored in the mapping relation cache server. In addition, optionally, if the routing module does not receive the response information sent by the mapping relation cache server within the preset time period, the routing module may store the transaction mapping relation into the delay queue again until the transaction mapping relation is successfully stored into the mapping relation cache server.
In the embodiment of the application, when the transaction platform is used for transaction data query, a routing module in the transaction platform can receive a transaction data query request, and then, a mapping relation cache server can be queried according to a transaction serial number to be queried to obtain a target transaction mapping relation comprising the transaction serial number to be queried; and then, acquiring transaction data corresponding to the transaction serial number to be inquired according to the database storage address in the target transaction mapping relation. It should be noted that the query request may include: the transaction serial number to be inquired. The transaction processing method of the embodiment of the application receives a transaction service request; acquiring a transaction mapping relation to be stored according to the transaction service request; judging whether a preset mapping relation cache server is in a storage limiting state or not; if the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches the delay time, storing the transaction mapping relation to a mapping relation cache server; judging whether response information returned by the mapping relation cache server when the storage is successful is received in a preset time period; and if the response information is received within the preset time period, determining that the transaction mapping relation is successfully stored. . The method stores the transaction mapping relation based on the storage state of the mapping relation cache server, can reduce the probability of no transaction mapping relation in the mapping relation cache server for query operation, avoids polling operation on the database, and reduces the pressure on the database; in addition, the probability of transaction anti-repeat failure can be reduced.
Corresponding to the transaction processing method provided by the above embodiment, the embodiment of the present application further provides a transaction processing device, and since the transaction processing device provided by the embodiment of the present application corresponds to the transaction processing method provided by the above embodiment, the implementation of the foregoing transaction processing method is also applicable to the transaction processing device provided by the present embodiment, and is not described in detail in the present embodiment. Fig. 3 is a schematic structural diagram of a transaction processing apparatus according to an embodiment of the present disclosure. As shown in fig. 3, the transaction processing device 300 includes: the device comprises a receivingmodule 310, an obtainingmodule 320, a judgingmodule 330, astoring module 340 and a determiningmodule 350.
Specifically, the receivingmodule 310 is configured to receive a transaction service request; an obtainingmodule 320, configured to obtain a transaction mapping relationship to be stored according to a received transaction service request; the determiningmodule 330 is configured to determine whether a preset mapping relationship cache server is in a storage restriction state; thestorage module 340 is configured to store the transaction mapping relationship into the delay queue when the mapping relationship cache server is in the storage-restricted state; thestorage module 340 is further configured to store the transaction mapping relationship to the mapping relationship cache server when the transaction mapping relationship in the delay queue reaches the delay time; the determiningmodule 330 is further configured to determine whether response information returned by the mapping relation cache server when the storage is successful is received within a preset time period; the determiningmodule 350 is configured to determine that the transaction mapping relationship is successfully stored when the response message is received within a preset time period.
As a possible implementation manner of the embodiment of the present application, thestorage module 340 is further configured to, when the response information is not received within the preset time period, store the transaction mapping relationship into the delay queue again until the transaction mapping relationship is successfully stored into the mapping relationship cache server.
As a possible implementation manner of the embodiment of the present application, thestorage module 340 is further configured to store the transaction mapping relationship to the mapping relationship cache server when the mapping relationship cache server is not in the storage-limited state.
As a possible implementation manner of the embodiment of the present application, the transaction mapping relationship includes: the corresponding relation between the transaction serial number and the database storage address; as shown in fig. 4, the transaction processing device 300 may further include, based on the description in fig. 3: aquery module 360.
Specifically, the receivingmodule 310 is further configured to receive a transaction data query request, where the query request includes: a transaction serial number to be queried; thequery module 360 is further configured to query the mapping relationship cache server according to the transaction serial number to be queried, and obtain a target transaction mapping relationship including the transaction serial number to be queried; the obtainingmodule 320 is further configured to obtain transaction data corresponding to the transaction serial number to be queried according to the database storage address in the target transaction mapping relationship.
As a possible implementation manner of the embodiment of the present application, limiting the storage state includes: a master-slave switching state, and a fault state.
As a possible implementation manner of the embodiment of the present application, the obtainingmodule 320 is specifically configured to obtain, according to the transaction service request, a transaction serial number of the transaction data to be stored; generating a transaction mapping relation corresponding to the transaction serial number by combining the transaction serial number and a preset mapping relation generation strategy; the transaction mapping relationship includes: the corresponding relation between the transaction serial number and the storage address of the database; judging whether the state of the database corresponding to the storage address of the database is a non-fault state or not; and if the state of the database corresponding to the database storage address is a non-fault state, determining the transaction mapping relation as the transaction mapping relation to be stored.
As a possible implementation manner of the embodiment of the application, the obtainingmodule 320 is further specifically configured to, if the state of the database corresponding to the database storage address is a failure state, generate a policy by combining the transaction serial number and a preset mapping relationship, and regenerate the transaction mapping relationship corresponding to the transaction serial number until the state of the database corresponding to the database storage address in the generated transaction mapping relationship is a non-failure state.
The transaction processing device of the embodiment of the application receives a transaction service request; acquiring a transaction mapping relation to be stored according to the transaction service request; judging whether a preset mapping relation cache server is in a storage limiting state or not; if the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches delay time, storing the transaction mapping relation to the mapping relation cache server; judging whether response information returned by the mapping relation cache server when the storage is successful is received in a preset time period; and if the response information is received in a preset time period, determining that the transaction mapping relation is successfully stored. The device can realize the storage of the transaction mapping relation based on the storage state of the mapping relation cache server, can reduce the probability of no transaction mapping relation in the mapping relation cache server for the query operation, avoids the polling operation on the database, and reduces the pressure on the database; in addition, the probability of transaction anti-repeat failure can be reduced.
In order to realize the above embodiment, the present application also proposes another transaction processing device. Fig. 5 is a schematic structural diagram of another transaction processing device according to an embodiment of the present disclosure. The transaction processing device includes:memory 1001,processor 1002, and computer programs stored onmemory 1001 and executable onprocessor 1002.
Theprocessor 1002, when executing the program, implements the transaction processing method provided in the above-described embodiment.
Further, the transaction processing device further comprises:
acommunication interface 1003 for communicating between thememory 1001 and theprocessor 1002.
Amemory 1001 for storing computer programs that can be run on theprocessor 1002.
Memory 1001 may include high-speed RAM memory and may also include non-volatile memory (e.g., at least one disk memory).
Theprocessor 1002 is configured to implement the transaction processing method according to the foregoing embodiment when executing the program.
If thememory 1001, theprocessor 1002, and thecommunication interface 1003 are implemented independently, thecommunication interface 1003, thememory 1001, and theprocessor 1002 may be connected to each other through a bus and perform communication with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 5, but that does not indicate only one bus or one type of bus.
Optionally, in a specific implementation, if thememory 1001, theprocessor 1002, and thecommunication interface 1003 are integrated on one chip, thememory 1001, theprocessor 1002, and thecommunication interface 1003 may complete communication with each other through an internal interface.
Theprocessor 1002 may be a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits configured to implement embodiments of the present Application.
In order to implement the above embodiment, the present application further provides a transaction processing system, including: the system comprises an application transaction platform, a mapping relation cache server and a database; and the application transaction platform is connected with the mapping relation cache server and the database.
The application transaction platform is provided with a delay queue and is used for acquiring a transaction mapping relation to be stored; when the mapping relation cache server is in a storage limiting state, storing the transaction mapping relation into a delay queue; when the transaction mapping relation in the delay queue reaches the delay time, sending the transaction mapping relation to a mapping relation cache server; when response information returned by the mapping relation cache server is received in a preset time period, determining that the transaction mapping relation is successfully stored; the transaction mapping relationship includes: the corresponding relation between the transaction serial number and the database storage address;
the mapping relation cache server is used for storing the transaction mapping relation and returning response information to the application transaction platform when the transaction mapping relation is successfully stored;
and the database is used for storing the transaction data corresponding to the transaction serial number in the database storage address.
The present application also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a transaction processing method as described above.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Moreover, various embodiments or examples and features of various embodiments or examples described in this specification can be combined and combined by one skilled in the art without being mutually inconsistent.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present application, "plurality" means at least two, e.g., two, three, etc., unless explicitly specified otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing steps of a custom logic function or process, and alternate implementations are included within the scope of the preferred embodiment of the present application in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
The logic and/or steps represented in the flowcharts or otherwise described herein, e.g., an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a separate product, may also be stored in a computer-readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application, and that variations, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.