CN116069868A - Distributed flexible transaction processing method and device based on enterprise microservice - Google Patents

Distributed flexible transaction processing method and device based on enterprise microservice Download PDF

Info

Publication number
CN116069868A
CN116069868A CN202310233438.3A CN202310233438A CN116069868A CN 116069868 A CN116069868 A CN 116069868A CN 202310233438 A CN202310233438 A CN 202310233438A CN 116069868 A CN116069868 A CN 116069868A
Authority
CN
China
Prior art keywords
service
transaction
foreground
instance
global
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.)
Granted
Application number
CN202310233438.3A
Other languages
Chinese (zh)
Other versions
CN116069868B (en
Inventor
夏维强
遆好贺
姜丽萍
许晨
李明亮
王落
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
XCMG Hanyun Technologies Co Ltd
Original Assignee
XCMG Hanyun Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by XCMG Hanyun Technologies Co Ltd filed Critical XCMG Hanyun Technologies Co Ltd
Priority to CN202310233438.3A priority Critical patent/CN116069868B/en
Publication of CN116069868A publication Critical patent/CN116069868A/en
Application granted granted Critical
Publication of CN116069868B publication Critical patent/CN116069868B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/273Asynchronous replication or reconciliation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Multi Processors (AREA)

Abstract

The application discloses a distributed flexible transaction processing method and device based on enterprise micro-service, wherein different service requests are respectively submitted to corresponding foreground arrangement services by identifying service request types of clients, the corresponding foreground arrangement services create a plurality of calling logics of data write operation interfaces of a plurality of micro-services according to the different service requests, then the transaction center service creates corresponding global transactions in a global transaction table based on the plurality of calling logics, the corresponding foreground arrangement services are notified to respectively execute the global transactions, abnormal events generated by executing the global transactions by the foreground arrangement services are captured in real time, and the transaction center service is triggered to respectively execute compensation flows corresponding to the corresponding global transactions. According to the embodiment of the application scene of the high-concurrency long transaction, the fault tolerance performance of executing the distributed flexible transaction in the enterprise software system based on the micro-service architecture is improved, and therefore the final consistency of data among databases of all micro-services is ensured.

Description

Distributed flexible transaction processing method and device based on enterprise microservice
Technical Field
The application relates to the technical field of computer information, in particular to a distributed flexible transaction processing method and device based on enterprise microservices.
Background
In an enterprise software system based on a micro-service architecture, a business processing scenario of distributed transactions is typically involved. Distributed transactions refer to multiple micro-services and multiple databases that need to be deployed across a distribution to perform a certain business function. Distributed rigid transactions refer to requiring a distributed transaction as strongly consistent with the local transaction of each database, whereas distributed flexible transactions do not require a distributed transaction as strongly consistent with the local transaction of each database, but rather require a final consistency of data between databases. One scheme for implementing distributed flexible transaction processing in enterprise microservice architecture is to adopt a Saga model, the Saga model splits a distributed transaction into a plurality of local transactions, each local transaction is provided with a corresponding execution module and a compensation module, and when any local transaction is in error, the final consistency of transaction data can be achieved by calling the transaction processing before rollback of the related compensation module. The Saga model supports collaborative transaction coordination and organized transaction coordination, wherein the collaborative transaction coordination is to distribute the execution sequence of the transaction to each micro service, each micro service realizes the transaction coordination through event exchange, and the organized transaction coordination is to be responsible for coordinating each micro service to execute local transaction by a centralized transaction orchestrator. Because the collaborative type Saga model has lower performance in the application scene of long transactions (namely more local transactions are contained), the organized type Saga model is more suitable for the application scene of the long transactions.
However, in an enterprise software system based on a micro-service architecture, software applications of multiple different business processes may be involved, where the software applications may generally share a set of enterprise micro-services, and thus, when a centralized transaction orchestrator is used to coordinate and process distributed flexible transactions across multiple micro-services in the software applications based on a traditional orchestration Saga model, in an application scenario of a high-concurrency long transaction, once the centralized transaction orchestrator fails or has a performance bottleneck, the execution of the whole distributed flexible transaction may be abnormal, so that a problem of data final inconsistency between databases of the micro-services occurs. Accordingly, there is a need for an improved solution to the above-mentioned problems.
Disclosure of Invention
In view of this, the present application proposes a method and apparatus for distributed flexible transaction processing based on enterprise micro services, which are used to improve the fault tolerance performance of executing distributed flexible transactions in an enterprise software system based on micro service architecture, so as to ensure the final consistency of data between databases of each micro service.
In a first aspect, the present application proposes a distributed flexible transaction method based on enterprise microservices, including:
Identifying whether the service request type of the client is a first service request or a second service request, submitting the first service request to a first foreground orchestration service, and submitting the second service request to a second foreground orchestration service;
the first foreground orchestration service creates a first calling logic of a data writing operation interface of a plurality of micro services according to the first service request, and the second foreground orchestration service creates a second calling logic different from the first calling logic of the data writing operation interface of the plurality of micro services according to the second service request, and notifies the transaction center service of the first calling logic and the second calling logic;
the transaction center service creates a first global transaction and a second global transaction in a global transaction table based on the first calling logic and the second calling logic, and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction respectively;
and capturing a first abnormal event generated by the first foreground arrangement service executing the first global transaction and a second abnormal event generated by the second foreground arrangement service executing the second global transaction in real time, and triggering the business-in-transaction service to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction respectively according to the first abnormal event and the second abnormal event.
In some embodiments, notifying the transaction center platform service of the first call logic and the second call logic includes:
the first foreground orchestration service and the second foreground orchestration service acquire access addresses of a first instance of the in-transaction platform service at a first node and a first instance of the in-transaction platform service at a second node;
the first foreground orchestration service informs the first instance of the business center platform service of the first calling logic according to the access address of the first instance of the business center platform service;
the second foreground orchestration service notifies the second instance of the in-transaction platform service of the second call logic according to the access address of the second instance of the in-transaction platform service.
In some embodiments, the transaction center service creates a first global transaction and a second global transaction in a global transaction table based on the first call logic and the second call logic, and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction, respectively, comprising:
the first instance of the in-transaction table service creates the first global transaction in a global transaction table in a shared database based on the first call logic, and the second instance of the in-transaction table service creates the second global transaction in a global transaction table in the shared database based on the second call logic.
In some embodiments, the method further comprises:
when the first instance service is interrupted, the first foreground orchestration service informs the second instance of the first calling logic according to the access address of the second instance, so that the second instance creates the first global transaction in a global transaction table in the shared database based on the first calling logic;
when the second instance services an interrupt, the second foreground orchestration service notifies the first instance of the second call logic according to the access address of the first instance, so that the first instance creates the second global transaction in a global transaction table in the shared database based on the second call logic.
In some embodiments, the method further comprises:
the first foreground orchestration service and the second foreground orchestration service acquire access addresses of third instances of the in-transaction platform service at a third node;
when the first instance service is interrupted, the first foreground orchestration service informs the third instance of the first calling logic according to the access address of the third instance, so that the third instance creates the first global transaction in a global transaction table in the shared database based on the first calling logic;
When the second instance services an interrupt, the second foreground orchestration service notifies the third instance of the second call logic according to the access address of the third instance, so that the third instance creates the second global transaction in a global transaction table in the shared database based on the second call logic.
In some embodiments, the triggering the transaction center service according to the first and second abnormal events to execute a first compensation procedure and a second compensation procedure corresponding to the first and second global transactions, respectively, includes:
the first instance sequentially executes first forward compensation operation corresponding to the first global transaction according to the first abnormal event, and if the first forward compensation operation fails, sequentially executes first backward compensation operation corresponding to the first global transaction;
and the second instance sequentially executes second forward compensation operation corresponding to the second global transaction according to the second abnormal event, and if the second forward compensation operation fails, sequentially executes second backward compensation operation corresponding to the second global transaction.
In some embodiments, the method further comprises:
executing a distributed timing task in any node of the first node and the second node, traversing the global transaction table in a preset period, and acquiring a list of incomplete global transactions with the time greater than a preset time from the current time in the global transaction table;
triggering a third exception event for each incomplete global transaction in the list of incomplete global transactions, and notifying the first instance or the second instance of the third exception event according to the transaction type of each incomplete global transaction;
and the first instance or the second instance sequentially executes a third forward compensation operation corresponding to each incomplete global transaction according to the third abnormal event, and if the third forward compensation operation fails, sequentially executes a third backward compensation operation corresponding to each incomplete global transaction.
In some embodiments, the method further comprises:
and adjusting the maximum retry times of the first forward compensation operation, the second forward compensation operation and the third forward compensation operation in an adaptive manner based on the system resource occupancy rate of the first node and the second node, and/or scheduling the distributed timing task in an adaptive manner between the first node and the second node based on the system resource occupancy rate of the first node and the second node.
In some embodiments, the method further comprises:
setting transaction lock marks for data written by a data write operation interface for calling each micro service in the execution process of the first global transaction and the second global transaction;
after the execution of the first global transaction and the second global transaction is successful, the first foreground orchestration service and the second foreground orchestration service broadcast message notifications to each micro service, so that each micro service clears the transaction lock mark according to the message notifications.
In a second aspect, the present application further proposes a distributed flexible transaction method based on enterprise microservices, including:
identifying a plurality of service requests from a client, wherein the plurality of service requests correspond to a plurality of service request types, and respectively submitting the plurality of service requests to a plurality of foreground arrangement services respectively corresponding to the plurality of service request types;
the foreground orchestration services respectively create a plurality of calling logics of the data writing operation interfaces of the micro services according to the service requests, the calling logics are different, and the calling logics are respectively notified to a plurality of instances of the business center platform service;
A plurality of instances of the business center platform service respectively establish a plurality of global business in a shared global business table based on the plurality of calling logics, and inform the plurality of foreground orchestration services to respectively execute the plurality of global business;
capturing at least one first abnormal event generated by the foreground arrangement services respectively executing the global transactions in real time, and triggering the corresponding instance of the service in the transaction to respectively execute a first compensation flow corresponding to the abnormal global transaction according to the at least one first abnormal event.
In a third aspect, the present application further proposes a distributed flexible transaction processing device based on enterprise microservices, including:
the request identification unit is used for identifying whether the service request type of the client is a first service request or a second service request, so as to submit the first service request to a first foreground orchestration service and submit the second service request to a second foreground orchestration service;
the foreground arrangement unit is used for creating first calling logic of the data write operation interfaces of the micro services according to the first business request by the first foreground arrangement service, creating second calling logic of the data write operation interfaces of the micro services according to the second business request by the second foreground arrangement service, and notifying the transaction center service of the first calling logic and the second calling logic;
The transaction creation unit is used for creating a first global transaction and a second global transaction in a global transaction table based on the first call logic and the second call logic by the transaction center service, and notifying the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction respectively;
the exception handling unit is used for capturing a first exception event generated by the first foreground arrangement service executing the first global transaction and a second exception event generated by the second foreground arrangement service executing the second global transaction in real time, and triggering the transaction center service to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction respectively according to the first exception event and the second exception event.
In a fourth aspect, the present application further proposes a distributed flexible transaction processing device based on enterprise microservices, including:
the request identification unit is used for identifying a plurality of service requests from the client, wherein the service requests correspond to a plurality of service request types, and the service requests are respectively submitted to a plurality of foreground arrangement services corresponding to the service request types;
The foreground arrangement unit is used for respectively creating a plurality of calling logics of the data write operation interfaces of the micro-services according to the service requests, wherein the calling logics are different, and respectively notifying a plurality of instances of the business center platform service to the calling logics;
the transaction creation unit is used for respectively creating a plurality of global transactions in the shared global transaction table based on the plurality of calling logics by a plurality of instances of the transaction center platform service and notifying the plurality of foreground arrangement services to respectively execute the plurality of global transactions;
the exception handling unit is used for capturing at least one first exception event generated by the execution of the global transactions by the foreground orchestration services respectively in real time, and triggering the corresponding instance of the business-in-business service to execute a first compensation flow corresponding to the at least one abnormal global transaction respectively according to the at least one first exception event.
The application can at least achieve the following beneficial effects:
the method comprises the steps of identifying the service request type of a client, submitting a first service request to a first foreground orchestration service, submitting a second service request to a second foreground orchestration service, creating first call logic for data write operation interfaces of a plurality of micro services according to the first service request by the first foreground orchestration service, creating second call logic different from the first call logic for the data write operation interfaces of the plurality of micro services according to the second service request by the second foreground orchestration service, then creating a first global transaction and a second global transaction in a global transaction table by a transaction center service based on the first call logic and the second call logic, notifying the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction respectively, capturing first abnormal events generated by the first foreground orchestration service executing the first global transaction and second abnormal events generated by the second foreground orchestration service executing the second global transaction in real time, and triggering second abnormal events generated by the first foreground service executing the second global transaction and corresponding to the first abnormal transactions and the second abnormal transactions executing the second abnormal transaction and the first abnormal transaction and the second abnormal transaction corresponding to the first global transaction and the second global transaction executing compensation process. Therefore, aiming at the enterprise software system based on the micro-service architecture, even if a fault or performance bottleneck occurs to an individual foreground arrangement service under the application scene of a high-concurrency long transaction, other foreground arrangement services can not be influenced to execute corresponding distributed flexible transactions, meanwhile, the locally persistent global transaction data and abnormal transaction processing are managed by combining with independently deployed business center service, the fault tolerance performance of executing the distributed flexible transactions in the enterprise software system based on the micro-service architecture is improved, and the final consistency of data among databases of all micro-services is ensured.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly explain the drawings that are required to be used in the embodiments of the present application. It is appreciated that the following drawings depict only certain embodiments of the application and are not to be considered limiting of its scope.
FIG. 1 is a flow diagram of a distributed flexible transaction method based on enterprise microservices according to a first embodiment of the present application;
FIG. 2 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a second embodiment of the present application;
FIG. 3 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a third embodiment of the present application;
FIG. 4 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a fourth embodiment of the present application;
FIG. 5 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a fifth embodiment of the present application;
FIG. 6 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a sixth embodiment of the present application;
FIG. 7 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a seventh embodiment of the present application;
FIG. 8 is a flow diagram of a distributed flexible transaction method based on enterprise microservices according to an eighth embodiment of the present application;
FIG. 9 is a schematic diagram of a distributed flexible transaction device based on enterprise microservices according to a first embodiment of the present application;
FIG. 10 is a partial schematic diagram of an enterprise microservice-based distributed flexible transaction device according to a second embodiment of the present application;
FIG. 11 is a schematic diagram of a portion of an enterprise microservice-based distributed flexible transaction processing device according to a third embodiment of the present application;
FIG. 12 is a schematic diagram of a portion of an enterprise microservice-based distributed flexible transaction processing device according to a fourth embodiment of the present application;
FIG. 13 is a schematic diagram of a portion of an enterprise microservice-based distributed flexible transaction processing device according to a fifth embodiment of the present application;
fig. 14 is a schematic structural diagram of an enterprise microservice-based distributed flexible transaction device according to a sixth embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present application. However, it should be understood that the described embodiments are only some, but not all, of the exemplary embodiments of the present application and, therefore, the following detailed description of the embodiments of the present application is not intended to limit the scope of the claims of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and in the claims of this application are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order, and are not to be construed as indicating or implying relative importance.
As previously described, in an enterprise software system based on a micro-service architecture, software applications that may involve multiple different business processes may generally share a set of enterprise micro-services, so when a centralized transaction orchestrator is used to coordinate processing of distributed flexible transactions across multiple micro-services in the software applications based on a traditional orchestration Saga model, in an application scenario of high-concurrency long transactions, once the centralized transaction orchestrator fails, a data exception occurs in the execution of the entire distributed flexible transaction, which causes a problem of data final inconsistency between databases of the micro-services. To this end, embodiments of the present application propose a distributed flexible transaction processing method and apparatus based on enterprise microservices to improve the above-mentioned problems.
Fig. 1 is a flow diagram of a distributed flexible transaction processing method based on enterprise microservices according to a first embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
Step S101, identifying whether the service request type of the client is a first service request or a second service request, submitting the first service request to a first foreground orchestration service, and submitting the second service request to a second foreground orchestration service;
step S102, the first foreground orchestration service creates a first calling logic of a data writing operation interface of a plurality of micro services according to the first service request, the second foreground orchestration service creates a second calling logic different from the first calling logic of the data writing operation interface of the plurality of micro services according to the second service request, and notifies the transaction center service of the first calling logic and the second calling logic;
step S103, the business center service creates a first global business and a second global business in a global business table based on the first calling logic and the second calling logic, and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global business and the second global business respectively;
step S104, capturing, in real time, a first abnormal event generated by the first foreground arrangement service executing the first global transaction and a second abnormal event generated by the second foreground arrangement service executing the second global transaction, and triggering the in-transaction platform service to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction respectively according to the first abnormal event and the second abnormal event.
In this application, an enterprise software system based on a micro-service architecture generally includes a plurality of software applications with different service flows, and service requests from clients can be divided into a plurality of service request types according to the software applications from which the service requests come. In this embodiment, taking the example that the service request of the client is from the first software application and the second software application, the first software application and the second software application implement different service flows, so that the service request of the client from the first software application may be referred to as a first service request, and the service request of the client from the second software application may be referred to as a second service request.
In this embodiment, after identifying whether the service request type of the client is a first service request or a second service request, the first service request is submitted to a first foreground orchestration service, and the second service request is submitted to a second foreground orchestration service. The first foreground arrangement service and the second foreground arrangement service are used for arranging the calling sequence of the data write operation interfaces of the plurality of micro services related in the business request of the client according to the business request type of the client so as to realize the corresponding business processing flow. The first foreground orchestration service creates a first calling logic of the data writing operation interfaces of the micro services according to the first service request, and the second foreground orchestration service creates a second calling logic of the data writing operation interfaces of the micro services according to the second service request. In one embodiment, the first foreground arranging service and the second foreground arranging service can be deployed by distributed nodes, and can be laterally expanded into more than two foreground arranging services such as a third foreground arranging service, a fourth foreground arranging service and the like on the basis of the first foreground arranging service and the second foreground arranging service according to the variety and the number of service request types of the clients.
In this embodiment, the first call logic for the data write operation interface to the plurality of micro-services is different from the second call logic for the data write operation interface to the plurality of micro-services. For example, assume that a plurality of micro-services in an enterprise software system are represented as
Figure SMS_1
The data write operation interfaces of the plurality of micro-services are respectively expressed as +.>
Figure SMS_8
N is an integer greater than 1, representing the number of the plurality of micro-services. Then, a first call logic of a data write operation interface to the plurality of micro services, which is related to a first service request, and a pair, which is related to a second service requestThe second calling logic of the data write operation interfaces of the micro services may include different calling orders of the data write operation interfaces of the same group of micro services in the micro services, may also include calling of the data write operation interfaces of different groups of micro services in the micro services, and may also include calling of the data write operation interfaces of the micro services partially shared in the micro services. As one example, both the first service request and the second service request relate to a micro-service +.>
Figure SMS_12
Is different in that the order of the two is different, e.g. the first service request is for micro-services +. >
Figure SMS_2
The first call logic of the data write operation interface of (1) is denoted +.>
Figure SMS_7
Second service request is about micro-service>
Figure SMS_11
The second call logic of the data write operation interface of (a) can be expressed as +.>
Figure SMS_15
. As a second example, the first service request and the second service request relate to invocation of data write operation interfaces of different groups of micro services, respectively, e.g. the first service request relates to invocation of micro services
Figure SMS_4
First call logic of the data write operation interface of (1), denoted +.>
Figure SMS_6
The second service request relates to a micro-service +.>
Figure SMS_9
The second call logic of the data write operation interface of (a) can be expressed as +.>
Figure SMS_13
. As a third example, the first service request and the second service request may also each relate to a call to a data write operation interface of a partially shared micro-service, e.g. the first service request relates to +_ to the micro-service>
Figure SMS_3
First call logic of the data write operation interface of (1), denoted +.>
Figure SMS_5
The second service request relates to a micro-service +.>
Figure SMS_10
The second call logic of the data write operation interface of (2) may be expressed as
Figure SMS_14
And then, after the first foreground orchestration service and the second foreground orchestration service respectively create a first calling logic and a second calling logic of the data writing operation interfaces of the micro services according to the first service request and the second service request, the first calling logic and the second calling logic need to be notified to the business center service. In this embodiment, the transaction center service is configured to perform global distributed transaction (hereinafter referred to as global transaction) construction on different call logics of data write operation interfaces of multiple micro services created by each front-end orchestration service. The transaction center service stores a global transaction table in a persistent data storage module, wherein the global transaction table stores global transactions respectively executed by each front-end arrangement service, and each global transaction comprises the calling sequence of data write operation interfaces of a plurality of micro services, the data write operation interface information of each micro service and reverse data operation interface information forming reverse data operation with the data write operation interface of each micro service. If the data writing operation interface of each micro service is a data newly-added interface, the corresponding reverse data operation interface is a data deleting interface; if data write operations of individual microservices The interface is a data updating interface, and the corresponding reverse data operation interface is a data updating and restoring interface, namely an operation interface for updating and restoring the data of the database into the original data. If the data write operation interfaces of the plurality of micro-services are respectively represented as
Figure SMS_16
The reverse data manipulation interface corresponding thereto may be expressed as + ->
Figure SMS_17
In one embodiment, the data write operation interface information and the reverse data operation interface information of each micro service include an interface URI address and an interface parameter, respectively. In one embodiment, the data write operation interface and the reverse data operation interface of each micro-service may be an API interface based on the HTTP protocol, such as an API interface based on the RESTful micro-service interface protocol.
In this embodiment, each global transaction further includes the execution state of the entire global transaction and each branch transaction. The transaction center service creates a first global transaction and a second global transaction in a global transaction table based on the first calling logic and the second calling logic respectively, and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction respectively. The first foreground orchestration service and the second foreground orchestration service execute remote call of the data write operation interfaces of the corresponding plurality of micro services according to the call sequence of the data write operation interfaces of the plurality of micro services contained in the first global transaction and the second global transaction. Meanwhile, in the link execution process of executing the first global transaction and the second global transaction by the first foreground orchestration service and the second foreground orchestration service, a first abnormal event generated by executing the first global transaction by the first foreground orchestration service and a second abnormal event generated by executing the second global transaction by the second foreground orchestration service are captured in real time. The first exception event generated by the first foreground orchestration service executing the first global transaction and the second exception event generated by the second foreground orchestration service executing the second global transaction may include a call failure or a response timeout to a data write operation interface of either micro-service of the first global transaction and the second global transaction. And updating the execution state of the branch transaction corresponding to the call of the data write operation interface of the micro service as failure once the call of the data write operation interface of the micro service in the execution link fails.
In this embodiment, once a first exception event generated by the first foreground arrangement service executing the first global transaction and a second exception event generated by the second foreground arrangement service executing the second global transaction are captured in real time, the first foreground arrangement service and the second foreground arrangement service trigger the in-transaction platform service to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction respectively according to the first exception event and the second exception event. The first compensation flow and the second compensation flow corresponding to the first global transaction and the second global transaction respectively can comprise exception processing of compensation operation for branch transactions which are failed to be executed in the first global transaction and the second global transaction, so that the data in the databases of each micro service ensure final consistency.
In summary, the embodiment of the application submits a first service request to a first foreground orchestration service by identifying the service request type of a client, submits a second service request to a second foreground orchestration service, wherein the first foreground orchestration service creates first call logic for data write operation interfaces of a plurality of micro services according to the first service request, the second foreground orchestration service creates second call logic for data write operation interfaces of the plurality of micro services according to the second service request, then a transaction center service creates a first global transaction and a second global transaction in a global transaction table based on the first call logic and the second call logic, and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction respectively, simultaneously captures a first abnormal event generated by the first foreground orchestration service executing the first global transaction and a second abnormal event generated by the second foreground orchestration service executing the second global transaction in real time, and creates a first abnormal event generated by the second global transaction according to the first abnormal event and the second abnormal event trigger corresponding to the first transaction and the second abnormal transaction executing the second abnormal transaction and the first abnormal transaction executing the second global transaction and the first abnormal transaction compensating process and the second global transaction. Therefore, aiming at the enterprise software system based on the micro-service architecture, even if a fault or performance bottleneck occurs to an individual foreground arrangement service under the application scene of a high-concurrency long transaction, other foreground arrangement services can not be influenced to execute corresponding distributed flexible transactions, meanwhile, the locally persistent global transaction data and abnormal transaction processing are managed by combining with independently deployed business center service, the fault tolerance performance of executing the distributed flexible transactions in the enterprise software system based on the micro-service architecture is improved, and the final consistency of data among databases of all micro-services is ensured.
Fig. 2 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a second embodiment of the present application. As shown in fig. 2, on the basis of the method steps in the foregoing embodiment, notifying the transaction center service of the first call logic and the second call logic in step S102 may include:
step S201, the first foreground arrangement service and the second foreground arrangement service acquire access addresses of a first instance of the business center service positioned at a first node and a second instance of the business center service positioned at a second node;
step S202, the first foreground arrangement service informs the first calling logic of the first instance of the business center platform service according to the access address of the first instance of the business center platform service;
in step S203, the second foreground orchestration service notifies the second instance of the in-transaction platform service of the second call logic according to the access address of the second instance of the in-transaction platform service.
In this embodiment, the in-transaction table service may be deployed by using distributed multiple nodes, where each node separately runs a running instance of the in-transaction table service, for example, a first instance of the in-transaction table service located in a first node and a second instance of the in-transaction table service located in a second node. The first foreground orchestration service and the second foreground orchestration service may obtain access addresses for a first instance of the in-transaction platform service at a first node and a second instance of the in-transaction platform service at a second node before accessing the in-transaction platform service.
In one embodiment, when the first instance and the second instance of the transaction center service are started, the micro access address of the transaction center service may be registered with the enterprise micro service registry. The first foreground orchestration service and the second foreground orchestration service may obtain access addresses from the enterprise micro service registry for a first instance of the in-transaction platform service at a first node and a second instance of the in-transaction platform service at a second node. Then, the first foreground orchestration service notifies the first instance of the in-transaction table service of the first call logic according to the access address of the first instance of the in-transaction table service, and the second foreground orchestration service notifies the second call logic of the second instance of the in-transaction table service according to the access address of the second instance of the in-transaction table service.
In one embodiment, the first instance and the second instance of the in-transaction table service may be simultaneously connected to a persisted shared database, accessing a global transaction table in the shared database.
According to the embodiment of the application, the first instance and the second instance of the business center platform service are respectively operated at the first node and the second node, the first foreground arrangement service informs the first instance of the business center platform service of the first calling logic according to the access address of the first instance of the business center platform service, and the second foreground arrangement service informs the second instance of the business center platform service of the second calling logic according to the access address of the second instance of the business center platform service. Therefore, the method and the system manage the persistent global transaction data and process the abnormal transaction based on different running examples of the business center platform service, and each running example of the business center platform service fails or the performance bottleneck does not affect other running examples of the business center platform service, so that the fault tolerance performance of executing the distributed flexible business in the enterprise software system based on the micro-service architecture is further improved, and the final consistency of the data among databases of all micro-services is ensured.
Accordingly, in one embodiment, the service in a transaction center creates a first global transaction and a second global transaction in a global transaction table based on the first call logic and the second call logic in step S103, and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction, respectively, and may further include:
the first instance of the in-transaction table service creates the first global transaction in a global transaction table in a shared database based on the first call logic, and the second instance of the in-transaction table service creates the second global transaction in a global transaction table in the shared database based on the second call logic.
Fig. 3 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a third embodiment of the present application. As shown in fig. 3, on the basis of the method steps of any of the foregoing embodiments, the method may further include:
step S301, when a first instance of the in-transaction table service is interrupted, the first foreground orchestration service notifies the second instance of the in-transaction table service of the first calling logic according to an access address of the second instance of the in-transaction table service, so that the second instance of the in-transaction table service creates the first global transaction in a global transaction table in the shared database based on the first calling logic;
Step S302, when the second instance service of the in-transaction table service is interrupted, the second foreground orchestration service notifies the first instance of the in-transaction table service of the second call logic according to the access address of the first instance of the in-transaction table service, so that the first instance of the in-transaction table service creates the second global transaction in the global transaction table in the shared database based on the second call logic.
In this embodiment, the first instance service and the second instance service of the in-transaction platform service may be hot backups, once any instance service of the in-transaction platform service is interrupted, the first foreground orchestration service or the second foreground orchestration service may notify the other instance of the in-transaction platform service of the first calling logic or the second calling logic according to the access address of the other instance of the in-transaction platform service, so that even if any instance service of the in-transaction platform service is interrupted, the first foreground orchestration service or the second foreground orchestration service may not be influenced to execute respective distributed flexible transactions, and fault tolerance performance of executing the distributed flexible transactions in an enterprise software system based on a micro service architecture is further improved, thereby ensuring final consistency of data between databases of each micro service.
Fig. 4 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a fourth embodiment of the present application. As shown in fig. 4, on the basis of the method steps of the foregoing embodiment, the method may further include:
step S401, the first foreground arranging service and the second foreground arranging service acquire access addresses of a third instance of the business center service positioned at a third node;
step S402, when the first instance service of the in-transaction table service is interrupted, the first foreground orchestration service notifies the third instance of the in-transaction table service of the first calling logic according to the access address of the third instance of the in-transaction table service, so that the third instance of the in-transaction table service creates the first global transaction in the global transaction table in the shared database based on the first calling logic;
step S403, when the second instance service of the in-transaction table service is interrupted, the second foreground orchestration service notifies the third instance of the in-transaction table service of the second calling logic according to the access address of the third instance of the in-transaction table service, so that the third instance of the in-transaction table service creates the second global transaction in the global transaction table in the shared database based on the second calling logic.
In this embodiment, the number of running instances of the in-transaction platform service is deployed according to the number of foreground arrangement services, that is, the first instance service and the second instance service of the in-transaction platform service are deployed for the first foreground arrangement service and the second foreground arrangement service respectively, and meanwhile, the third instance of the in-transaction platform service is additionally run for the first instance service and the second instance service of the in-transaction platform service as a hot backup, once the first instance service or the second instance service of the in-transaction platform service is interrupted, the first foreground arrangement service or the second foreground arrangement service can notify the third instance of the in-transaction platform service of the first calling logic or the second calling logic according to the access address of the third instance of the in-transaction platform service, so that even if the first instance service and the second instance service of the in-transaction platform service are interrupted, the first foreground arrangement service or the second foreground arrangement service can not be influenced to execute the respective distributed flexible transaction, and the fault tolerance performance of each enterprise database of the distributed flexible transaction in a software system based on a micro-service architecture is further improved, and the final data base consistency between the enterprise databases is ensured.
Fig. 5 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a fifth embodiment of the present application. As shown in fig. 5, on the basis of the method steps in any one of the foregoing embodiments, in step S104, triggering the service of the middle office platform to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction according to the first exception event and the second exception event may further include:
step S501, the first instance of the service platform in the transaction sequentially executes a first forward compensation operation corresponding to the first global transaction according to the first abnormal event, and if the first forward compensation operation fails, sequentially executes a first backward compensation operation corresponding to the first global transaction;
step S502, the second instance of the service platform in the transaction sequentially executes a second forward compensation operation corresponding to the second global transaction according to the second abnormal event, and if the second forward compensation operation fails, sequentially executes a second backward compensation operation corresponding to the second global transaction.
In this embodiment, as described above, once a first exception event generated by the first foreground arrangement service executing the first global transaction and a second exception event generated by the second foreground arrangement service executing the second global transaction are captured in real time, the first foreground arrangement service and the second foreground arrangement service trigger the in-transaction platform service to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction respectively according to the first exception event and the second exception event. Taking a first compensation flow as an example, the first instance of the service platform in the transaction sequentially executes a first forward compensation operation corresponding to the first global transaction according to the first abnormal event, and if the first forward compensation operation fails, sequentially executes a first backward compensation operation corresponding to the first global transaction.
Assume a first global transaction
Figure SMS_19
Comprising->
Figure SMS_24
Three branch transactions of the data write operation interface of (2)>
Figure SMS_27
These three branch transactions are about micro-service>
Figure SMS_21
The calling order of the data write operation interface of (a) is expressed as +.>
Figure SMS_23
When executing branch transaction->
Figure SMS_26
Invoking micro-services +.>
Figure SMS_29
If an abnormality occurs in the data write operation interface of (1), the first case of the first compensation flow can be expressed as +.>
Figure SMS_18
The first case refers to the sequential +_for micro-services>
Figure SMS_22
The data write operation interface of (1) performs the forward compensation operation of retry call, the maximum retry number is +.>
Figure SMS_25
,/>
Figure SMS_28
Indicating the success of the result of the compensating operation for each branch transaction, i.e. for micro-services
Figure SMS_20
The forward compensation operation of the data write operation interface of (c) results in success within the maximum number of retries.
The second case of the first compensation procedure can be expressed as
Figure SMS_32
The second case refers to if the micro-service is +.>
Figure SMS_34
The data write operation interface of (1) performs the forward compensation operation of retry call at the maximum retry number +.>
Figure SMS_36
Afterwards, the compensation operation fails, +.>
Figure SMS_31
I.e. indicating that the result of the compensating operation for each branch transaction failed, then +.>
Figure SMS_33
Performing a reverse compensation operation, i.e. performing a micro-service +.>
Figure SMS_35
Data write operation interface->
Figure SMS_37
Reverse data operation interface constituting reverse data operation >
Figure SMS_30
. If a plurality of branch transactions exist before the branch transaction which fails to execute the forward compensation operation, the backward compensation operation is to execute the call of the backward data operation interface on the plurality of branch transactions before the branch transaction which fails to execute the forward compensation operation in reverse order until the data write generated by the branch transaction which is successfully invoked before the first global transaction is abnormal is restored to the original state before the transaction is executed. Similarly, the second compensation process is similar to the first compensation process, and will not be described in detail herein.
This exception handling manner in this embodiment is quite different from the reverse compensation operation that uses direct rollback in the distributed flexible handling based on the conventional Saga mode, which does not take into account occasional failures of micro-service interface calls caused by network jitter. According to the method, the first forward compensation operation corresponding to the first global transaction is sequentially executed according to the first abnormal event, if the first forward compensation operation fails, the first backward compensation operation corresponding to the first global transaction is sequentially executed, the second forward compensation operation corresponding to the second global transaction is sequentially executed according to the second abnormal event, and if the second forward compensation operation fails, the second backward compensation operation corresponding to the second global transaction is sequentially executed, so that transaction data abnormality caused by accidental failure of micro service interface call due to network jitter is avoided, fault tolerance performance of executing distributed flexible transactions in an enterprise software system based on a micro service architecture is further improved, and final consistency of data among databases of all micro services is ensured.
In one embodiment, the method may include adaptively adjusting the first node and the second node based on system resource occupancy of the first node and the second nodeMaximum number of retries by the first forward compensation operation and the second forward compensation operation
Figure SMS_38
. Because the retry call to the data write operation interface of the micro service occupies the system resources of the first node and the second node, the more the retry times, the larger the occupied system resources, and in the scene of high concurrency long transaction, the processing performance of the first instance and the second instance of the service of the middle platform of the transaction can be affected, therefore, the maximum retry times of the first forward compensation operation and the second forward compensation operation are adaptively adjusted based on the system resource occupancy rates of the first node and the second node>
Figure SMS_39
That is, when the system resource occupancy of the first node and the second node has a continuous trend of increasing, the maximum retry number +.>
Figure SMS_40
When the system resource occupancy rates of the first node and the second node have a continuous decreasing trend, the maximum retry number +.>
Figure SMS_41
In this way, the stability of the overall transaction data with durable service management and the performance of processing abnormal transactions in the middle-stage service can be ensured, and the fault tolerance performance of executing the distributed flexible transaction in the enterprise software system based on the micro-service architecture is further improved, so that the fault tolerance performance of executing the distributed flexible transaction by each foreground orchestration service is further promoted.
Fig. 6 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a sixth embodiment of the present application. As shown in fig. 6, on the basis of the method steps of any of the foregoing embodiments, the method may further include:
step S601, executing a distributed timing task in any node of the first node and the second node, traversing the global transaction table with a predetermined period, and obtaining a list of incomplete global transactions with a distance between time and current time greater than a predetermined time in the global transaction table;
step S602, for each incomplete global transaction in the list of incomplete global transactions, triggering a third exception event, and notifying the first instance or the second instance of the service of the middle-stage of the transaction of the third exception event according to the transaction type of each incomplete global transaction;
in step S603, the first instance or the second instance of the service platform in the transaction sequentially executes a third forward compensation operation corresponding to each incomplete global transaction according to the third abnormal event, and if the third forward compensation operation fails, sequentially executes a third backward compensation operation corresponding to each incomplete global transaction.
In this embodiment, if the first foreground orchestration service or the second foreground orchestration service itself fails to cause an interrupt exception to the executed global transaction, the first exception event or the second exception event in the foregoing embodiment may not occur, and in this case, the global transaction table may have incomplete global transactions, where these incomplete global transactions may cause a problem that the data in the databases of the micro services are eventually inconsistent. Therefore, the embodiment can execute a distributed timing task at any node of a first node running in a first instance of the service of the middle office platform and a second node running in a second instance of the service of the middle office platform, the distributed timing task traverses the global transaction table with a preset period, and a list of incomplete global transactions with the time longer than the preset time from the current time in the global transaction table is obtained; and then, triggering a third abnormal event according to each incomplete global transaction, and informing the first instance or the first instance of the service of the middle platform of the transaction according to the transaction type of each incomplete global transaction, namely the first global transaction or the second global transaction, wherein the first instance or the second instance of the service of the middle platform of the transaction sequentially executes a third forward compensation operation corresponding to each incomplete global transaction according to the third abnormal event, and if the third forward compensation operation fails, sequentially executes a third backward compensation operation corresponding to each incomplete global transaction. The manner of executing the corresponding third forward compensation operation and third backward compensation operation for each incomplete global transaction in this embodiment is similar to that of executing the first forward compensation operation and the first backward compensation operation in the foregoing embodiment, and will not be described herein.
Therefore, the embodiment can further avoid the global transaction data exception caused by single-point failure of individual foreground orchestration service, further improve the fault tolerance performance of executing distributed flexible transactions in the enterprise software system based on the micro-service architecture, and further ensure the final consistency of data among databases of all micro-services.
In one embodiment, the performing of the distributed timing task at any one of the first node and the second node may adaptively schedule the distributed timing task between the first node and the second node based on system resource occupancy of the first node and the second node. In one embodiment, the distributed timing task is performed at a randomly selected node of the first node and the second node when system resource occupancy of both the first node and the second node is less than a first threshold. In another embodiment, the distributed timing task is scheduled to be performed in the second node when the system resource occupancy of the first node is greater than a first threshold and greater than the system resource occupancy of the second node, whereas the distributed timing task is scheduled to be performed in the first node when the system resource occupancy of the second node is greater than a first threshold and greater than the system resource occupancy of the first node. Because the first node and the second node execute the distributed timing task occupy the system resources of the first node and the second node, and the processing performance of the first instance and the second instance of the service of the middle business is affected under the high-concurrency long business scene, the distributed timing task is adaptively scheduled based on the system resource occupancy rate of the first node and the second node, and the stability of the performance of managing persistent global business data and processing abnormal business of the middle business can be ensured, so that the fault tolerance performance of executing the distributed flexible business in the enterprise software system based on the micro-business architecture is further improved.
In one implementation, as in the previous embodiment, the method may also include adaptively adjusting the maximum number of retries of the third forward compensation operation based on system resource occupancy of the first node and the second node
Figure SMS_42
. The adaptive adjustment is similar to the previous embodiments and will not be described again.
Fig. 7 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to a seventh embodiment of the present application. As shown in fig. 7, on the basis of the method steps of any of the foregoing embodiments, the method may further include:
step S701, setting a transaction lock flag for data written to the data write operation interface of each micro service during the execution of the first global transaction and the second global transaction;
step S702, after the execution of the first global transaction and the second global transaction succeeds, the first foreground orchestration service and the second foreground orchestration service broadcast message notifications to each micro service, so that each micro service clears the transaction lock mark according to the message notifications.
In this embodiment, since the processing of the distributed flexible transaction requires the final consistency of the data of each micro service, the strong consistency of the data is not emphasized, and the isolation of the database of each micro service is weakened, thus in some cases, dirty reading problems between different transactions may occur, that is, intermediate data generated by one transaction may be read by other transactions before the transaction is not submitted. Therefore, in order to avoid this problem, in this embodiment, during the execution of the first global transaction and the second global transaction, a transaction lock flag may be set for data written by the data write operation interface of each micro service, specifically may be set by the data write operation interface of each micro service, once the execution of the first global transaction and the second global transaction is successful, the first foreground orchestration service and the second foreground orchestration service broadcast message notifications to each micro service, for example, may send a transaction success notification message to a designated message queue, and each micro service subscribed to the designated message queue may obtain the transaction success notification message from the designated message queue, and clear the transaction lock flag set during the execution of the transaction according to the transaction success notification message. Therefore, the problem of dirty reading of intermediate data in the database of each micro service in the execution process of the global transaction can be prevented, and the fault tolerance of executing the distributed flexible transaction in the enterprise software system based on the micro service architecture is further improved.
Fig. 8 is a partial flow diagram of a distributed flexible transaction method based on enterprise microservices according to an eighth embodiment of the present application. As shown in fig. 8, on the basis of the method steps of any of the foregoing embodiments, the method includes:
step S801, a plurality of service requests from a client are identified, the plurality of service requests correspond to a plurality of service request types, and the plurality of service requests are respectively submitted to a plurality of foreground arrangement services respectively corresponding to the plurality of service request types;
step S802, the foreground orchestration services respectively create a plurality of calling logics of a data writing operation interface for the micro services according to the service requests, the calling logics are different, and the calling logics are respectively notified to a plurality of instances of the business center platform service;
step S803, the multiple instances of the service in the transaction platform respectively create multiple global transactions in the shared global transaction table based on the multiple call logics, and notify the multiple foreground orchestration services to respectively execute the multiple global transactions;
step S804, capturing, in real time, at least one first abnormal event generated by the plurality of foreground arrangement services executing the plurality of global transactions respectively, and triggering the corresponding instance of the inter-transaction platform service to execute the first compensation process corresponding to the at least one abnormal global transaction respectively according to the at least one first abnormal event.
The embodiment extends the service request type of the service request of the client to a plurality of service request types based on any one of the foregoing embodiments, after identifying a plurality of service requests from the client, the plurality of service requests respectively correspond to a plurality of service request types, and the plurality of service requests are respectively submitted to a plurality of foreground arrangement services respectively corresponding to the plurality of service types, where each foreground arrangement service is used for a corresponding service request type, and is used for arranging a calling sequence of data write operation interfaces of a plurality of micro services involved in the service request of the client according to the corresponding service request type of the client, so as to implement a corresponding service processing flow. Subsequently, the plurality of call logics of the data write operation interfaces of the plurality of micro services created by the foreground orchestration services are respectively notified to run a plurality of instances of the transaction center service on the plurality of nodes, and the plurality of call logics are different. And respectively creating a plurality of global transactions in a shared global transaction table by a plurality of running instances of the business center platform service based on the plurality of calling logics, notifying the plurality of foreground arrangement services to respectively execute the plurality of global transactions, capturing at least one first abnormal event generated by the plurality of foreground arrangement services respectively executing the plurality of global transactions in real time, and triggering the corresponding running instance of the business center platform service to respectively execute a first compensation flow corresponding to the at least one abnormal global transaction according to the at least one first abnormal event.
In one embodiment, when any foreground orchestration service of the plurality of foreground orchestration services finds that any instance of the in-transaction platform service is interrupted, according to an access address of any other instance of the in-transaction platform service, notifying any other instance of the in-transaction platform service of the corresponding call logic, so that any other instance of the in-transaction platform service creates a corresponding global transaction in a global transaction table in a shared database according to the corresponding call logic.
In one embodiment, the triggering, according to the at least one first abnormal event, the corresponding instance of the service in the transaction center to execute the first compensation process corresponding to the at least one abnormal global transaction respectively includes:
and the corresponding instance of the business center platform service sequentially executes first forward compensation operation corresponding to the at least one abnormal global business according to the at least one first abnormal event, and if the first forward compensation operation fails, sequentially executes first backward compensation operation corresponding to the at least one abnormal global business.
In one embodiment, the method further comprises:
executing a distributed timing task at any node in a plurality of nodes respectively operated by a plurality of instances of the business center platform service, traversing the global business table in a preset period, and acquiring a list of incomplete global business with the time greater than the preset time in the global business table;
Triggering a third abnormal event for each incomplete global transaction in the list of incomplete global transactions, and notifying a corresponding instance of the transaction center service of the third abnormal event according to the transaction type of each incomplete global transaction;
and the corresponding instance of the business center platform service sequentially executes a third forward compensation operation corresponding to each incomplete global business according to the third abnormal event, and if the third forward compensation operation fails, sequentially executes a third backward compensation operation corresponding to each incomplete global business.
It should be noted that the detailed descriptions of the features in any of the foregoing embodiments are equally applicable to the present embodiment, and are incorporated into the present embodiment herein, and are not repeated herein. For example, including but not limited to, the specific implementation of the first compensation procedure, etc.
In summary, according to the embodiment of the application, aiming at a plurality of service request types in the enterprise software system based on the micro-service architecture, under the application scene of high-concurrency long transactions, even if a single foreground orchestration service fails or has a performance bottleneck, other foreground orchestration services can not be affected to execute corresponding distributed flexible transactions, meanwhile, local persistent global transaction data and abnormal transaction processing are managed by combining independently deployed transaction center platform services, the fault tolerance performance of executing the distributed flexible transactions in the enterprise software system based on the micro-service architecture is improved, and therefore the final consistency of data among databases of all micro-services is ensured.
Fig. 9 is a schematic structural diagram of an enterprise microservice-based distributed flexible transaction device according to a first embodiment of the present application. As shown in fig. 9, the distributed flexible transaction processing device based on the enterprise micro service according to the embodiment of the present application may include the following units:
a request identifying unit 901, configured to identify whether a service request type of a client is a first service request or a second service request, so as to submit the first service request to a first foreground orchestration service, and submit the second service request to a second foreground orchestration service;
a foreground orchestration unit 902, configured to create, by the first foreground orchestration service, a first call logic for data write operation interfaces of a plurality of micro services according to the first service request, create, by the second foreground orchestration service, a second call logic different from the first call logic for data write operation interfaces of the plurality of micro services according to the second service request, and notify the transaction center service of the first call logic and the second call logic;
a transaction creation unit 903, configured to create a first global transaction and a second global transaction in a global transaction table by using the transaction center service based on the first call logic and the second call logic, and notify the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction, respectively;
The exception processing unit 904 is configured to capture, in real time, a first exception event generated by the first foreground arrangement service executing the first global transaction and a second exception event generated by the second foreground arrangement service executing the second global transaction, and trigger the in-transaction platform service to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction respectively according to the first exception event and the second exception event.
The distributed flexible transaction processing device in the embodiment of the application submits a first service request to a first foreground arrangement service and submits a second service request to a second foreground arrangement service respectively by identifying the service request type of a client, the first foreground arrangement service creates first calling logic of data write operation interfaces of a plurality of micro services according to the first service request, the second foreground arrangement service creates second calling logic which is different from the first calling logic and is used for the data write operation interfaces of the plurality of micro services according to the second service request, then a transaction center service creates a first global transaction and a second global transaction in a global transaction table based on the first calling logic and the second calling logic, and notifies the first foreground arrangement service and the second foreground arrangement service to execute the first global transaction and the second global transaction respectively, simultaneously captures a first abnormal event generated by the first foreground arrangement service executing the first global transaction and a second abnormal event generated by the second foreground arrangement service executing the second global transaction in real time, and triggers a transaction and a second abnormal event generated by the second foreground arrangement service executing the second global transaction and a corresponding abnormal transaction and the second abnormal transaction and the first abnormal transaction executing the second abnormal transaction and the abnormal transaction in the first global process and the second global transaction. Therefore, aiming at the enterprise software system based on the micro-service architecture, even if a fault or performance bottleneck occurs to an individual foreground arrangement service under the application scene of a high-concurrency long transaction, other foreground arrangement services can not be influenced to execute corresponding distributed flexible transactions, meanwhile, the locally persistent global transaction data and abnormal transaction processing are managed by combining with independently deployed business center service, the fault tolerance performance of executing the distributed flexible transactions in the enterprise software system based on the micro-service architecture is further improved, and the final consistency of data among databases of all micro-services is ensured.
In some embodiments, as shown in fig. 10, based on the foregoing example, the foreground orchestration unit 902 may include:
an address obtaining unit 1001, configured to obtain access addresses of a first instance of the in-transaction table service located at a first node and a second instance of the in-transaction table service located at a second node by using the first foreground orchestration service and the second foreground orchestration service;
a first request unit 1002, configured to notify, by the first foreground orchestration service, the first instance of the in-transaction platform service according to an access address of the first instance of the in-transaction platform service;
a second request unit 1003, configured to notify, by the second foreground orchestration service, the second instance of the in-transaction platform service according to an access address of the second instance of the in-transaction platform service.
Accordingly, in one embodiment, the transaction creation unit 903 may be further configured to: the first instance of the in-transaction table service creates the first global transaction in a global transaction table in a shared database based on the first call logic, and the second instance of the in-transaction table service creates the second global transaction in a global transaction table in the shared database based on the second call logic.
In some implementations, based on the foregoing embodiment, the first request unit 1002 is further configured to: when a first instance of the in-transaction table service is interrupted, the first foreground orchestration service informs a second instance of the in-transaction table service of the first call logic according to an access address of the second instance of the in-transaction table service, so that the second instance of the in-transaction table service creates the first global transaction in a global transaction table in the shared database based on the first call logic;
the second requesting unit 1003 is further configured to: when the second instance of the in-transaction table service is interrupted, the second foreground orchestration service notifies the first instance of the in-transaction table service of the second call logic according to the access address of the first instance of the in-transaction table service, so that the first instance of the in-transaction table service creates the second global transaction in a global transaction table in the shared database based on the second call logic.
In some embodiments, on the basis of the foregoing embodiment, the address obtaining unit 1001 is further configured to: the first foreground orchestration service and the second foreground orchestration service obtain access addresses of a third instance of the in-transaction platform service at a third node.
The first request unit 1002 is further configured to: when the first instance of the in-transaction table service is interrupted, the first foreground orchestration service informs the third instance of the in-transaction table service of the first call logic according to the access address of the third instance of the in-transaction table service, so that the third instance of the in-transaction table service creates the first global transaction in a global transaction table in the shared database based on the first call logic.
The second requesting unit 1003 is further configured to: when the second instance of the in-transaction table service is interrupted, the second foreground orchestration service notifies the third instance of the in-transaction table service of the second call logic according to the access address of the third instance of the in-transaction table service, so that the third instance of the in-transaction table service creates the second global transaction in a global transaction table in the shared database based on the second call logic.
In some embodiments, as shown in fig. 11, on the basis of any one of the foregoing embodiments, the exception processing unit 904 may further include:
a first compensation unit 1101, configured to sequentially perform, by using a first instance of the service in transaction center, a first forward compensation operation corresponding to the first global transaction according to the first exception event, and if the first forward compensation operation fails, sequentially perform a first backward compensation operation corresponding to the first global transaction;
And a second compensation unit 1102, configured to sequentially perform, according to the second exception event, a second forward compensation operation corresponding to the second global transaction by using a second instance of the service in transaction, and if the second forward compensation operation fails, sequentially perform a second backward compensation operation corresponding to the second global transaction.
In one embodiment, the first compensation unit 1101 and the second compensation unit 1102 may adaptively adjust the maximum retry times performed by the first forward compensation operation and the second forward compensation operation based on the system resource occupancy rates of the first node and the second node, that is, when the system resource occupancy rates of the first node and the second node have a continuous trend of increasing, the maximum retry times may be reduced, and when the system resource occupancy rates of the first node and the second node have a continuous trend of decreasing, the maximum retry times may be increased, so that the performance stability of the table service management in the transaction for persistence global transaction data and processing abnormal transactions may be ensured, thereby further improving the fault tolerance performance of executing the distributed flexible transaction in the enterprise software system based on the micro service architecture.
In some embodiments, as shown in fig. 12, on the basis of any of the foregoing embodiments, the apparatus may further include:
a timing task unit 1201, configured to perform a distributed timing task in any one of the first node and the second node, traverse the global transaction table with a predetermined period, and obtain a list of incomplete global transactions in which a distance between a time and a current time is greater than a predetermined time in the global transaction table;
an exception notification unit 1202, configured to trigger a third exception event for each incomplete global transaction in the list of incomplete global transactions, and notify, according to a transaction type of each incomplete global transaction, a first instance or a second instance of a service of the middle-stage of the transaction of the third exception event;
and a third compensation unit 1203, configured to sequentially execute, by using the first instance or the second instance of the service in the middle-transaction platform, a third forward compensation operation corresponding to each incomplete global transaction according to the third exception event, and if the third forward compensation operation fails, sequentially execute a third backward compensation operation corresponding to each incomplete global transaction.
In one embodiment, the timing task unit 1201 performs a distributed timing task at any one of the first node and the second node, and may adaptively schedule the distributed timing task between the first node and the second node based on system resource occupancy of the first node and the second node. In one embodiment, the distributed timing task is performed at a randomly selected node of the first node and the second node when system resource occupancy of both the first node and the second node is less than a first threshold. In another embodiment, the distributed timing task is scheduled to be performed in the second node when the system resource occupancy of the first node is greater than a first threshold and greater than the system resource occupancy of the second node, whereas the distributed timing task is scheduled to be performed in the first node when the system resource occupancy of the second node is greater than a first threshold and greater than the system resource occupancy of the first node. Therefore, the service management persistence global transaction data and the abnormal transaction processing performance stability of the transaction center platform can be ensured, and the fault tolerance performance of executing the distributed flexible transaction in the enterprise software system based on the micro-service architecture is further improved.
In one implementation, as described in the previous embodiment, the third compensation unit 1203 may adaptively adjust the maximum number of retries of the third forward compensation operation based on the system resource occupancy of the first node and the second node. The adaptive adjustment is similar to the previous embodiments and will not be described again.
In some embodiments, as shown in fig. 13, on the basis of any of the foregoing embodiments, the apparatus may further include:
a transaction lock setting unit 1301, configured to set a transaction lock flag for data written by a data write operation interface calling each micro service during execution of the first global transaction and the second global transaction;
the transaction lock clearing unit 1302 is configured to, after the execution of the first global transaction and the second global transaction succeeds, broadcast a message notification to each micro service by the first foreground orchestration service and the second foreground orchestration service, so that each micro service clears the transaction lock flag according to the message notification.
Fig. 14 is a schematic structural diagram of an enterprise microservice-based distributed flexible transaction device according to a sixth embodiment of the present application. As shown in fig. 14, the distributed flexible transaction processing device based on the enterprise micro service according to the embodiment of the present application may include the following units:
A request identifying unit 1401, configured to identify a plurality of service requests from a client, where the plurality of service requests correspond to a plurality of service request types, and respectively submit the plurality of service requests to a plurality of foreground orchestration services corresponding to the plurality of service request types;
a foreground orchestration unit 1402, configured to create, according to the plurality of service requests, a plurality of call logics for data write operation interfaces of a plurality of microservices, where the plurality of call logics are different from each other, and notify, respectively, a plurality of instances of a transaction center service of the plurality of call logics;
a transaction creation unit 1403, configured to create a plurality of global transactions in a shared global transaction table based on the plurality of call logics respectively by a plurality of instances of the transaction center service, and notify the plurality of foreground orchestration services to execute the plurality of global transactions respectively;
the exception processing unit 1404 is configured to capture, in real time, at least one first exception event generated by the plurality of foreground orchestration services executing the plurality of global transactions respectively, and trigger, according to the at least one first exception event, a corresponding instance of the in-transaction platform service to execute a first compensation flow corresponding to the at least one abnormal global transaction respectively.
It should be noted that, as those skilled in the art can understand, the different embodiments described in the method embodiments of the present application, the explanation and the achieved technical effects thereof are also applicable to the device embodiments of the present application, and are not repeated herein.
Further, the embodiment of the application also provides an electronic device, which may include: a processor and a memory. Wherein the memory stores computer program instructions that the processor may invoke in the memory to perform all or part of the steps of the methods described in any of the embodiments of the present application. The computer program instructions in the memory described above may be embodied in the form of software functional units and may be stored in a computer-readable storage medium when sold or used as a stand-alone product.
Further, the present application also provides a computer program product comprising a non-transitory computer readable storage medium storing a computer program capable of performing all or part of the steps of the method of any of the embodiments of the present application when the computer readable storage medium is connected to a computer device, the computer program being executed by one or more processors of the computer device.
Further, the present application also provides a non-transitory computer readable storage medium having stored thereon a computer program executable by one or more processors to perform all or part of the steps of the methods described in any of the embodiments of the present application.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments of the present application may be implemented by software or by a combination of software and necessary general hardware platforms, and of course may be implemented by hardware functions. Based on such understanding, the technical solutions of the present application may be embodied in essence or in a part contributing to the prior art in the form of a software product stored in a storage medium, including several instructions for causing a computer device, including for example but not limited to a personal computer, a server, or a network device, to perform all or part of the steps of the method of any of the embodiments of the present application. The aforementioned storage medium may include: a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic or optical disk, or other various media capable of storing computer program code.
The above describes exemplary embodiments of the present application, it should be understood that the above-described exemplary embodiments are not limiting, but rather illustrative, and the scope of the present application is not limited thereto. It will be appreciated that modifications and variations to the embodiments of the present application may be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and variations are intended to be within the scope of the present application.

Claims (10)

1. A distributed flexible transaction method based on enterprise microservices, comprising:
identifying whether the service request type of the client is a first service request or a second service request, submitting the first service request to a first foreground orchestration service, and submitting the second service request to a second foreground orchestration service;
the first foreground orchestration service creates a first calling logic of a data writing operation interface of a plurality of micro services according to the first service request, and the second foreground orchestration service creates a second calling logic different from the first calling logic of the data writing operation interface of the plurality of micro services according to the second service request, and notifies the transaction center service of the first calling logic and the second calling logic;
The transaction center service creates a first global transaction and a second global transaction in a global transaction table based on the first calling logic and the second calling logic, and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction respectively;
and capturing a first abnormal event generated by the first foreground arrangement service executing the first global transaction and a second abnormal event generated by the second foreground arrangement service executing the second global transaction in real time, and triggering the business-in-transaction service to execute a first compensation flow and a second compensation flow corresponding to the first global transaction and the second global transaction respectively according to the first abnormal event and the second abnormal event.
2. The enterprise microservice-based distributed flexible transaction method of claim 1 wherein notifying the transaction center service of the first and second call logic comprises:
the first foreground orchestration service and the second foreground orchestration service acquire access addresses of a first instance of the in-transaction platform service at a first node and a first instance of the in-transaction platform service at a second node;
The first foreground orchestration service informs the first instance of the business center platform service of the first calling logic according to the access address of the first instance of the business center platform service;
the second foreground orchestration service notifies the second instance of the in-transaction platform service of the second call logic according to the access address of the second instance of the in-transaction platform service.
3. The enterprise microservice-based distributed flexible transaction processing method of claim 2 wherein the transaction center service creates a first global transaction and a second global transaction in a global transaction table based on the first call logic and the second call logic and notifies the first foreground orchestration service and the second foreground orchestration service to execute the first global transaction and the second global transaction, respectively, comprising:
the first instance of the in-transaction table service creates the first global transaction in a global transaction table in a shared database based on the first call logic, and the second instance of the in-transaction table service creates the second global transaction in a global transaction table in the shared database based on the second call logic.
4. The enterprise microservice-based distributed flexible transaction method of claim 3 further comprising:
When the first instance service is interrupted, the first foreground orchestration service informs the second instance of the first calling logic according to the access address of the second instance, so that the second instance creates the first global transaction in a global transaction table in the shared database based on the first calling logic;
when the second instance services an interrupt, the second foreground orchestration service notifies the first instance of the second call logic according to the access address of the first instance, so that the first instance creates the second global transaction in a global transaction table in the shared database based on the second call logic.
5. The enterprise microservice-based distributed flexible transaction method of claim 3 further comprising:
the first foreground orchestration service and the second foreground orchestration service acquire access addresses of third instances of the in-transaction platform service at a third node;
when the first instance service is interrupted, the first foreground orchestration service informs the third instance of the first calling logic according to the access address of the third instance, so that the third instance creates the first global transaction in a global transaction table in the shared database based on the first calling logic;
When the second instance services an interrupt, the second foreground orchestration service notifies the third instance of the second call logic according to the access address of the third instance, so that the third instance creates the second global transaction in a global transaction table in the shared database based on the second call logic.
6. The method for processing distributed flexible transaction based on enterprise micro services according to claim 4 or 5, wherein triggering the transaction center service to execute a first compensation process and a second compensation process corresponding to the first global transaction and the second global transaction according to the first exception event and the second exception event, respectively, comprises:
the first instance sequentially executes first forward compensation operation corresponding to the first global transaction according to the first abnormal event, and if the first forward compensation operation fails, sequentially executes first backward compensation operation corresponding to the first global transaction;
and the second instance sequentially executes second forward compensation operation corresponding to the second global transaction according to the second abnormal event, and if the second forward compensation operation fails, sequentially executes second backward compensation operation corresponding to the second global transaction.
7. The enterprise microservice-based distributed flexible transaction method of claim 6 further comprising:
executing a distributed timing task in any node of the first node and the second node, traversing the global transaction table in a preset period, and acquiring a list of incomplete global transactions with the time greater than a preset time from the current time in the global transaction table;
triggering a third exception event for each incomplete global transaction in the list of incomplete global transactions, and notifying the first instance or the second instance of the third exception event according to the transaction type of each incomplete global transaction;
and the first instance or the second instance sequentially executes a third forward compensation operation corresponding to each incomplete global transaction according to the third abnormal event, and if the third forward compensation operation fails, sequentially executes a third backward compensation operation corresponding to each incomplete global transaction.
8. The enterprise microservice-based distributed flexible transaction method of claim 7 further comprising:
And adjusting the maximum retry times of the first forward compensation operation, the second forward compensation operation and the third forward compensation operation in an adaptive manner based on the system resource occupancy rate of the first node and the second node, and/or scheduling the distributed timing task in an adaptive manner between the first node and the second node based on the system resource occupancy rate of the first node and the second node.
9. The enterprise microservice-based distributed flexible transaction method of claim 8 further comprising:
setting transaction lock marks for data written by a data write operation interface for calling each micro service in the execution process of the first global transaction and the second global transaction;
after the execution of the first global transaction and the second global transaction is successful, the first foreground orchestration service and the second foreground orchestration service broadcast message notifications to each micro service, so that each micro service clears the transaction lock mark according to the message notifications.
10. A distributed flexible transaction method based on enterprise microservices, comprising:
identifying a plurality of service requests from a client, wherein the plurality of service requests correspond to a plurality of service request types, and respectively submitting the plurality of service requests to a plurality of foreground arrangement services respectively corresponding to the plurality of service request types;
The foreground orchestration services respectively create a plurality of calling logics of the data writing operation interfaces of the micro services according to the service requests, the calling logics are different, and the calling logics are respectively notified to a plurality of instances of the business center platform service;
a plurality of instances of the business center platform service respectively establish a plurality of global business in a shared global business table based on the plurality of calling logics, and inform the plurality of foreground orchestration services to respectively execute the plurality of global business;
capturing at least one first abnormal event generated by the foreground arrangement services respectively executing the global transactions in real time, and triggering the corresponding instance of the service in the transaction to respectively execute a first compensation flow corresponding to the abnormal global transaction according to the at least one first abnormal event.
CN202310233438.3A 2023-03-13 2023-03-13 Distributed flexible transaction processing method and device based on enterprise microservice Active CN116069868B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310233438.3A CN116069868B (en) 2023-03-13 2023-03-13 Distributed flexible transaction processing method and device based on enterprise microservice

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310233438.3A CN116069868B (en) 2023-03-13 2023-03-13 Distributed flexible transaction processing method and device based on enterprise microservice

Publications (2)

Publication Number Publication Date
CN116069868A true CN116069868A (en) 2023-05-05
CN116069868B CN116069868B (en) 2023-06-09

Family

ID=86175162

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310233438.3A Active CN116069868B (en) 2023-03-13 2023-03-13 Distributed flexible transaction processing method and device based on enterprise microservice

Country Status (1)

Country Link
CN (1) CN116069868B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109697110A (en) * 2017-10-20 2019-04-30 阿里巴巴集团控股有限公司 Transaction coordination processing system, method, apparatus and electronic equipment
CN112835688A (en) * 2021-02-01 2021-05-25 北京星网锐捷网络技术有限公司 Distributed transaction processing method, device and storage medium
CN115145997A (en) * 2021-03-30 2022-10-04 华为云计算技术有限公司 Distributed transaction implementation method and distributed system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109697110A (en) * 2017-10-20 2019-04-30 阿里巴巴集团控股有限公司 Transaction coordination processing system, method, apparatus and electronic equipment
CN112835688A (en) * 2021-02-01 2021-05-25 北京星网锐捷网络技术有限公司 Distributed transaction processing method, device and storage medium
CN115145997A (en) * 2021-03-30 2022-10-04 华为云计算技术有限公司 Distributed transaction implementation method and distributed system

Also Published As

Publication number Publication date
CN116069868B (en) 2023-06-09

Similar Documents

Publication Publication Date Title
JP4637842B2 (en) Fast application notification in clustered computing systems
US8589732B2 (en) Consistent messaging with replication
JP5695324B2 (en) Method, system, and computer readable recording medium for determining a major group in a split brain situation
US20120011100A1 (en) Snapshot acquisition processing technique
US8843581B2 (en) Live object pattern for use with a distributed cache
KR20140138670A (en) Systems and methods for supporting transaction recovery based on a strict ordering of two-phase commit calls
CN112597249A (en) Synchronous distribution and storage method and system for service data
US20160277152A1 (en) Method and system for robust message retransmission
CA3041211C (en) Utilizing nonce table to resolve concurrent blockchain transaction failure
US10250519B2 (en) System and method for supporting a distributed data structure in a distributed data grid
US20080307429A1 (en) Apparatus, system, and method for autonomously maintaining a single system image in a parallel systems complex
US20060282524A1 (en) Apparatus, system, and method for facilitating communication between an enterprise information system and a client
US11522966B2 (en) Methods, devices and systems for non-disruptive upgrades to a replicated state machine in a distributed computing environment
CN112822091A (en) Message processing method and device
CN115964198B (en) Distributed flexible transaction processing method and device based on long transaction
US8725708B2 (en) Resolving a unit of work
CN116069868B (en) Distributed flexible transaction processing method and device based on enterprise microservice
CN111143041A (en) Data consistency method, distributed coordinator and central coordinator
CN107045426B (en) Multi-copy reading method and system
CN114860505A (en) Object storage data asynchronous backup method and system
CN110502460B (en) Data processing method and node
CN113254159B (en) Migration method and device of stateful service, computer equipment and storage medium
CN116662040B (en) Message distribution method and device, electronic equipment and storage medium
WO2015179092A1 (en) System and method for supporting a distributed data structure in a distributed data grid
TWI421677B (en) A transaction processing method for a cluster

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