Transaction processing methods, apparatus, devices and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-04
- Publication Date
- 2026-03-10
AI Technical Summary
[0014]根据本公开的技术,提高了事务处理过程的稳定性、可扩展性和可维护性。
Smart Images

Figure CN115827265B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of Internet, in particular to cloud computing technology, and more particularly to a transaction processing method, device, equipment and storage medium. BACKGROUND
[0002] Cloud service is an increasing, using and interacting mode of related services based on Internet, usually involving providing dynamic, scalable and often virtualized resources through Internet. Cloud service is to provide required services in an on-demand and scalable manner through network, thereby reducing operation and maintenance cost of service demander. SUMMARY
[0003] The present disclosure provides a transaction processing method, device, equipment and storage medium.
[0004] According to an aspect of the present disclosure, a transaction processing method is provided, comprising:
[0005] obtaining a to-be-processed transaction from a transaction queue, and determining a transaction state of the to-be-processed transaction;
[0006] determining a to-be-processed executor according to the transaction state, and calling the to-be-processed executor to process the to-be-processed transaction;
[0007] updating the transaction state according to a transaction processing stage where the to-be-processed transaction is located;
[0008] if the transaction state belongs to a non-completion state, adding the to-be-processed transaction to the transaction queue.
[0009] According to another aspect of the present disclosure, an electronic device is also provided, comprising:
[0010] at least one processor; and
[0011] a memory in communication connection with the at least one processor; wherein
[0012] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any one of the transaction processing methods provided by the embodiments of the present disclosure.
[0013] According to another aspect of the present disclosure, a non-transitory computer readable storage medium storing computer instructions is also provided, wherein the computer instructions are used to enable a computer to execute any one of the transaction processing methods provided by the embodiments of the present disclosure.
[0014] According to the technology of the present disclosure, the stability, scalability and maintainability of the transaction processing process are improved.
[0015] It should be understood that the contents described in this part are not intended to identify key or important features of the embodiments of the present disclosure, nor to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0016] The accompanying drawings are used to better understand the present scheme, and do not limit the present disclosure. Among them:
[0017] Figure 1 is a flowchart of a transaction processing method provided by an embodiment of the present disclosure;
[0018] Figure 2 is a flowchart of another transaction processing method provided by an embodiment of the present disclosure;
[0019] Figure 3 is a flowchart of another transaction processing method provided by an embodiment of the present disclosure;
[0020] Figure 4A is a flowchart of another transaction processing method provided by an embodiment of the present disclosure;
[0021] Figure 4B is a schematic diagram of the correspondence between the transaction processing stages, transaction states and candidate executors provided by an embodiment of the present disclosure;
[0022] Figure 5 is a structural diagram of a transaction processing apparatus provided by an embodiment of the present disclosure;
[0023] Figure 6 is a block diagram of an electronic device for implementing the transaction processing method of an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, which include various details of the embodiments of the present disclosure to help understanding, and should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Also, for the sake of clarity and conciseness, the description below omits the description of well-known functions and structures.
[0025] The transaction processing method and transaction processing apparatus provided by the embodiments of the present disclosure are suitable for scenarios of relying on cloud services to process a large number of transactions including different transaction processing stages. The transaction processing methods provided by the embodiments of the present disclosure can be executed by a transaction processing apparatus, which can be implemented by software and / or hardware, and is specifically configured in an electronic device, which can be a distributed device providing cloud services, and the present disclosure does not make any limitation on this.
[0026] For ease of understanding, the transaction processing method is first described in detail.
[0027] Referring to Figure 1 A transaction processing method is shown, comprising:
[0028] S101, obtaining a to-be-processed transaction from a transaction queue, and determining a transaction state of the to-be-processed transaction.
[0029] The transaction queue is a queue specially used for storing to-be-processed transactions. Each to-be-processed transaction corresponds to a transaction state, which is used to represent the transaction processing stage in which the to-be-processed transaction is located. Different transaction processing stages correspond to different transaction states, and different transaction processing stages correspond to different transaction processing logics. Therefore, the transaction state can indicate the transaction processing stage that the subsequent to-be-processed transaction is about to enter, and the transaction processing logic required for the to-be-processed transaction. It should be noted that the present disclosure does not make any limitation on the transaction processing logic corresponding to different transaction processing stages, which can be set or adjusted by the technician according to the need or experience.
[0030] It can be understood that the transaction states of different to-be-processed transactions in the same transaction queue can be the same or different. It should be noted that the transaction state of the to-be-processed transaction can be maintained in the transaction queue or in other storage devices outside the transaction queue, and the present disclosure does not make any limitation thereon.
[0031] For example, the transaction processing stage can include at least one of a transaction verification stage, a service query stage, a resource transfer stage, a service creation stage, and a record generation stage, and each of the above transaction processing sequences constitutes the entire transaction life cycle of the to-be-processed transaction.
[0032] Specifically, in the transaction verification stage, the to-be-processed transaction needs to be verified for transaction legality; in the service query stage, the attribute information (such as at least one of service price, service type, and service duration) of the required service needs to be queried; in the resource transfer stage, the required service needs to be replaced with resources; in the service creation stage, the required service needs to be prepared; and in the record generation stage, the required service and the resource replacement situation need to be recorded.
[0033] Accordingly, the transaction status can include at least one of the following: initial status, pending query status, pending transfer status, pending creation status, pending recording status, and completed status. Specifically, the initial status indicates that the pending transaction will subsequently enter the transaction verification phase; the pending query status indicates that the pending transaction will subsequently enter the service query phase; the pending transfer status indicates that the pending transaction will subsequently enter the resource transfer phase; the pending creation status indicates that the pending transaction will subsequently enter the service creation phase; the pending recording status indicates that the pending transaction will subsequently enter the record generation phase; and the completed status indicates that the record generation phase of the pending transaction has been completed, and the transaction lifecycle of the pending transaction has ended.
[0034] Understandably, by refining the correspondence between transaction processing phases and transaction states, the use of transaction processing phases in service replacement scenarios has been further improved.
[0035] In a specific example, the service replacement scenario could be a cloud service purchase scenario; the transaction verification phase could verify one of the following: the validity of the parameters of the transaction request to be processed, the validity of the signature, and the idempotency of the request; the service query phase could inquire about the price of the required service; the resource transfer phase could pay for the required service; the service creation phase could wait for the required service to be created in order to provide the corresponding service; and the record generation phase could record relevant information in the cloud service purchase scenario.
[0036] To avoid confusion regarding the transaction states of different pending transactions, a unique transaction identifier can be assigned to each pending transaction, and a correspondence between the transaction identifier and its corresponding transaction state can be established. Accordingly, based on the transaction identifier of the pending transaction, the transaction state can be determined using this correspondence.
[0037] In an optional embodiment, upon receiving a transaction request corresponding to a transaction to be processed, a transaction identifier can be generated based on at least one of the following: the transaction request generation time of the transaction to be processed, the device identifier of the transaction identifier proxy service, the table identifier corresponding to the transaction request storage table, and a random number. The transaction request receiving device can be at least one, and the device identifier of the transaction identifier proxy service is used to distinguish different transaction request receiving devices; for example, it can be a MAC address (Media Access Control Address). The transaction request storage table can be at least one, used to store transaction requests; the table identifier of the transaction request storage table is used to distinguish different transaction request storage tables. It should be noted that the naming method of the device identifier and table identifier can be set or adjusted by technicians according to needs or experience, and this disclosure does not impose any limitations on this.
[0038] S102. Based on the transaction status, determine the executor to be processed and call the executor to process the transaction.
[0039] The executor to be processed is used to process transactions in different transaction states, and different executors to be processed correspond to different transaction states. Since there is a one-to-one correspondence between transaction states and transaction processing stages, different executors to be processed correspond to different transaction processing stages.
[0040] For example, a correspondence between different transaction states and candidate executors can be pre-set; accordingly, based on the correspondence, the candidate executor corresponding to the transaction state is selected as the executor to be processed; and the executor to be processed is called to process the transaction to be processed.
[0041] S103. Update the transaction status according to the transaction processing stage of the pending transaction.
[0042] After the pending executor is invoked to process the pending transaction, the pending transaction will enter the next transaction processing stage. Therefore, it is necessary to switch the transaction state of the pending transaction to a transaction state that matches the next transaction processing stage to facilitate the normal processing of the pending transaction in the next transaction processing stage.
[0043] S104. If the transaction status is incomplete, add the pending transaction to the transaction queue.
[0044] If the transaction status is incomplete, it means that the transaction still needs to be processed in subsequent transaction processing stages. Therefore, the transaction needs to be added back to the transaction queue for subsequent retrieval and transaction status determination, so as to process the transaction in the subsequent transaction processing stages.
[0045] Furthermore, if the transaction status is in the completed state, it indicates that the pending transaction has completed all transaction processing stages in the transaction lifecycle. Therefore, it is prohibited to add the pending transaction to the transaction queue, that is, no further transaction processing will be performed on the pending transaction. This ensures the integrity and effectiveness of the transaction processing process of the pending transaction and avoids the waste of computing resources caused by over-processing of the pending transaction.
[0046] This disclosure introduces the transaction state of pending transactions to determine the pending executor and then calls the pending executor to process the pending transaction, ensuring the orderliness and atomicity of the processing process and improving the maintainability of the transaction processing process. Since the transaction state is updated according to the transaction processing stage in which the pending transaction is located, this disclosure transforms the synchronous processing of pending transactions at different transaction processing stages in the prior art into an asynchronous processing process based on the transaction state, without waiting for the result of the previous transaction processing stage, thereby improving the stability of the transaction processing process. When a new transaction processing stage is introduced, a dedicated pending executor can be added for that transaction processing stage, and a new transaction state can be assigned to that stage, improving the scalability of the transaction processing.
[0047] Based on the above technical solutions, this disclosure also provides an optional embodiment in which the transaction status update operation is further optimized and improved. It should be noted that for parts not described in detail in the embodiments of this disclosure, please refer to the relevant descriptions in the foregoing embodiments.
[0048] See Figure 2 The transaction processing methods shown include:
[0049] S201. Obtain the pending transactions from the transaction queue and determine the transaction status of the pending transactions.
[0050] S202. Based on the transaction status, determine the executor to be processed and call the executor to process the transaction.
[0051] S203A: If the transaction processing stage of the pending transaction is the transaction verification stage, then switch the transaction status from the initial state to the pending query state. Continue execution of S204.
[0052] The initial state is set when a transaction request corresponding to the pending transaction is received. When the pending transaction is in the initial state, the transaction verification phase is triggered to verify the legality of the pending transaction. After the verification is successful, the transaction state is switched to the pending query state, triggering the service query phase, which instructs the pending transaction to query the attribute information of the required services.
[0053] S203B. If the transaction processing stage of the pending transaction is the service query stage, then the transaction status is switched from the pending query state to the pending transfer state. Continue execution of S204.
[0054] If the pending transaction is in the service query phase, once the service query is completed, the transaction status will be switched from pending query to pending transfer, triggering the entry into the resource transfer phase, which is used to indicate the replacement of resources for the required services.
[0055] S203C. If the transaction being processed is in the resource transfer phase, then switch the transaction status from the pending transfer state to the pending creation state. Continue execution to S204.
[0056] If the pending transaction is in the resource transfer phase, once the resource transfer is complete, the transaction status will be switched from pending transfer to pending creation, triggering the service creation phase, which is used to indicate the preparation of the required service.
[0057] S203D: If the transaction to be processed is in the service creation stage, then change the transaction status from pending creation to pending recording. Continue execution of S204.
[0058] If the transaction to be processed is in the service creation phase, once the service is created, the transaction status will be switched from the pending creation state to the pending recording state, triggering the entry into the record generation phase, which is used to instruct the service instance and transaction identifier of the required service to be recorded.
[0059] For example, when the service required for a pending transaction is ready to start, the pending transaction is switched from the pending creation state to the pending recording state. Since the service creation process may fail for various reasons, especially for services with long preparation times, to avoid the inconvenience to both service providers and users caused by hastily switching the transaction state to the pending recording state that triggers the recording generation stage if the service creation fails, in an optional embodiment, the transaction state can be controlled to switch from the pending creation state to the pending recording state based on the completion status of service creation.
[0060] Specifically, the transaction state can be switched to the pending state only when the service creation is complete; if the service creation is not complete, the transaction state should not be switched to the pending state, thus ensuring the rationality of the transaction state switching and helping the pending transactions to be processed to be effectively executed in the transaction generation cycle.
[0061] In an alternative embodiment, an intermediate state can be introduced between the pending creation state and the pending recording state to indicate that the service has been created but not yet completed.
[0062] For example, if a service has been created but not yet completed, the transaction status is switched from pending creation to creation; if the service has been created, the transaction status is switched from creation to pending recording.
[0063] It should be noted that since both the "pending creation" and "creating" states indicate that the transaction is in the service creation phase, the corresponding executors can be the same or different. To reduce the waste of computing resources, both states can share a single executor.
[0064] In a specific example, during the "Pending Creation" state, the pending executor sends a preparation instruction message for the required service to the service provider, informing the service provider to start the preparation work for the corresponding service. When the service provider starts preparing for the corresponding service, it responds to the preparation instruction message by calling back the pending executor and setting the pending transaction to the "Creating" state, so that the service requester can be informed of the service preparation status. To further enrich the information on service preparation status, the service preparation progress can also be updated to the service requester in real time or periodically during the "Creating" state, based on the service preparation status.
[0065] Understandably, by introducing the "creating" state, it is possible to address situations where the required services in pending transactions have a long preparation time. This allows service requesters to effectively control the service startup preparation status and improves their user experience.
[0066] S203E: If the transaction processing stage of the pending transaction is the record generation stage, then the transaction status will be switched from the pending record state to the completed state.
[0067] If the transaction to be processed is in the record generation stage, once the record generation is complete, the transaction status will be switched from the pending record state to the completed state, indicating that the entire transaction declaration lifecycle of the transaction has been processed and there are no other transaction processing stages afterward, meaning that no further processing is required.
[0068] S204. If the transaction status is incomplete, add the pending transaction to the transaction queue. Return to execute S201.
[0069] The above-described technical solution of this disclosure further refines the transaction state update operation into the switching from the initial state to the query state during the transaction verification phase, the switching from the query state to the transfer state during the service query phase, the switching from the transfer state to the creation state during the resource transfer phase, the switching from the creation state to the record state during the service creation phase, and the switching from the record state to the completion state during the record generation phase. This improves the state switching situation of different transaction processing stages throughout the entire life cycle of the pending transaction, facilitates the orderly and atomic execution of the pending transaction throughout its entire life cycle, improves the accuracy of the final processing result of the pending transaction, and facilitates the management and maintenance of the pending transaction at different transaction processing stages.
[0070] Based on the above technical solutions, this disclosure also provides an optional embodiment, which provides effective countermeasures for unexpected situations that occur during the processing of transactions. It should be noted that for parts not described in detail in the embodiments of this disclosure, please refer to the relevant descriptions in other embodiments.
[0071] See Figure 3 One transaction processing method shown includes:
[0072] S301. Obtain the pending transactions from the transaction queue and determine the transaction status of the pending transactions.
[0073] S302. Based on the transaction status, determine the executor to be processed and call the executor to process the transaction.
[0074] S303. If calling the pending executor to process the pending transaction fails, determine the target remedy method based on the reason for the failure; wherein, the target remedy method is either a degradation method or a retry method.
[0075] S304. Re-execute the pending transaction according to the target remedy method.
[0076] The reason for failure can be a network error or a system error, which can be determined by the feedback information after the failed execution of the pending transaction. In an optional embodiment, a preset identifier in the feedback information can be parsed, and the reason for failure of this call to the pending executor can be determined according to the mapping relationship between the preset identifier and the failure reason. Different failure reasons correspond to different preset identifiers; the preset identifiers corresponding to each failure reason can be set by technical personnel according to their needs or experience, and this disclosure does not limit the specific presentation method of the preset identifiers.
[0077] The term "remedial method" describes the post-processing execution logic after a transaction fails to execute. Different remedial methods correspond to different post-processing execution logics, which can be set or adjusted by technical personnel based on needs or experience. This disclosure does not impose any limitations on this. The "target remedial method" specifically refers to the remedial method determined in the event that the current invocation of the executor to be processed has failed.
[0078] The retry method involves re-invoking the execution logic in the pending executor.
[0079] The downgrade method includes equivalent execution logic that has the same execution result function as the execution logic in the executor to be processed, but whose execution method has relatively poor accuracy or timeliness. For example, in the process of service quotation, if the latest price is unknown, the latest price can be determined based on historical prices in adjacent historical time periods.
[0080] In an optional embodiment, since the execution results of the equivalent execution logic in the degradation method and the execution logic of the executor to be processed may deviate to some extent, a reversal logic can also be set in the degradation method to eliminate the data differences caused by the execution using the equivalent execution logic after the system recovers from an anomaly. Continuing the previous example, during the service quotation process, if the price using the equivalent execution logic is too high, a price difference refund can be made to the service requester; if the price using the equivalent execution logic is too low, a price difference supplement can be made to the service requester to claim the difference.
[0081] Optionally, if the failure is due to a network anomaly, it indicates that the executor itself can provide services normally, but the communication link network for data transmission with the executor is poor. In this case, retry can be used as the target remedy. By re-calling the executor, the accuracy of the transaction processing result at the current transaction processing stage can be ensured.
[0082] In the event of network jitter, retries can ensure the accuracy of transaction processing results by sacrificing a small amount of execution efficiency. However, network anomalies can also lead to situations where the network cannot be restored for an extended period. Therefore, recklessly using retries for pending transactions for an extended period will severely reduce transaction processing efficiency and prevent the acquisition of transaction results. To avoid this, a preset execution period for retries can be set. If this execution period is exceeded, retries will no longer be used. For example, a degradation approach can be adopted, or the pending transaction can be marked as abnormal, and re-executed after the network recovers. The execution period can be a preset threshold for the number of calls or a preset threshold for execution time, which can be set or adjusted by technical personnel according to their needs or experience.
[0083] To reduce communication bandwidth usage, in one optional embodiment, the executor to be processed can be re-called at preset time intervals within a preset execution cycle of the retry mode; wherein the preset time interval increases with the number of calls. The advantage of this is that it reduces the communication bandwidth between the executor and the processor, thus reducing communication pressure.
[0084] Optionally, if the failure is due to a system exception, it indicates that the system corresponding to the executor to be processed can no longer provide services. In this case, even if the retry method is used, the execution result of the pending transaction cannot be obtained. Therefore, a degraded method can be used to re-execute the pending transaction based on the historical processing data associated with the pending transaction.
[0085] Understandably, using historical processing data associated with pending transactions as a reference can, to some extent, ensure the accuracy of pending transactions, avoid the impact of long waiting times on service requesters, and improve the execution efficiency of pending transactions.
[0086] As can be seen from the above technical solutions, in the event of network anomalies, retrying is used as the target remedy; in the event of system anomalies, degradation is used as the target remedy. This can effectively balance the accuracy and efficiency of the execution results of the pending transactions.
[0087] S305. Update the transaction status according to the transaction processing stage of the pending transaction.
[0088] S306. If the transaction status is incomplete, add the pending transaction to the transaction queue.
[0089] This embodiment of the disclosure determines the target remedy method based on the failure reason during the processing of pending transactions, and then re-executes the pending transactions using the corresponding target remedy method. This avoids the impact of pending transaction failure on subsequent transaction processing stages, thereby ensuring the smooth and effective execution of pending transactions in the post-processing stages of the current transaction processing stage, and thus improving the execution efficiency of pending transactions throughout the entire lifecycle of transaction processing.
[0090] Based on the above technical solutions, this disclosure also provides a preferred embodiment for implementing the transaction processing method. See [link to previous document]. Figure 4A The transaction processing method shown includes a transaction identifier generation phase and a transaction processing phase.
[0091] 1) Transaction identifier generation phase
[0092] Receive transaction requests sent by service requesters and respond to the transaction requests by assigning a unique transaction identifier to the transaction request; persist the transaction identifier to the transaction state database and set the transaction state of the transaction identifier to the initial state; create pending transactions based on the transaction requests and add the pending transactions to the transaction queue.
[0093] For example, a transaction identifier proxy service (work-proxy server) can be invoked to generate a transaction identifier based on the device identifier of the transaction identifier proxy service, the generation timestamp of the transaction request, the table identifier corresponding to the transaction request storage table, and a random number.
[0094] 2) Transaction processing phase
[0095] Read the pending transaction from the transaction queue and determine its transaction status in the transaction status database; select the candidate executor corresponding to the transaction status as the pending executor and call the pending executor to process the pending transaction; after execution, update the transaction status corresponding to the transaction identifier of the pending transaction in the transaction status database according to the preset correspondence between transaction processing stages and transaction status.
[0096] See Figure 4B The diagram illustrates the correspondence between transaction processing stages, transaction states, and candidate executors.
[0097] The transaction processing phase includes the transaction verification phase, service query phase, resource transfer phase, service creation phase, and record generation phase; the transaction status includes the initial state, the state to be queried, the state to be transferred, the state to be created, the state to be recorded, and the completed state; the candidate executors include the transaction verification executor, the service query executor, the resource transfer executor, the service creation executor, and the record generation executor.
[0098] Specifically, if the transaction state is in the initial state, it enters the transaction verification phase, where the transaction verification executor is called to verify the legality of the transaction to be processed. After the verification passes, the transaction state switches to the pending query state, entering the service query phase, where the service query executor is called to query the attribute information of the required service for the transaction to be processed. After the query is completed, the transaction state switches to the pending transfer state, entering the resource transfer phase, where the resource transfer executor is called to perform resource replacement for the required service. After the resource replacement is completed, the transaction state switches to the pending creation state, entering the service creation phase, where the service creation executor is called to inform the service provider to prepare for service. If the service has been created but not yet completed (this can be done by the service provider switching the state when starting service preparation, or by responding to a query operation from the service requester and calling the service creation executor a second time to query the service preparation status), the transaction state switches to the creating state. After the service is created, the service provider calls back the service creation executor to switch the transaction state to the pending record state. After the service is created, the record generation executor is called to record the service instance and transaction identifier of the required service. After the recording is completed, the transaction state switches to the completed state, ending the entire lifecycle of the pending transaction.
[0099] Furthermore, if any transaction processing stage fails to execute the transaction to be processed, the transaction status can be set to a failed state to instruct technical personnel to intervene manually or roll back.
[0100] The above technical solution can streamline the entire lifecycle of a transaction, ensuring its stability. Furthermore, by employing a flow control approach, the orderly execution of different executors is driven by the transaction state, guaranteeing the atomicity and maintainability of the transaction process. Additionally, when a new transaction processing stage needs to be introduced, it can be handled by setting up executors with specific business functions and adding new transaction states, demonstrating good scalability.
[0101] As an implementation of the above-described transaction processing methods, this disclosure also provides an optional embodiment of an execution apparatus for implementing the above-described transaction methods. See also Figure 5 The transaction processing apparatus 500 shown includes: a transaction status determination module 501, an executor determination module 502, a transaction status update module 503, and a transaction addition module 504.
[0102] The transaction status determination module 501 is used to obtain the transaction to be processed from the transaction queue and determine the transaction status of the transaction to be processed.
[0103] The executor determination module 502 is used to determine the executor to be processed based on the transaction status, and to call the executor to be processed to process the transaction to be processed;
[0104] The transaction status update module 503 is used to update the transaction status according to the transaction processing stage of the transaction to be processed.
[0105] The transaction addition module 504 is used to add the pending transaction to the transaction queue if the transaction status is incomplete.
[0106] This disclosure introduces the transaction state of pending transactions to determine the pending executor and then calls the pending executor to process the pending transaction, ensuring the orderliness and atomicity of the processing process and improving the maintainability of the transaction processing process. Since the transaction state is updated according to the transaction processing stage in which the pending transaction is located, this disclosure transforms the synchronous processing of pending transactions at different transaction processing stages in the prior art into an asynchronous processing process based on the transaction state, without waiting for the result of the previous transaction processing stage, thereby improving the stability of the transaction processing process. When a new transaction processing stage is introduced, a dedicated pending executor can be added for that transaction processing stage, and a new transaction state can be assigned to that stage, improving the scalability of the transaction processing.
[0107] In an optional embodiment, the transaction processing phase includes a transaction verification phase, a service query phase, a resource transfer phase, a service creation phase, and a record generation phase;
[0108] The transaction states include initial state, pending query state, pending transfer state, pending creation state, pending recording state, and completed state.
[0109] In an optional embodiment, the transaction status update module 503 includes:
[0110] The verification phase switching unit is used to switch the transaction status from the initial state to the pending query state if the transaction processing phase of the pending transaction is the transaction verification phase.
[0111] The query phase switching unit is used to switch the transaction status from the pending query state to the pending transfer state if the transaction processing phase of the pending transaction is the service query phase.
[0112] The transfer phase switching unit is used to switch the transaction status from the pending transfer state to the pending creation state if the transaction processing phase of the pending transaction is the resource transfer phase.
[0113] The creation phase switching unit is used to switch the transaction status from the pending creation state to the pending recording state if the transaction processing phase of the pending transaction is the service creation phase.
[0114] The recording stage switching unit is used to switch the transaction status from the pending recording state to the completed state if the transaction processing stage of the pending transaction is the recording generation stage.
[0115] The initial state is set when a transaction request corresponding to the pending transaction is received.
[0116] In an optional embodiment, the creation stage switching unit is specifically used for:
[0117] If the transaction to be processed is in the service creation stage, then the transaction status is switched from the pending creation state to the pending recording state according to the completion status of service creation.
[0118] In an optional embodiment, the creation phase switching unit includes:
[0119] The creation-in-progress switching subunit is used to switch the transaction status from the pending creation state to the creation-in-progress state if a service has been created but the service creation is not yet complete.
[0120] The creation and switching sub-unit is used to switch the transaction status from the creation state to the pending record state if the service creation is completed.
[0121] In an optional embodiment, the device 500 further includes:
[0122] The module prohibits adding transactions, which prevents the pending transactions from being added to the transaction queue if the transaction status is complete.
[0123] In an alternative embodiment, the device 500 further includes:
[0124] The remedy determination module is used to determine the target remedy method based on the reason for failure if the call to the executor to process the pending transaction fails during the processing of the pending transaction; wherein the target remedy method is a degradation method or a retry method.
[0125] The re-execution module is used to re-execute the pending transaction according to the target remedy method.
[0126] In an optional embodiment, the remedy determination module includes:
[0127] The retry method determination unit is used to determine the retry method as the target remedy method if the failure reason is network anomaly.
[0128] The degradation method determination unit is used to determine the degradation method as the target remedial method if the failure reason is a system abnormality.
[0129] In an optional embodiment, the re-execution module includes:
[0130] A retry response unit is used to re-invoke the executor to process the pending transaction if the target remedy method is a retry method.
[0131] The degradation response unit is used to re-execute the pending transaction based on the historical processing data associated with the pending transaction if the target remedy method is a degradation method.
[0132] In an optional embodiment, the retry mode response unit is specifically used for:
[0133] Within the preset execution cycle of the retry method, the pending executor is called again to process the pending transaction according to a preset time interval;
[0134] The preset time interval increases with the number of calls.
[0135] The above-described transaction processing apparatus can execute the transaction processing methods provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects for executing each transaction processing method.
[0136] The technical solutions disclosed herein involve the collection, storage, use, processing, transmission, provision, and disclosure of transaction requests, pending transactions, and the transaction status of pending transactions, all of which comply with relevant laws and regulations and do not violate public order and good morals.
[0137] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0138] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0139] like Figure 6 As shown, device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded from storage unit 608 into random access memory (RAM) 603. RAM 603 may also store various programs and data required for the operation of device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0140] Multiple components in device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0141] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as transaction processing methods. For example, in some embodiments, the transaction processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the transaction processing method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform transaction processing methods by any other suitable means (e.g., by means of firmware).
[0142] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0143] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0144] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0145] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0146] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0147] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is established by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem that addresses the management difficulties and weak business scalability inherent in traditional physical hosting and VPS services. Servers can also be servers for distributed systems or servers integrated with blockchain technology.
[0148] Artificial intelligence (AI) is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies mainly include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.
[0149] Cloud computing refers to a technology system that enables access to a shared pool of physical or virtual resources via a network. These resources can include servers, operating systems, networks, software, applications, and storage devices, and can be deployed and managed on demand and in a self-service manner. Cloud computing technology can provide efficient and powerful data processing capabilities for applications such as artificial intelligence and blockchain, as well as for model training.
[0150] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution provided in this disclosure can be achieved, and this is not limited herein.
[0151] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A transaction processing method, characterized by, The method is used for cloud service purchase scenario, comprising: obtaining a to-be-processed transaction from a transaction queue, and determining a transaction state of the to-be-processed transaction; determining a to-be-processed executor according to the transaction state, and calling the to-be-processed executor to process the to-be-processed transaction; updating the transaction state according to a transaction processing stage in which the to-be-processed transaction is located; if the transaction state belongs to a non-completion state, adding the to-be-processed transaction to the transaction queue; wherein the transaction processing stage comprises a transaction verification stage, a service query stage, a resource transfer stage, a service creation stage and a record generation stage; the transaction state comprises an initial state, a to-be-queried state, a to-be-transferred state, a to-be-created state, a to-be-recorded state and a completion state; the transaction verification stage is used for transaction legality verification of the to-be-processed transaction; the service query stage is used for attribute information query of a required service in the to-be-processed transaction; the resource transfer stage is used for resource replacement of the required service; the service creation stage is used for preparation of the required service; and the record generation stage is used for record of the required service and the resource replacement; wherein the updating the transaction state according to the transaction processing stage in which the to-be-processed transaction is located comprises: if the transaction processing stage in which the to-be-processed transaction is located is the transaction verification stage, switching the transaction state from the initial state to the to-be-queried state; if the transaction processing stage in which the to-be-processed transaction is located is the service query stage, switching the transaction state from the to-be-queried state to the to-be-transferred state; if the transaction processing stage in which the to-be-processed transaction is located is the resource transfer stage, switching the transaction state from the to-be-transferred state to the to-be-created state; if the transaction processing stage in which the to-be-processed transaction is located is the service creation stage, switching the transaction state from the to-be-created state to the to-be-recorded state; if the transaction processing stage in which the to-be-processed transaction is located is the record generation stage, switching the transaction state from the to-be-recorded state to the completion state; wherein the initial state is set when a transaction request corresponding to the to-be-processed transaction is received; the method further comprises: if the calling of the to-be-processed executor to process the to-be-processed transaction fails, determining a target remedial mode according to a failure cause; wherein the target remedial mode is a degradation mode or a retry mode; and re-executing the to-be-processed transaction according to the target remedial mode; wherein the retry mode is re-calling execution logic in the to-be-processed executor; and the degradation mode comprises equivalent execution logic which has the same function as an execution result of the execution logic in the to-be-processed executor, but has relatively poor execution accuracy or timeliness.
2. The method of claim 1, wherein, the switching of the transaction state from the to-be-created state to the to-be-recorded state if the transaction processing stage in which the to-be-processed transaction is located is the service creation stage comprises: if the transaction processing stage in which the to-be-processed transaction is located is the service creation stage, controlling the switching of the transaction state from the to-be-created state to the to-be-recorded state according to service creation completion.
3. The method of claim 2, wherein, The step of controlling the switch of the transaction status from the pending creation state to the pending recording state based on the service creation completion status includes: If a service has been created but the creation process is incomplete, the transaction status will be changed from pending creation to creation. If the service is created, the transaction status will be switched from the creation state to the pending record state.
4. The method according to any one of claims 1 to 3, wherein, The method further includes: If the transaction status is complete, then adding the pending transaction to the transaction queue is prohibited.
5. The method of claim 1, wherein, The process of determining the target remedial measures based on the cause of failure includes: If the failure is due to a network error, then the retry method will be used as the target remedy. If the failure is due to a system anomaly, then the degradation method will be used as the target remedy.
6. The method of claim 1, wherein, The step of re-executing the pending transaction according to the target remedy method includes: If the target remedy is a retry, then the pending executor is called again to process the pending transaction; If the target remedy is a degradation method, then the pending transaction is re-executed based on the historical processing data associated with the pending transaction.
7. The method of claim 6, wherein, The step of re-invoking the executor to process the transaction includes: Within the preset execution cycle of the retry method, the pending executor is called again to process the pending transaction according to a preset time interval; The preset time interval increases with the number of calls.
8. A transaction processing apparatus, characterized by comprising: Used in cloud service purchase scenarios, including: The transaction status determination module is used to retrieve transactions to be processed from the transaction queue and determine the transaction status of the transactions to be processed. An executor determination module is used to determine the executor to be processed based on the transaction status, and to call the executor to be processed to process the transaction to be processed; The transaction status update module is used to update the transaction status according to the transaction processing stage of the transaction to be processed; The transaction addition module is used to add the pending transaction to the transaction queue if the transaction status is incomplete. The transaction processing phase includes a transaction verification phase, a service query phase, a resource transfer phase, a service creation phase, and a record generation phase. The transaction status includes initial status, pending query status, pending transfer status, pending creation status, pending recording status, and completed status; The transaction verification phase is used to verify the legality of the transaction to be processed; the service query phase is used to query the attribute information of the services required in the transaction to be processed; the resource transfer phase is used to replace the resources of the required services; the service creation phase is used to prepare the required services; and the record generation phase is used to record the required services and resource replacement details. The transaction status update module includes: The verification phase switching unit is used to switch the transaction status from the initial state to the query state if the transaction processing phase of the transaction to be processed is the transaction verification phase. The query phase switching unit is used to switch the transaction status from the pending query state to the pending transfer state if the transaction processing phase of the pending transaction is the service query phase. The transfer stage switching unit is configured to switch the transaction state from the to-be-transferred state to the to-be-created state if the transaction processing stage of the to-be-processed transaction is a resource transfer stage. The creation stage switching unit is configured to switch the transaction state from the to-be-created state to the to-be-recorded state if the transaction processing stage of the to-be-processed transaction is a service creation stage. The record stage switching unit is configured to switch the transaction state from the to-be-recorded state to the completed state if the transaction processing stage of the to-be-processed transaction is a record generation stage. The initial state is set when a transaction request corresponding to the to-be-processed transaction is received. The remediation mode determination module is configured to determine a target remediation mode according to a failure cause if the to-be-processed transaction fails to be processed by the to-be-processed executor during processing of the to-be-processed transaction, wherein the target remediation mode is a downgrade mode or a retry mode. The re-execution module is configured to re-execute the to-be-processed transaction according to the target remediation mode. The retry mode is to re-call execution logic in the to-be-processed executor, and the downgrade mode includes equivalent execution logic which has the same function as the execution result of the execution logic in the to-be-processed executor but has relatively poor execution accuracy or timeliness.
9. The apparatus of claim 8, wherein, The creation stage switching unit is specifically configured to: If the transaction processing stage of the to-be-processed transaction is a service creation stage, switch the transaction state from the to-be-created state to the to-be-recorded state according to service creation completion.
10. The apparatus of claim 9, wherein, The creation stage switching unit includes: The in-creation switching subunit is configured to switch the transaction state from the to-be-created state to the in-creation state if a service has been created and service creation is not completed. The post-creation switching subunit is configured to switch the transaction state from the in-creation state to the to-be-recorded state if service creation is completed.
11. The apparatus of any one of claims 8-10, wherein, The apparatus further includes: The prohibition adding module is configured to prohibit adding the to-be-processed transaction to the transaction queue if the transaction state belongs to the completed state.
12. The apparatus of claim 8, wherein, The remediation mode determination module includes: The retry mode determination unit is configured to take the retry mode as the target remediation mode if the failure cause is a network exception. The downgrade mode determination unit is configured to take the downgrade mode as the target remediation mode if the failure cause is a system exception.
13. The apparatus of claim 8, wherein, The re-execution module includes: The retry mode response unit is configured to re-call the to-be-processed executor to process the to-be-processed transaction if the target remediation mode is the retry mode. The downgrade mode response unit is configured to re-execute the to-be-processed transaction according to historical processing data associated with the to-be-processed transaction if the target remediation mode is the downgrade mode.
14. The apparatus of claim 13, wherein, The retry mode response unit is specifically configured to: Re-call the to-be-processed executor to process the to-be-processed transaction at a preset time interval within a preset execution period of the retry mode. The preset time interval increases with an increase in the number of calls.
15. An electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the transaction processing method of any one of claims 1-7.
16. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are for causing a computer to perform the transaction processing method of any one of claims 1-7.
17. A computer program product comprising computer programs / instructions which, when executed by a processor, implement the steps of the transaction processing method of any one of claims 1-7.
Citation Information
Patent Citations
Task queue processing method and device and storage medium
CN111124625A
Transaction processing method and device, storage medium and computer equipment
CN114860486A