CN109819023B - Distributed transaction processing method and related product - Google Patents
Distributed transaction processing method and related product Download PDFInfo
- Publication number
- CN109819023B CN109819023B CN201910031513.1A CN201910031513A CN109819023B CN 109819023 B CN109819023 B CN 109819023B CN 201910031513 A CN201910031513 A CN 201910031513A CN 109819023 B CN109819023 B CN 109819023B
- Authority
- CN
- China
- Prior art keywords
- service
- coordinator
- message
- result
- request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Computer And Data Communications (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the application discloses a distributed transaction processing method and a related product, which are applied to a first service of a distributed service processing system, wherein the distributed service processing system comprises a plurality of services running on a plurality of devices, the plurality of services comprise a registry service, a first service, a second service and a third service, and the method comprises the following steps: the first service receives a transaction branch distribution message sent by the service of the registration center, responds to the transaction distribution message, and sends a response message for determining to start processing the first transaction branch to the registration center; receiving a coordinator service election message from a registry service, and sending processing information of a first transaction branch to the coordinator service; an execution message is received from the coordinator service to perform the execution operation of the first transaction branch. The embodiment of the application provides a transaction processing method for a distributed system, which is beneficial to improving the efficiency and convenience of distributed transaction processing.
Description
Technical Field
The present application relates to the field of electronic device technologies, and in particular, to a distributed transaction processing method and a related product.
Background
The distributed transaction means that a participant of the transaction, a server supporting the transaction, a resource server and a transaction manager are respectively positioned on different nodes of different distributed systems. More simply, a distributed transaction is composed of a plurality of different business operations, which are distributed on different servers and belong to different applications. In a large-scale distributed transaction processing environment, a transaction often spans multiple databases, and an effective strategy is needed for ensuring data consistency among the multiple databases.
In a distributed servitization development architecture mode, one business request often needs multiple services to be completed cooperatively, and each service in the process can perform persistent operation on data. If a service operation fails for some reason, the operation of the service prior to the operation needs to be rolled back. At present, a plurality of solutions are provided for the problem of distributed transaction, but the common problems of complex configuration, high use cost, large network request demand in the processing process, low interaction efficiency and the like exist.
Disclosure of Invention
The embodiment of the application provides a distributed transaction processing method and a related product, so that the high efficiency and convenience of distributed transaction processing are expected to be improved.
In a first aspect, an embodiment of the present application provides a distributed transaction processing method, which is applied to a first service of a distributed service processing system, where the distributed service processing system includes multiple services running on multiple devices, and the multiple services include a registry service, the first service, a second service, and a third service, and the method includes:
receiving a transaction branch allocation message sent by the registry service, and sending a response message for determining to start processing a first transaction branch to the registry service in response to the transaction allocation message, wherein the transaction branch allocation message is obtained by the registry service executing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information;
receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service;
sending processing information of the first transaction branch to the coordinator service according to the election result;
receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message;
and executing the executing operation of the first transaction branch according to the executing message.
In a second aspect, an embodiment of the present application provides a distributed transaction processing apparatus, which is applied to a first service of a distributed service processing system, where the distributed service processing system includes a plurality of services running on a plurality of devices, and the plurality of services include a registry service, the first service, a second service, and a third service; the distributed transaction processing apparatus includes a processing unit and a communication unit, wherein,
the processing unit is configured to receive a transaction branch assignment message sent by the registry service, and send, in response to the transaction assignment message, a response message to the registry service, where the response message determines to start processing a first transaction branch, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; and the system is used for receiving a coordinator service election message from the registry service and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; and processing information for sending the first transaction branch to the coordinator service according to the election result; and a receiver configured to receive an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the execution operation of the first transaction branch according to the execution message.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing steps in any method of the first aspect of the embodiment of the present application.
In a fourth aspect, the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program for electronic data exchange, where the computer program makes a computer perform part or all of the steps described in any one of the methods in the second aspect of the present application.
In a fifth aspect, the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform some or all of the steps described in any one of the methods of the second aspect of the present application. The computer program product may be a software installation package.
It can be seen that, in this embodiment of the present application, a first service receives a transaction branch assignment message sent by the registry service, and sends, in response to the transaction assignment message, a response message to determine to start processing a first transaction branch to the registry service, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; sending processing information of the first transaction branch to the coordinator service according to the election result; receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the executing operation of the first transaction branch according to the executing message. By the method, the embodiment of the application provides a solution for the object consistency of the distributed system without code intrusion and meeting the high concurrency scene, and by receiving the transaction branch distribution message sent by the registry service and introducing and acquiring annotation information, the configuration can be simplified, the use cost and the learning cost of the framework can be reduced, developers can concentrate on the service, the framework and the service can be decoupled, the concurrency capability is improved, the overhead of the system is reduced, and the high efficiency and the convenience of the distributed transaction processing are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a system architecture diagram of a distributed service processing system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a distributed transaction processing method according to an embodiment of the present application;
fig. 3 is a schematic flow chart of another distributed transaction processing method provided in the embodiment of the present application;
fig. 4 is a schematic flow chart of another distributed transaction processing method provided in the embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;
fig. 6 is a block diagram of functional units of a distributed transaction processing apparatus according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," and the like in the description and claims of the present application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The electronic device according to the embodiment of the present application may include various handheld devices, vehicle-mounted devices, wearable devices, computing devices or other processing devices connected to a wireless modem, which have wireless communication functions, and various forms of User Equipment (UE), Mobile Stations (MS), terminal devices (terminal device), and the like.
The following describes embodiments of the present application in detail.
Referring to fig. 1, fig. 1 is a schematic system architecture diagram of a distributed service processing system 100 according to an embodiment of the present application, where the distributed service processing system 100 includes a service end 110 and a plurality of clients 120, the plurality of clients 120 include clients using different types of development languages, and each client 120 runs a target application program, where the service end 110 may adopt a micro-service architecture design, specifically includes a registry service 111, a first service 112, a second service 113, and a third service 114, and each client is in communication connection with the registry service 111. Based on the above design, the following functions are provided in the configuration management of the registry service 111: assigning transaction branches, election coordinator services, etc.
The micro-service architecture uses a distributed service processing system design mode, each sub-service is an independent application, the coupling is reduced, the distributed service processing system is more expandable, and the stability is improved. Secondly, communication among the services is realized by using a service registration and feedback mechanism. The registry service 111 establishes communication with other sub-services of the distributed service processing system, and provides annotation means for easily implementing the allocation process by annotating driven allocation transaction branches. The third service 114, which is a sub-service provider of the distributed service processing system, is also configured as a coordinator service of the microservice, and both are in the same process, which can simplify the operation difficulty.
In a specific implementation, the service end 110 may adopt an independent server to centrally deploy the registry service 111, the first service 112, the second service 113, and the third service 114, or may adopt a distributed design mechanism, and deploy the registry service 111, the first service 112, the second service 113, and the third service 114 on different devices through a distributed system, and specifically, the flexible setting may be performed according to a business requirement without unique limitation. The client 120 may be deployed by using a mobile phone or other terminal equipment, and is flexibly set according to a service requirement.
Referring to fig. 2, fig. 2 is a schematic flowchart of a distributed transaction processing method, which is applied to a first service of a distributed service processing system, where the distributed service processing system includes a plurality of services running on a plurality of devices, and the plurality of services include a registry service, the first service, a second service, and a third service; the method comprises the following steps:
s201, a first service receives a transaction branch distribution message sent by the service of the registration center, responds to the transaction distribution message, and sends a response message for determining to start processing the first transaction branch to the registration center;
wherein the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; loading and analyzing the annotation information according to the processing request and the annotation information to obtain analyzed annotation information; allocating a first transaction branch in the processing request to the first service according to the analyzed annotation information;
the annotation information comprises a preset mapping relation which is obtained by inquiring at least one transaction branch in the transaction branches as an inquiry identifier, wherein the mapping relation comprises a corresponding relation between the at least one transaction branch and the annotation information;
s202, the first service receives a coordinator service election message from the registry service and acquires an election result of the coordinator service;
wherein the coordinator service election message is generated by the registry service performing the following operations: carrying out coordinator service election; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service;
wherein the coordinator service includes, but is not limited to, a third service;
s203, the first service sends the processing information of the first transaction branch to the coordinator service according to the election result;
s204, the first service receives an execution message from the coordinator service;
wherein the execute message comprises a commit operation message or a rollback operation message;
s205, the first service executes the execution operation of the first transaction branch according to the execution message.
It can be seen that, in this embodiment of the present application, a first service receives a transaction branch assignment message sent by the registry service, and sends, in response to the transaction assignment message, a response message to determine to start processing a first transaction branch to the registry service, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; sending processing information of the first transaction branch to the coordinator service according to the election result; receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the executing operation of the first transaction branch according to the executing message. By the method, the embodiment of the application provides a solution for the object consistency of the distributed system without code intrusion and meeting the high concurrency scene, and by receiving the transaction branch distribution message sent by the registry service and introducing and acquiring annotation information, the configuration can be simplified, the use cost and the learning cost of the framework can be reduced, developers can concentrate on the service, the framework and the service can be decoupled, the concurrency capability is improved, the overhead of the system is reduced, and the high efficiency and the convenience of the distributed transaction processing are improved.
In one possible example, the receiving a coordinator service election message from the registry service, and obtaining the election result of the coordinator service, includes: when the first service detects the processing request, according to the annotation information, sending a request for creating a main node and writing an internet protocol address and a configuration port of the first service into the registration center; the first service receives a coordinator service election message from the registry, the coordinator service election message generated by the registry performing the following operations: receiving a request from the first service, and determining a first request result; and accepting a second request from the second service, determining a result of the second request; and receiving a third request from the third service, determining a result of the third request; determining that the third service successfully acquires the main node and determining that the third service serves as a coordinator according to the first request result, the second request result and the third request result; the second request is used for indicating the second service to send a creation host node to the registration center and write the creation host node into the internet protocol address and the configuration port of the second service, and the third request is used for indicating the third service to send the creation host node to the registration center and write the internet protocol address and the configuration port of the third service into the registration center; and the first service acquires the third service as the coordinator service according to the coordinator service election message.
Wherein the coordinator service election message is to be sent by the registry service to the first service, the second service, and the third service.
Wherein the coordinator service election message includes assigning a second transaction branch in the processing request to the second service according to the parsed annotation information; and allocating a third transaction branch in the processing request to the third service according to the parsed annotation information; generating the transaction branch distribution message according to a corresponding relationship, wherein the corresponding relationship comprises a corresponding relationship between the first transaction branch and the first service, a corresponding relationship between the second transaction branch and the second service, and a corresponding relationship between the third transaction branch and the third service; wherein the distributed transaction comprises a plurality of transaction branches including the first transaction branch, the second transaction branch, and the third transaction branch.
As can be seen, in this example, the first service receives the coordinator service election message from the registry service, obtains the election result of the coordinator service, elects one of the services as the coordinator service, saves cost, elects the coordinator service based on the annotation information, simplifies configuration, and meets the three-high scenario of high concurrency, high performance, and high availability.
In a possible example, after the obtaining the third service as the coordinator service according to the coordinator service election message, the method further includes: when detecting that the coordinator service is down, the first service receives a coordinator service election message from the registry again, wherein the coordinator service election message is generated by the registry by performing the following operations: receiving a request from the first service, and determining a first request result; receiving a second request from the second service, and determining a result of the second request; receiving a third request from the third service, determining a result of the third request; determining that the second service successfully acquires the master node and determining that the second service serves as a coordinator according to the first request result, the second request result and the third request result; and the first service acquires the second service as a second coordinator service according to the coordinator service re-election message.
Wherein said re-election message according to said coordinator service comprises repeating said coordinator service election process.
And only one master node exists in the same time, and only one service of the plurality of services can successfully acquire the master node in the same time.
In this example, it can be seen that, in the concurrent creation, only one of the master nodes can be guaranteed to be successful, and when the service on the coordinator goes down, all the live services detect the event and complete the coordinator election again, so as to guarantee that one live coordinator is always running in all the services, which is beneficial to guarantee that the distributed transaction processing is performed normally and orderly.
In one possible example, the sending, to the coordinator service, processing information of the first transaction branch according to the election result includes: the first service creates a first transaction identity number and sends first registration information to the coordinator service; the first service receives a first registration result from the coordinator service according to the first registration information; if the first service receives the first registration result that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: creating a second transaction identity identification number, sending second registration information to the coordinator service, obtaining a second registration result, and if the second registration result is obtained as a successful registration, sending a call request to the third service, where the call request is used to instruct the third service to perform the following operations: and creating a third transaction identity identification number, acquiring third registration information and determining a third registration result.
Wherein the third service comprises the coordinator service.
In a payment scene, a first service creates a balance change transaction identity identification number and sends balance change registration information to a coordinator service, the coordinator service determines that the balance change registration information is successful, the first service receives a successful message of the balance change registration information from the coordinator service and sends a calling request to a second service, the second service creates a point change transaction identity identification number and sends point change registration information to the coordinator service, the coordinator service determines that the point change registration information is successful, the second service receives a successful message of the point change registration information from the coordinator service and sends a calling request to a third service, the third service creates a transaction money transaction identity identification number and determines a transaction money registration information result.
As can be seen, in this example, the first service sends the processing information of the first transaction branch to the coordinator service according to the election result, and the coordinator service receives the registration information from the first service, the second service, and the third service, and determines the result of the registration information, which is beneficial to processing the integrity and accuracy of the distributed transaction, and meets the requirement of solving the consistency of the distributed transaction in a high-concurrency scenario.
In one possible example, the method further comprises, in accordance with receiving an execution message from the coordinator service: the first service accepts an execution message from the coordinator service, the execution message generated by the coordinator service by: according to the first registration result, the second registration result and the third registration result, when the coordinator service determines that the third registration result is a failure, the first service performs a rollback operation of the first transaction branch and the second service performs a rollback operation of the second transaction branch.
Wherein the executing the message comprises executing a rollback operation message and/or executing a commit operation message.
In a payment scenario, the first service is a balance change service, the second service is a credit change service, the third service is a transaction payment service, the coordinator service determines that the balance change registration information is successful, determines that the credit change registration information is successful, and determines that the transaction payment registration information is failed, and then the execution message executes rollback operation for the first service and rollback operation for the second service.
As can be seen, in this example, according to the first registration result, the second registration result, and the third registration result, the coordinator service determines the registration result, so as to determine to execute the rollback operation, and the first service receives the execution message from the coordinator service, which is beneficial to meeting the concurrency capability of the distributed transaction, reducing the overhead of the system, and improving the efficiency and convenience of the distributed transaction processing.
In one possible example, the method further comprises, in accordance with receiving an execution message from the coordinator service: a first transaction accepts an execution message from the coordinator service, the execution message generated by the coordinator service by performing the operations of: receiving an execution message from the coordinator service according to the first registration result, the second registration result, and the third registration result; and when the third registration result is determined to be successful, the first service executes the commit operation of the first transaction branch, and the second service executes the commit operation of the second transaction branch and the third service executes the commit operation of the third transaction branch.
Wherein the executing the message comprises executing a rollback operation message and/or executing a commit operation message.
In a payment scenario, the first service is a balance change service, the second service is a credit change service, the third service is a transaction payment service, the coordinator service determines that the balance change registration information is successful, determines that the credit change registration information is successful, and determines that the transaction payment registration information is successful, and then the execution message is that the first service executes a submission operation, the second service executes a submission operation, and the third service executes a submission operation.
As can be seen, in this example, according to the first registration result, the second registration result, and the third registration result, the coordinator service determines to execute a commit operation, and the first service receives an execution message from the coordinator service, which is beneficial to meeting concurrency capability of distributed transactions, reducing overhead of a system, and improving efficiency and convenience of distributed transaction processing.
In one possible example, the sending, to the coordinator service, processing information of the first transaction branch according to the election result includes: the first service creates a first transaction identity number and sends first registration information to the coordinator service; the first service receives a first registration result from the coordinator service according to the first registration information; if the first service receives the first registration result that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: and creating a second transaction identity identification number, sending second registration information to the coordinator service, acquiring a second registration result, and stopping calling if the second registration result is registration failure.
Wherein the stop calling comprises the first service stopping calling the second service, and the third service suspending service.
In a payment scene, a first service creates a balance change transaction identity identification number and sends balance change registration information to a coordinator service, the coordinator service determines that the balance change registration information is successful, the first service receives the balance change registration information success message from the coordinator service and sends a call request to a second service, the second service creates a point change transaction identity identification number and sends point change registration information to the coordinator service, the coordinator service determines that the point change registration information is successful, and the second service receives the point change registration information failure message from the coordinator service and stops calling.
As can be seen, in this example, the first service sends the processing information of the first transaction branch to the coordinator service according to the election result, the coordinator service receives the registration information from the first service and the second service, determines the result of the registration information, and stops calling when the registration information of the second service is a failure, thereby avoiding unnecessary resource waste, facilitating improvement of convenience and efficiency of processing the distributed transaction, and meeting the requirement of solving the consistency of the distributed transaction in a high-concurrency scenario.
In one possible example, the receiving an execution message from the coordinator service includes: the first service accepts an execution message from the coordinator service, the execution message generated by the coordinator service by: determining an execution message sent to the first service and the second service according to the first registration result and the second registration result; and when the coordinator service determines that the second registration result is a failure, the first service performs a rollback operation of the first transaction branch.
In a payment scenario, the first service is a balance change service, the second service is a point change service, the third service is a transaction payment service, the coordinator service determines that the balance change registration information is successful, and determines that the point change registration information is failed, and then the execution message executes a rollback operation for the first service.
As can be seen, in this example, according to the first registration result and the second registration result, the coordinator service determines the registration result to determine to execute the rollback operation, and the first service receives the execution message from the coordinator service, which is beneficial to meeting the concurrency capability of the distributed transaction, reducing the overhead of the system, and improving the efficiency and convenience of the distributed transaction processing.
Referring to fig. 3, fig. 3 is a schematic flowchart of a distributed transaction processing method, which is applied to a first service of a distributed service processing system, where the distributed service processing system includes a plurality of services running on a plurality of devices, and the plurality of services include a registry service, the first service, a second service, and a third service; as shown in the figure, the distributed transaction processing method includes:
s301, a first service receives a transaction branch distribution message sent by the service of the registration center, responds to the transaction distribution message, and sends a response message for determining to start processing the first transaction branch to the registration center;
s302, when the first service detects the processing request, according to the annotation information, sending a request for creating a main node and writing an internet protocol address and a configuration port of the first service into the registration center;
s303, the first service receives a coordinator service election message from the registration center;
s304, the first service acquires the third service as the coordinator service according to the coordinator service election message;
s305, the first service sends the processing information of the first transaction branch to the coordinator service according to the election result;
s306, the first service receives an execution message from the coordinator service;
s307, the first service executes the execution operation of the first transaction branch according to the execution message.
It can be seen that, in this embodiment of the present application, a first service receives a transaction branch assignment message sent by the registry service, and sends, in response to the transaction assignment message, a response message to determine to start processing a first transaction branch to the registry service, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; sending processing information of the first transaction branch to the coordinator service according to the election result; receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the executing operation of the first transaction branch according to the executing message. By the method, the embodiment of the application provides a solution for the object consistency of the distributed system without code intrusion and meeting the high concurrency scene, and by receiving the transaction branch distribution message sent by the registry service and introducing and acquiring annotation information, the configuration can be simplified, the use cost and the learning cost of the framework can be reduced, developers can concentrate on the service, the framework and the service can be decoupled, the concurrency capability is improved, the overhead of the system is reduced, and the high efficiency and the convenience of the distributed transaction processing are improved.
Referring to fig. 4, fig. 4 is a schematic flowchart of a distributed transaction processing method, which is applied to a first service of a distributed service processing system, where the distributed service processing system includes a plurality of services running on a plurality of devices, and the plurality of services include a registry service, the first service, a second service, and a third service; as shown in the figure, the distributed transaction processing method includes:
s401, a first service receives a transaction branch distribution message sent by the service of the registration center, responds to the transaction distribution message, and sends a response message for determining to start processing the first transaction branch to the registration center;
s402, the first service receives a coordinator service election message from the registry service and acquires an election result of the coordinator service;
s403, the first service creates a first transaction identity number and sends first registration information to the coordinator service;
s404, the first service receives a first registration result from the coordinator service according to the first registration information;
s405, if the first service receives the first registration result that the registration is successful, sending a calling request to the second service;
s406, the first service accepts an execution message from the coordinator service;
s407, the first service executes the execution operation of the first transaction branch according to the execution message.
It can be seen that, in this embodiment of the present application, a first service receives a transaction branch assignment message sent by the registry service, and sends, in response to the transaction assignment message, a response message to determine to start processing a first transaction branch to the registry service, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; sending processing information of the first transaction branch to the coordinator service according to the election result; receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the executing operation of the first transaction branch according to the executing message. By the method, the embodiment of the application provides a solution for the object consistency of the distributed system without code intrusion and meeting the high concurrency scene, and by receiving the transaction branch distribution message sent by the registry service and introducing and acquiring annotation information, the configuration can be simplified, the use cost and the learning cost of the framework can be reduced, developers can concentrate on the service, the framework and the service can be decoupled, the concurrency capability is improved, the overhead of the system is reduced, and the high efficiency and the convenience of the distributed transaction processing are improved.
In addition, according to the first registration result, the second registration result and the third registration result, the coordinator service determines to execute a commit operation, and the first service receives an execution message from the coordinator service, so that the concurrency capability of the distributed transaction is favorably met, the overhead of a system is reduced, and the efficiency and the convenience of the distributed transaction processing are favorably improved.
In accordance with the embodiments shown in fig. 2, fig. 3, and fig. 4, please refer to fig. 5, and fig. 5 is a schematic structural diagram of an electronic device 500 according to an embodiment of the present application, as shown in the figure, the electronic device 500 includes an application processor 510, a memory 520, a communication interface 530, and one or more programs 521, where the one or more programs 521 are stored in the memory 520 and configured to be executed by the application processor 510, and the one or more programs 521 include instructions for performing the following steps;
receiving a transaction branch allocation message sent by the registry service, and sending a response message for determining to start processing a first transaction branch to the registry service in response to the transaction allocation message, wherein the transaction branch allocation message is obtained by the registry service executing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information;
receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service;
sending processing information of the first transaction branch to the coordinator service according to the election result;
receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message;
and executing the executing operation of the first transaction branch according to the executing message.
It can be seen that, in this embodiment of the present application, a first service receives a transaction branch assignment message sent by the registry service, and sends, in response to the transaction assignment message, a response message to determine to start processing a first transaction branch to the registry service, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; sending processing information of the first transaction branch to the coordinator service according to the election result; receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the executing operation of the first transaction branch according to the executing message. By the method, the embodiment of the application provides a solution for the object consistency of the distributed system without code intrusion and meeting the high concurrency scene, and by receiving the transaction branch distribution message sent by the registry service and introducing and acquiring annotation information, the configuration can be simplified, the use cost and the learning cost of the framework can be reduced, developers can concentrate on the service, the framework and the service can be decoupled, the concurrency capability is improved, the overhead of the system is reduced, and the high efficiency and the convenience of the distributed transaction processing are improved.
In a possible example, the receiving a coordinator service election message from the registry service, and obtaining an election result of the coordinator service, where instructions in the program are specifically configured to perform the following operations: when the processing request is detected, sending a request for creating a main node and writing an internet protocol address and a configuration port of the main node into the registration center according to the annotation information; receiving a coordinator service election message from the registry, the coordinator service election message generated by the registry performing the following operations: receiving a request from the first service, and determining a first request result; and accepting a second request from the second service, determining a result of the second request; and receiving a third request from the third service, determining a result of the third request; determining that the third service successfully acquires the main node and determining that the third service serves as a coordinator according to the first request result, the second request result and the third request result; the second request is used for indicating the second service to send a creation host node to the registration center and write the creation host node into the internet protocol address and the configuration port of the second service, and the third request is used for indicating the third service to send the creation host node to the registration center and write the internet protocol address and the configuration port of the third service into the registration center; and acquiring the third service as the coordinator service according to the coordinator service election message.
In a possible example, after the third service is acquired as the coordinator service according to the coordinator service election message, the method further includes the following operation by the instruction in the program: when detecting that the service of the coordinator service is down, re-receiving a coordinator service election message from the registry, wherein the coordinator service election message is generated by the registry by performing the following operations: receiving a request from the first service, and determining a first request result; receiving a second request from the second service, and determining a result of the second request; receiving a third request from the third service, determining a result of the third request; determining that the second service successfully acquires the master node and determining that the second service serves as a coordinator according to the first request result, the second request result and the third request result; and acquiring the second service as a second coordinator service according to the coordinator service re-election message.
In a possible example, the sending, according to the election result, the processing information of the first transaction branch to the coordinator service, and the instructions in the program are specifically configured to perform the following operations: creating a first transaction identity identification number and sending first registration information to the coordinator service; according to the first registration information, the first service receives a first registration result from the coordinator service; if the received first registration result is that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: creating a second transaction identity identification number, sending second registration information to the coordinator service, obtaining a second registration result, and if the second registration result is obtained as a successful registration, sending a call request to the third service, where the call request is used to instruct the third service to perform the following operations: and creating a third transaction identity identification number, acquiring third registration information and determining a third registration result.
In one possible example, the instructions in the program are specifically configured to, in accordance with receiving an execution message from the coordinator service: accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: according to the first registration result, the second registration result and the third registration result, when the coordinator service determines that the third registration result is a failure, the first service performs a rollback operation of the first transaction branch and the second service performs a rollback operation of the second transaction branch.
In one possible example, the instructions in the program are specifically configured to, in accordance with receiving an execution message from the coordinator service: accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: according to the first registration result, the second registration result and the third registration result, when the third registration result is determined to be successful, the first service executes the commit operation of the first transaction branch, and the second service executes the commit operation of the second transaction branch and the third service executes the commit operation of the third transaction branch.
In a possible example, the sending, according to the election result, the processing information of the first transaction branch to the coordinator service, and the instructions in the program are specifically configured to perform the following operations: creating a first transaction identity identification number and sending first registration information to the coordinator service; according to the first registration information, the first service receives a first registration result from the coordinator service; if the received first registration result is that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: and creating a second transaction identity identification number, sending second registration information to the coordinator service, acquiring a second registration result, and stopping calling if the second registration result is registration failure.
In one possible example, the receiving an execution message from the coordinator service, the instructions in the program are specifically configured to: accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: determining an execution message sent to the first service and the second service according to the first registration result and the second registration result; and when the coordinator service determines that the second registration result is a failure, the first service performs a rollback operation of the first transaction branch.
The above description has introduced the solution of the embodiment of the present application mainly from the perspective of the method-side implementation process. It is understood that the electronic device comprises corresponding hardware structures and/or software modules for performing the respective functions in order to realize the above-mentioned functions. Those of skill in the art will readily appreciate that the present application is capable of hardware or a combination of hardware and computer software implementing the various illustrative elements and algorithm steps described in connection with the embodiments provided herein. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiment of the present application, the electronic device may be divided into the functional units according to the method example, for example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit. It should be noted that the division of the unit in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
Fig. 6 is a block diagram of functional units of a distributed transaction processing apparatus 600 according to an embodiment of the present application. The distributed transaction apparatus 600 is applied to a first service of a distributed service processing system, and includes a processing unit 601 and a communication unit 602, wherein,
the processing unit 601 is configured to receive a transaction branch assignment message sent by the registry service, and send, in response to the transaction assignment message, a response message to the registry service, where the response message determines to start processing a first transaction branch, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; and the system is used for receiving a coordinator service election message from the registry service and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; and processing information for sending the first transaction branch to the coordinator service according to the election result; and a receiver configured to receive an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the execution operation of the first transaction branch according to the execution message.
It can be seen that, in this embodiment of the present application, a first service receives a transaction branch assignment message sent by the registry service, and sends, in response to the transaction assignment message, a response message to determine to start processing a first transaction branch to the registry service, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; sending processing information of the first transaction branch to the coordinator service according to the election result; receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the executing operation of the first transaction branch according to the executing message. By the method, the embodiment of the application provides a solution for the object consistency of the distributed system without code intrusion and meeting the high concurrency scene, and by receiving the transaction branch distribution message sent by the registry service and introducing and acquiring annotation information, the configuration can be simplified, the use cost and the learning cost of the framework can be reduced, developers can concentrate on the service, the framework and the service can be decoupled, the concurrency capability is improved, the overhead of the system is reduced, and the high efficiency and the convenience of the distributed transaction processing are improved.
In a possible example, the receiving a coordinator service election message from the registry service and obtaining an election result of the coordinator service, where the processing unit 601 is specifically configured to: when the processing request is detected, sending a request for creating a main node and writing an internet protocol address and a configuration port of the main node into the registration center according to the annotation information; receiving a coordinator service election message from the registry, the coordinator service election message generated by the registry performing the following operations: receiving a request from the first service, and determining a first request result; and accepting a second request from the second service, determining a result of the second request; and receiving a third request from the third service, determining a result of the third request; determining that the third service successfully acquires the main node and determining that the third service serves as a coordinator according to the first request result, the second request result and the third request result; the second request is used for indicating the second service to send a creation host node to the registration center and write the creation host node into the internet protocol address and the configuration port of the second service, and the third request is used for indicating the third service to send the creation host node to the registration center and write the internet protocol address and the configuration port of the third service into the registration center; and acquiring the third service as the coordinator service according to the coordinator service election message.
In a possible example, after obtaining the third service as the coordinator service according to the coordinator service election message, the method further includes the processing unit 601 specifically configured to: when detecting that the service of the coordinator service is down, re-receiving a coordinator service election message from the registry, wherein the coordinator service election message is generated by the registry by performing the following operations: receiving a request from the first service, and determining a first request result; receiving a second request from the second service, and determining a result of the second request; receiving a third request from the third service, determining a result of the third request; determining that the second service successfully acquires the master node and determining that the second service serves as a coordinator according to the first request result, the second request result and the third request result; and acquiring the second service as a second coordinator service according to the coordinator service re-election message.
In a possible example, the processing unit 601 is specifically configured to send processing information of the first transaction branch to the coordinator service according to the election result, and to: creating a first transaction identity identification number and sending first registration information to the coordinator service; according to the first registration information, the first service receives a first registration result from the coordinator service; if the received first registration result is that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: creating a second transaction identity identification number, sending second registration information to the coordinator service, obtaining a second registration result, and if the second registration result is obtained as a successful registration, sending a call request to the third service, where the call request is used to instruct the third service to perform the following operations: and creating a third transaction identity identification number, acquiring third registration information and determining a third registration result.
In a possible example, the processing unit 601 is specifically configured to, according to the execution message received from the coordinator service: accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: according to the first registration result, the second registration result and the third registration result, when the coordinator service determines that the third registration result is a failure, the first service performs a rollback operation of the first transaction branch and the second service performs a rollback operation of the second transaction branch.
In a possible example, the processing unit 601 is specifically configured to, according to the execution message received from the coordinator service: accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: according to the first registration result, the second registration result and the third registration result, when the third registration result is determined to be successful, the first service executes the commit operation of the first transaction branch, and the second service executes the commit operation of the second transaction branch and the third service executes the commit operation of the third transaction branch.
In a possible example, the processing unit 601 is specifically configured to send processing information of the first transaction branch to the coordinator service according to the election result, and to: creating a first transaction identity identification number and sending first registration information to the coordinator service; according to the first registration information, the first service receives a first registration result from the coordinator service; if the received first registration result is that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: and creating a second transaction identity identification number, sending second registration information to the coordinator service, acquiring a second registration result, and stopping calling if the second registration result is registration failure.
In a possible example, the processing unit 601 is specifically configured to, in response to receiving the execution message from the coordinator service: accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: determining an execution message sent to the first service and the second service according to the first registration result and the second registration result; and when the coordinator service determines that the second registration result is a failure, the first service performs a rollback operation of the first transaction branch.
Embodiments of the present application also provide a computer storage medium, where the computer storage medium stores a computer program for electronic data exchange, the computer program enabling a computer to execute part or all of the steps of any one of the methods described in the above method embodiments, and the computer includes an electronic device.
Embodiments of the present application also provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods as described in the above method embodiments. The computer program product may be a software installation package, the computer comprising an electronic device.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit may be stored in a computer readable memory if it is implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a memory, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the above-mentioned method of the embodiments of the present application. And the aforementioned memory comprises: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable memory, which may include: flash Memory disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the method and the core concept of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.
Claims (11)
1. A distributed transaction processing method applied to a first service of a distributed service processing system, the distributed service processing system including a plurality of services running on a plurality of devices, the plurality of services including a registry service, the first service, a second service, and a third service, the method comprising:
receiving a transaction branch allocation message sent by the registry service, and sending a response message for determining to start processing a first transaction branch to the registry service in response to the transaction branch allocation message, wherein the transaction branch allocation message is obtained by the registry service executing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information;
when the processing request is detected, sending a request for creating a main node and writing an internet protocol address and a configuration port of the main node into the registry service according to the annotation information;
receiving a coordinator service election message from the registry service, and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service;
sending processing information of the first transaction branch to the coordinator service according to the election result;
receiving an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message;
and executing the executing operation of the first transaction branch according to the executing message.
2. The method of claim 1, wherein the coordinator service election message is generated by the registry performing the following operations: receiving a request from the first service, and determining a first request result; and accepting a second request from the second service, determining a second request result; and receiving a third request from the third service, determining a third request result; determining that the third service successfully acquires the main node and determining that the third service serves as a coordinator according to the first request result, the second request result and the third request result; the second request is used for indicating the second service to send a creation host node to the registration center and write the creation host node into the internet protocol address and the configuration port of the second service, and the third request is used for indicating the third service to send the creation host node to the registration center and write the internet protocol address and the configuration port of the third service into the registration center;
and acquiring the third service as the coordinator service according to the coordinator service election message.
3. The method of claim 2, wherein after obtaining the third service as the coordinator service according to the coordinator service election message, the method further comprises:
when detecting that the service of the coordinator service is down, re-receiving a coordinator service election message from the registry, wherein the coordinator service election message is generated by the registry by performing the following operations: receiving a request from the first service, and determining a first request result; receiving a second request from the second service, and determining a result of the second request; receiving a third request from the third service, determining a result of the third request; determining that the second service successfully acquires the master node and determining that the second service serves as a coordinator according to the first request result, the second request result and the third request result;
and regenerating the election message according to the coordinator service, and acquiring the second service as the second coordinator service.
4. The method of claim 1, wherein sending processing information of the first transaction branch to the coordinator service according to the election result comprises:
creating a first transaction identity identification number and sending first registration information to the coordinator service;
according to the first registration information, the first service receives a first registration result from the coordinator service;
if the received first registration result is that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: creating a second transaction identity identification number, sending second registration information to the coordinator service, obtaining a second registration result, and if the second registration result is obtained as a successful registration, sending a call request to the third service, where the call request is used to instruct the third service to perform the following operations: and creating a third transaction identity identification number, acquiring third registration information and determining a third registration result.
5. The method of claim 4, wherein the in accordance with receiving the execution message from the coordinator service comprises:
accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: receiving an execution message from the coordinator service according to the first registration result, the second registration result, and the third registration result; and when the coordinator service determines that the third registration result is a failure, the first service performs a rollback operation of the first transaction branch and the second service performs a rollback operation of a second transaction branch.
6. The method of claim 4, wherein the in accordance with receiving the execution message from the coordinator service comprises:
accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: receiving an execution message from the coordinator service according to the first registration result, the second registration result, and the third registration result; and when the third registration result is determined to be successful, the first service executes the commit operation of the first transaction branch, and the second service executes the commit operation of the second transaction branch and the third service executes the commit operation of the third transaction branch.
7. The method of claim 1, wherein sending processing information of the first transaction branch to the coordinator service according to the election result comprises:
creating a first transaction identity identification number and sending first registration information to the coordinator service;
according to the first registration information, the first service receives a first registration result from the coordinator service;
if the received first registration result is that the registration is successful, sending a call request to the second service, wherein the call request is used for indicating the second service to execute the following operations: and creating a second transaction identity identification number, sending second registration information to the coordinator service, acquiring a second registration result, and stopping calling if the second registration result is registration failure.
8. The method of claim 7, wherein receiving the execution message from the coordinator service comprises:
accepting an execution message from the coordinator service, the execution message generated by the coordinator service by performing: determining an execution message sent to the first service and the second service according to the first registration result and the second registration result; and when the coordinator service determines that the second registration result is a failure, the first service performs a rollback operation of the first transaction branch.
9. A distributed transaction processing apparatus, applied to a first service of a distributed service processing system, wherein the distributed service processing system comprises a plurality of services running on a plurality of devices, and the plurality of services comprise a registry service, the first service, a second service, and a third service; the distributed transaction processing apparatus includes a processing unit and a communication unit, wherein,
the processing unit is configured to receive a transaction branch assignment message sent by the registry service, and send, to the registry service in response to the transaction branch assignment message, a response message that determines to start processing a first transaction branch, where the transaction branch assignment message is obtained by the registry service performing the following operations: the registry service receives a processing request from a user and acquires annotation information; and allocating a first transaction branch in the processing request to the first service according to the annotation information; and the request is used for sending a request for creating a main node and writing an internet protocol address and a configuration port of the main node into the registry service according to the annotation information when the processing request is detected; and the system is used for receiving a coordinator service election message from the registry service and acquiring an election result of the coordinator service, wherein the coordinator service election message is generated by the registry service by performing the following operations: receiving the response message and starting election coordinator service; and determining that the third service is the coordinator service; and generating the coordinator service election message according to the determined coordinator service; and processing information for sending the first transaction branch to the coordinator service according to the election result; and a receiver configured to receive an execution message from the coordinator service, wherein the execution message is obtained by the coordinator service performing the following operations: determining a processing result according to the processing information, and generating an execution message; and executing the execution operation of the first transaction branch according to the execution message.
10. An electronic device comprising a processor, a memory, a communication interface, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps in the method of any of claims 1-8.
11. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the method according to any one of claims 1-8.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811646840X | 2018-12-29 | ||
CN201811646840 | 2018-12-29 |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109819023A CN109819023A (en) | 2019-05-28 |
CN109819023B true CN109819023B (en) | 2021-09-14 |
Family
ID=66603428
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910031513.1A Active CN109819023B (en) | 2018-12-29 | 2019-01-14 | Distributed transaction processing method and related product |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109819023B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111143040A (en) * | 2019-12-30 | 2020-05-12 | 北京三快在线科技有限公司 | Transaction processing method, device, system and storage medium |
CN113301091B (en) * | 2020-07-31 | 2022-10-28 | 阿里巴巴集团控股有限公司 | Message processing method and device for distributed system, electronic equipment and medium |
CN112100188B (en) * | 2020-09-01 | 2024-05-28 | 上海交通大学 | Concurrency control method and system based on machine learning |
CN112799799B (en) * | 2020-12-29 | 2024-07-19 | 杭州涂鸦信息技术有限公司 | Data consumption method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6873987B1 (en) * | 2000-05-31 | 2005-03-29 | International Business Machines Corporation | Method, system and program products for recovering from failures within a shared nothing distributed computing environment |
CN106325978A (en) * | 2015-06-19 | 2017-01-11 | 阿里巴巴集团控股有限公司 | Distributed transaction processing method and apparatus |
CN108845866A (en) * | 2018-06-28 | 2018-11-20 | 阿里巴巴集团控股有限公司 | The method and apparatus for handling distributed transaction |
CN108958894A (en) * | 2018-06-14 | 2018-12-07 | 阿里巴巴集团控股有限公司 | A kind of distributed transaction processing method, system, task manager and terminal device |
CN109002462A (en) * | 2018-06-04 | 2018-12-14 | 北京明朝万达科技股份有限公司 | A kind of method and system for realizing distributed things |
-
2019
- 2019-01-14 CN CN201910031513.1A patent/CN109819023B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6873987B1 (en) * | 2000-05-31 | 2005-03-29 | International Business Machines Corporation | Method, system and program products for recovering from failures within a shared nothing distributed computing environment |
CN106325978A (en) * | 2015-06-19 | 2017-01-11 | 阿里巴巴集团控股有限公司 | Distributed transaction processing method and apparatus |
CN109002462A (en) * | 2018-06-04 | 2018-12-14 | 北京明朝万达科技股份有限公司 | A kind of method and system for realizing distributed things |
CN108958894A (en) * | 2018-06-14 | 2018-12-07 | 阿里巴巴集团控股有限公司 | A kind of distributed transaction processing method, system, task manager and terminal device |
CN108845866A (en) * | 2018-06-28 | 2018-11-20 | 阿里巴巴集团控股有限公司 | The method and apparatus for handling distributed transaction |
Non-Patent Citations (1)
Title |
---|
"SOA环境下分布式事务处理的研究";何一昕;《中国优秀硕士学位论文全文数据库 信息科技辑》;20091215;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN109819023A (en) | 2019-05-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109819023B (en) | Distributed transaction processing method and related product | |
CN109949111B (en) | Electronic bill identification distribution method, electronic bill generation method, device and system | |
CN110048879B (en) | Microservice registration method, microservice registration device, electronic equipment and computer-readable storage medium | |
CN111698315B (en) | Data processing method and device for block and computer equipment | |
CN111163130B (en) | Network service system and data transmission method thereof | |
CN107005435B (en) | Network service descriptor shelving method and device | |
CN109800083B (en) | Method, device, system and storage medium for micro-service collaborative call | |
CN111343262B (en) | Distributed cluster login method, device, equipment and storage medium | |
US10282120B2 (en) | Method, apparatus and system for inserting disk | |
CN112380072A (en) | Multi-data center access method and system | |
CN110930003A (en) | Work order processing method and device | |
CN110312266B (en) | Method and device for realizing WIFI communication by multiple systems of terminal | |
CN106101171A (en) | Server method of attachment and device | |
CN103369038A (en) | PaaS (platform as a service) management platform and method | |
US20180088999A1 (en) | Method, device, and system | |
CN112087401A (en) | Method and device for realizing service quality in distributed storage | |
CN114979286A (en) | Access control method, device and equipment for container service and computer storage medium | |
CN110750780A (en) | User role permission fusion method, device and equipment based on multi-service system | |
CN107734050B (en) | Load machine distribution method, computing equipment and load machine distribution system | |
CN106685708B (en) | Method, device and system for determining service relationship | |
CN110378494B (en) | Remote facing slip method, remote facing slip device, storage medium and computer equipment | |
CN113986995A (en) | Request distribution method and device, storage medium and electronic equipment | |
CN114710485A (en) | Processing method and processing apparatus | |
CN111858079B (en) | Distributed lock migration method and device, electronic equipment and storage medium | |
CN114070824A (en) | Registration method, registration cloud service, medium, and program product for internet of things device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |