Movatterモバイル変換


[0]ホーム

URL:


CN106874130A - The processing method of distributed transaction in a kind of micro services framework - Google Patents

The processing method of distributed transaction in a kind of micro services framework
Download PDF

Info

Publication number
CN106874130A
CN106874130ACN201710065665.4ACN201710065665ACN106874130ACN 106874130 ACN106874130 ACN 106874130ACN 201710065665 ACN201710065665 ACN 201710065665ACN 106874130 ACN106874130 ACN 106874130A
Authority
CN
China
Prior art keywords
distributed transaction
module
transaction
processing method
micro services
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.)
Pending
Application number
CN201710065665.4A
Other languages
Chinese (zh)
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.)
More Information Technology (beijing) Co Ltd
Original Assignee
More Information Technology (beijing) 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 More Information Technology (beijing) Co LtdfiledCriticalMore Information Technology (beijing) Co Ltd
Priority to CN201710065665.4ApriorityCriticalpatent/CN106874130A/en
Publication of CN106874130ApublicationCriticalpatent/CN106874130A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

The present invention relates to a kind of processing method of distributed transaction in micro services framework, it includes:Open the unit affairs of DB examples;DB requests are performed, DB is updated;Request Real-time Transaction module;Whether Real-time Transaction module is asked successfully to judge, if not asking successfully, to trigger rollback, the transaction rollback trigger event that throw exception or other DB drive;If asking successfully, to be submitted to.The present invention efficiently utilizes the unit Two-phase commitment characteristic of DB drive modules, a kind of topological structure using service call is innovatively proposed to realize the mode of distributed transaction, can serve as the solution of real-time consistency, it is also possible to realize final consistency affairs.The present invention only can just realize transaction guarantee by an interaction, be especially suitable for the distributed module within three and realize affair mechanism.The present invention can conclusively show the treatment rank of distributed transaction by topology design, and series connection is realtime uniform, and parallel connection is final consistent.

Description

The processing method of distributed transaction in a kind of micro services framework
Technical field
The invention belongs to computer realm, and in particular to the processing method of distributed transaction in a kind of micro services framework.
Background technology
Micro services are a new architecture design thought of rising in recent years.SOA is compared, micro services enter one by by functionStep distributed component, with good autgmentability and sustainable exploitation ability.Micro services refer to that exploitation one is single small-sizedBut there is the service of business function, each service has treatment and the light weight communication mechanism of oneself, can be deployed in single or multipleOn server.Micro services also refer to a kind of loose coupling, have the Service-Oriented Architecture Based of certain bounded context.That is, such asReally each service will be changed simultaneously, then they are not just micro services, because they are tightly coupled together;If necessary to graspThe too many context use condition of one service, then it is exactly one service on context border.The mesh of micro servicesBe it is effective split application, realize agile development and deployment.
If SOA can avoid distributed transaction problem by design, because service fractionation granularity is thinner, with SOA notWith micro services become indispensable for the requirement of distributed transaction.Such as one on-line payment process, SOA mayAn order subsystem for encapsulating payment function, voluntarily safeguarding stock is split out, commodity amount, modification order shape will be updatedThe operations such as state, record payment expense are completed with unit affairs.But for micro services framework, it is likely that due to autgmentabilityConsider, split into payment module, order module, commodity SKU management modules.When successfully notice arrival is paid, it is necessary in real timeUpdate the DB data of multiple modules.
The content of the invention
In order to solve the above mentioned problem of prior art presence, the invention provides distributed transaction in a kind of micro services frameworkProcessing method.
The technical solution adopted in the present invention is:The processing method of distributed transaction in a kind of micro services framework, it includesFollowing steps:Open the unit affairs of DB examples;DB requests are performed, DB is updated;Request Real-time Transaction module;To Real-time Transaction mouldWhether block asks successfully to be judged that, if not asking successfully, to trigger rollback, the affairs that throw exception or other DB drive are returnedRolling trigger event;If asking successfully, to be submitted to.
Further, in the step of request Real-time Transaction module, at most carry out a Real-time Transaction module and call, such asFruit has multiple Real-time Transaction modules, then carry out series connection and call.
Further, it is described whether to ask Real-time Transaction module the step of successfully judging, if asked successfully,Before being submitted to, also including insertion final consistency processing module the step of.
Further, it is described whether to ask Real-time Transaction module the step of successfully judging, if asked successfully,Before being submitted to, also including insertion final consistency processing module the step of.
Further, the processing method of the distributed transaction processes distributed thing using the topological structure that module is calledBusiness.
Further, the topological structure called using module processes distributed transaction core design rule bagInclude:At most once the RPC of modification type is called one module, and the RPC of modification type is called and need not be provided rollback interface.
Further, if the RPC that single process has repeatedly modification type is called, while ensureing real-time the one of entirety againCause property, need to call series connection by RPC.
Further, the topological structure called using module is also wrapped processing distributed transaction core design ruleInclude:RPC interface interchanges are encapsulated in inside DB transaction process methods, are placed on behind DB affairs.
Further, after the RPC interface interchanges failure or return fail, throw exception triggering DB transaction rollbacks.
Further, if the RPC in flow calls receiving final consistent, queue is inserted into, but must putAfter all call flows terminate.
Due to using above technical scheme, beneficial effects of the present invention to be:The present invention efficiently utilizes DB drive modulesUnit Two-phase commitment characteristic, a kind of topological structure using service call is innovatively proposed to realize distributed transactionMode, can serve as the solution of real-time consistency.Meanwhile, the program has good ductility, is tied by another topologyStructure, it is also possible to realize final consistency affairs.The present invention only can just realize transaction guarantee by an interaction, fit very muchClose the distributed module within three and realize affair mechanism.The present invention can conclusively show distributed transaction by topology designTreatment rank, series connection is realtime uniform, and parallel connection is final consistent.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existingThe accompanying drawing to be used needed for having technology description is briefly described, it should be apparent that, drawings in the following description are only thisSome embodiments of invention, for those of ordinary skill in the art, on the premise of not paying creative work, can be withOther accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is typical service call topological structure schematic diagram;
Fig. 2 is the flow chart of the processing method of distributed transaction in micro services framework of the present invention;
Fig. 3 is the instruction execution sequence schematic diagram of each distributed transaction module.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, technical scheme will be carried out belowDetailed description.Obviously, described embodiment is only a part of embodiment of the invention, rather than whole embodiments.BaseEmbodiment in the present invention, those of ordinary skill in the art are resulting on the premise of creative work is not made to be ownedOther embodiment, belongs to the scope that the present invention is protected.
Current micro services framework has worldwide been widely used as a kind of new design.But its difficult pointOne of, it is affairs problem caused by distributed deployment.
Distributing real time system is related to multiple databases for being distributed in different places, but operation to database must be wholeIt is submitted or rollback.As long as failing when any database is operated, all databases for participating in affairs are required for rollback.It is distributedIt is consistent with final that affairs can be divided into realtime uniform.
The current general real-time consistency solution of industry has the scheme submitted to based on Two-phase commitment or three stages.TwoRealization such as Atomikos storehouses (realizing JTA), JOTM, LIXA that stage submits to.Two-phase commitment scheme is applied in practiceCompare wide.But distributed scene is different from unit scene, and process time is double, an interaction is divided into originallyPrepare and commit are interacted twice, poor performance and have shortcoming:Coordinator delays and participant can be caused synchronously to hinder in the case of machinePlug, need to increase coordinator it is hot standby and record undo and redo daily records.When coordinator and participant delay machine simultaneously, problem is without solution.
In a distributed manner as a example by Two-phase commitment, after receiving a transactions requests, coordinator initiates to coordinate request for the first timePrepare, it is desirable to the corresponding sentence of whole participant's pre-executions.When all feeding back successfully, coordinator will initiate commit pleaseAsk, it is desirable to which whole participants submit affairs to.When two steps all after the completion of, issued transaction complete.Lost when the first step has participant to feed backWhen losing, coordinator initiates rollback requests, it is desirable to whole participant's rollback affairs.
In order to solve the problems, such as Two-phase commitment, XA proposes three stages submission scheme.Wherein, XA is that X/Open DTP determineInterface specification (i.e. interface function) between the task manager and database of justice.Three stages increased once for ratificationCanPrepare, and increase the overtime obstructing problem to solve Two-phase commitment, but three stages submitted the interactivity of scheme toCan be worse.
The main flow of the solution of current final consistency is achieved in that, based on the message queue that can be retried, consumer willPeriodically retry until the system of all participants finally realizes that data are consistent.
As shown in figure 1, the invention provides a kind of processing method of distributed transaction in micro services framework, it uses moduleThe topological structure that calls processes distributed transaction, and it specifically includes following steps:
1) the unit affairs of DB (DataBase, database) example are opened.
2) DB requests are performed, DB is updated.
3) Real-time Transaction module is asked.
4) to step 3) whether ask successfully to judge, if not asking successfully, to trigger rollback, throw exception or itsThe transaction rollback trigger event that his DB drives;If asking successfully, to be submitted to.
Above-mentioned steps 3) in, at most carry out a Real-time Transaction module and call, if multiple Real-time Transaction modules, then enterRow series connection is called.
Above-mentioned steps 4) in, if asked successfully, before being submitted to, also including insertion final consistency processing moduleThe step of.
Solving distributed transaction the very corn of a subject design rule with topological mode is:
(1) module at most once modification type RPC (Remote Procedure Call Protocol, farJourney invocation of procedure agreement) call.The RPC of modification type is called and need not be provided rollback interface.
(2) if the RPC that single process has repeatedly modification type is called, while ensureing overall real-time consistency again, needRPC is called into series connection.
(3) RPC interface interchanges are encapsulated in inside DB transaction process methods, are placed on behind DB affairs.
(4) after the failure of RPC interface interchanges or return fail, throw exception triggering DB transaction rollbacks.
(5) if some of flow RPC is called can receive final consistent (such as settling accounts the background modules such as reconciliation), canTo insert queue.But must necessarily be placed in after all call flows terminate.
Illustrate below and the processing method of distributed transaction in micro services framework of the present invention is illustrated.
Call relation between micro services is organized into topological diagram, represents that affairs are real-time consistencies or final with topological diagramUniformity.As shown in figure 1, real-time consistency processing module includes distributed transaction modules A, distributed transaction module B and distributionFormula transaction module C.Final consistency processing module includes distributed transaction module D and distributed transaction module E.Each affairs mouldBlock includes that DB affairs and RPC are asked.
It is called according to mode as shown in Figure 2, the transactional guarantees driven using DB entirely process the transactional of logic.Distributed transaction modules A needs modification table a (real-time consistency), distributed transaction module B to need modification table b (realtime uniformsProperty), distributed transaction module C needs modification table c (real-time consistency), distributed transaction module D to need modification table d (finalCause property), distributed transaction module E needs modification table e (final consistency).
Distributed transaction modules A, distributed transaction module B and distributed transaction module C need to ensure realtime uniform, distributionFormula transaction module D needs to ensure final consistent with distributed transaction module E.In topology design, according to principle (1) and principle(2) order will be called to be adjusted.Distributed transaction modules A accesses distributed transaction module B, and distributed transaction module B is accessedDistributed transaction module C.According to principle (5), the access of distributed transaction module D and distributed transaction module E is placed on finally.
As shown in figure 3, each distributed transaction module execute instruction flow is:
If distributed transaction modules A, distributed transaction module B and distributed transaction module C overall operations are normal, divideCloth affairs are submitted to successfully.Then distribution of notifications formula transaction module D and distributed transaction module E, makes its final process complete i.e.Can.
Assuming that fail when distributed transaction module performs itself DB in-stockroom operation, then distributed transaction module C rollback the machineAffairs, are then back to mono- error code of distributed transaction module B.Distributed transaction module B receives distributed transaction module C'sReturn, be the discovery that mistake, also rollback the machine affairs;Distributed transaction modules A takes the return of distributed transaction module B, also returnsRolling the machine affairs, reach overall rollback.
Under extreme case, if distributed transaction module C runs succeeded, but fail when returning to distributed transaction module B(such as distributed transaction module C performs overlong time, causes TCP to connect and disconnects, or network jitter causes connection to disconnect), then canGo wrong.The database of distributed transaction module C cannot rollback.At this point it is possible to pass through to increase cache make distributed transaction mouldThe access of block C has idempotence, is that distributed transaction module B to distributed transaction module C increases time-out is retried.
The invention provides a kind of processing method of distributed transaction in micro services framework, the process efficiently utilizes DBThe unit Two-phase commitment characteristic of drive module, innovatively proposes a kind of topological structure using service call to realize distributionThe mode of formula affairs, can serve as the solution of real-time consistency.Meanwhile, the program has good ductility, by anotherPlant topological structure, it is also possible to realize final consistency affairs.The present invention only can just realize that affairs are protected by an interactionCard, is especially suitable for the distributed module within three and realizes affair mechanism.The present invention can be conclusivelyed show by topology designThe treatment rank of distributed transaction, series connection is realtime uniform, and parallel connection is final consistent.
The above, specific embodiment only of the invention, but protection scope of the present invention is not limited thereto, and it is anyThose familiar with the art the invention discloses technical scope in, change or replacement can be readily occurred in, should all containCover within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.

Claims (10)

CN201710065665.4A2017-02-062017-02-06The processing method of distributed transaction in a kind of micro services frameworkPendingCN106874130A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201710065665.4ACN106874130A (en)2017-02-062017-02-06The processing method of distributed transaction in a kind of micro services framework

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201710065665.4ACN106874130A (en)2017-02-062017-02-06The processing method of distributed transaction in a kind of micro services framework

Publications (1)

Publication NumberPublication Date
CN106874130Atrue CN106874130A (en)2017-06-20

Family

ID=59166651

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201710065665.4APendingCN106874130A (en)2017-02-062017-02-06The processing method of distributed transaction in a kind of micro services framework

Country Status (1)

CountryLink
CN (1)CN106874130A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN107528912A (en)*2017-09-112017-12-29金蝶软件(中国)有限公司A kind of automatic method, system and relevant apparatus for realizing distributing real time system
CN107943601A (en)*2017-11-222018-04-20国云科技股份有限公司 A method to balance the consistency and reliability of non-core business data under the microservice architecture
CN108153598A (en)*2017-12-252018-06-12东软集团股份有限公司 Data consistency method and device based on microservice architecture
CN108415758A (en)*2018-03-272018-08-17深圳市买买提信息科技有限公司Distributed transaction coordination approach and device
CN108804238A (en)*2018-03-292018-11-13中国工程物理研究院计算机应用研究所A kind of flexible bus communication means based on remote procedure call
CN110764930A (en)*2019-10-212020-02-07中国民航信息网络股份有限公司Request or response processing method and device based on message mode
CN111708616A (en)*2020-06-112020-09-25浙江网新恒天软件有限公司Processing method of single data source distributed transaction under micro-service architecture
CN113055465A (en)*2021-03-112021-06-29南京大学Micro-service dynamic updating method supporting transaction consistency
CN114237833A (en)*2021-12-162022-03-25富盛科技股份有限公司 A high-performance real-time consistent microservice execution method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102073540A (en)*2010-12-152011-05-25北京新媒传信科技有限公司Distributed affair submitting method and device thereof
CN105824842A (en)*2015-01-072016-08-03阿里巴巴集团控股有限公司Distributed transaction processing method and system
CN105988862A (en)*2015-02-042016-10-05阿里巴巴集团控股有限公司Distributed transaction processing method and device
CN106168915A (en)*2016-04-252016-11-30云南电网有限责任公司昆明供电局Distributed system architecture data process consistency ensuring method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102073540A (en)*2010-12-152011-05-25北京新媒传信科技有限公司Distributed affair submitting method and device thereof
CN105824842A (en)*2015-01-072016-08-03阿里巴巴集团控股有限公司Distributed transaction processing method and system
CN105988862A (en)*2015-02-042016-10-05阿里巴巴集团控股有限公司Distributed transaction processing method and device
CN106168915A (en)*2016-04-252016-11-30云南电网有限责任公司昆明供电局Distributed system architecture data process consistency ensuring method

Cited By (12)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN107528912A (en)*2017-09-112017-12-29金蝶软件(中国)有限公司A kind of automatic method, system and relevant apparatus for realizing distributing real time system
CN107943601A (en)*2017-11-222018-04-20国云科技股份有限公司 A method to balance the consistency and reliability of non-core business data under the microservice architecture
CN108153598A (en)*2017-12-252018-06-12东软集团股份有限公司 Data consistency method and device based on microservice architecture
CN108153598B (en)*2017-12-252021-06-25东软集团股份有限公司 Data consistency method and device based on microservice architecture
CN108415758A (en)*2018-03-272018-08-17深圳市买买提信息科技有限公司Distributed transaction coordination approach and device
CN108415758B (en)*2018-03-272020-11-27深圳市融壹买信息科技有限公司Distributed transaction coordination method and device
CN108804238A (en)*2018-03-292018-11-13中国工程物理研究院计算机应用研究所A kind of flexible bus communication means based on remote procedure call
CN108804238B (en)*2018-03-292022-03-04中国工程物理研究院计算机应用研究所Soft bus communication method based on remote procedure call
CN110764930A (en)*2019-10-212020-02-07中国民航信息网络股份有限公司Request or response processing method and device based on message mode
CN111708616A (en)*2020-06-112020-09-25浙江网新恒天软件有限公司Processing method of single data source distributed transaction under micro-service architecture
CN113055465A (en)*2021-03-112021-06-29南京大学Micro-service dynamic updating method supporting transaction consistency
CN114237833A (en)*2021-12-162022-03-25富盛科技股份有限公司 A high-performance real-time consistent microservice execution method and system

Similar Documents

PublicationPublication DateTitle
CN106874130A (en)The processing method of distributed transaction in a kind of micro services framework
CN111930529B (en)Data synchronization method, device and system based on message queue and microservice
CN100452707C (en)A method and system for keeping data consistency
CN105988862B (en)Distributed transaction processing method and device
KR100625595B1 (en) Parallel Logging Method and Transaction Log Processing System of Transaction Processing System
CN103425462B (en)A kind of method and apparatus of workflow data persistence
CN111277639B (en)Method and device for maintaining data consistency
CN107038645B (en)Service processing method, device and system and server
WO2020000720A1 (en)Server, packet processing method, program, and computer-readable storage medium
US20020013846A1 (en)Apparatus, methods, and computer program products for transactional support of network management operations
CN109064311A (en)Batch based on online mode is withholdd processing method and processing device
CN114429340A (en)Electronic payment processing method and device, electronic equipment and storage medium
CN109146653A (en)A kind of checking method and device for cutting account day based on distributed environment
CN112131305A (en) Account Processing System
WO2020258666A1 (en)Distributed system and data processing method
CN112099973B (en) Service calling method and device
CN115187358B (en)Account checking engine data processing system and working method thereof
CN109615508A (en)Data summarization checking method and subsystem for internet banking system
CN115907776A (en) An aggregated active-active payment method and system based on flexible distributed transactions
CN111400283A (en)Data processing method, system, electronic equipment and storage medium
CN113643032A (en)Information processing method and device based on block chain and data management system
CN112434050A (en)Data synchronization method and device of power grid business processing system and business processing system
CN110008271B (en)Micro-service transaction submitting method based on single database
US9025758B2 (en)Electronic communications system for multinodal expert networks
CN111861746A (en) A method and apparatus for processing transaction data

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
AD01Patent right deemed abandoned

Effective date of abandoning:20201222

AD01Patent right deemed abandoned

[8]ページ先頭

©2009-2025 Movatter.jp