Specific implementation mode
The embodiment of this specification proposes a kind of implementation method of new distributed transaction heat deployment, by promoter to participating in
The calling of person's service interface is realized by branch's transaction component, by updating branch's transaction set in the operational process of promoter
The script of part replaces original branch's transaction component with new branch's transaction component, realizes the online liter of branch's transaction component
Grade is upgraded point in this way when the service interface of participant change using the branch's transaction component script for matching new demand servicing interface
Branch transaction component, you can the adaptability update for completing promoter accelerates the speed of matching business demand variation, reduces exploitation
The work of personnel.
In the embodiment of this specification, using TCC, (Try/Confirm/Cancel, trial/confirmation/take distributed transaction
Disappear) pattern.In TCC patterns, each participant realize a stage Try method of a certain branch's affairs, two-stage Confirm and
Two-stage Cancel method is issued in the form of service interface, is called for promoter and Service Manager.
Promoter registers to Service Manager after opening a distributed transaction and realizes each of distributed transaction point
The participant of branch affairs, and the service interface that each participant is respectively adopted calls the stage of the participant to service;It is each
Participant executes a stage Try method of promoter branch affairs, and a stage whether successful implementing result is returned to initiation
Person;If the stage implementing result of each participant is success, promoter notifies Service Manager to submit the distribution thing
Business, Service Manager call the two-stage Confirm method of distributed transaction participant;Otherwise promoter notifies transaction management
Person's rollback distributed transaction, Service Manager call the two-stage Cancel method of distributed transaction participant.
The embodiment of this specification is applied to the promoter in distributed transaction TCC patterns.In this specification embodiment
Promoter may operate in any equipment with calculating and storage capacity, such as mobile phone, tablet computer, PC (Personal
Computer, PC), notebook, the equipment such as server;It can also be by operating in the logics of two or more equipment
Node realizes the various functions of promoter in this specification embodiment.
In the embodiment of this specification, the flow of the implementation method of the upper distributed transaction heat deployment of promoter is as shown in Figure 1.
Step 110, some updated script of branch's transaction component is obtained.
In the embodiment of this specification, on promoter to the calling of the service interface of participant's publication using component come real
Existing, component is that by the software unit of certain function, and the concrete form of component can be according to the software of practical application scene
The factors such as system environments, programming language determine, do not limit.Such as component can be class, object, software package etc..
On promoter, by calling participant's service interface to be known as branch's transaction set to carry out the component of distributed transaction
Part.Promoter includes one and arrives multiple branch's transaction components, and each branch's transaction component corresponds to one and arrives multiple participants, real
Now to the calling of corresponding participant's service interface.Branch's transaction component needs the service interface for being matched with corresponding participant,
The stage service that the energy normal use participant provides.
Promoter is when starting operation, using the script load branch transaction set of included each branch's transaction component
Part.In the process of running, after the script of branch's transaction component updates, promoter obtains updated component script.
The concrete mode of branch's transaction component script can be according to the specific of practical application scene after promoter's acquisition update
It realizes to determine, does not limit.For example, the script of each branch's transaction component in promoter can be preserved to predetermined storage position
It sets, whether has script update by promoter's timing inquiry, if there is then reading newer branch's transaction component script.
In one implementation, each branch's transaction component script of promoter can be registered to DRM
On (Distributed Resource Manager, distributed resource management) server, promoter subscribes to this to DRM server
A little branches transaction component script, when any one in these branch's transaction component scripts updates, promoter can connect
Receive the updated script of branch's transaction component of DRM server push.DRM server can by branch transaction component mark,
And script is pushed to promoter after the update of branch's transaction component with the mark.
Step 120, new branch's transaction component is generated according to updated script, replaces original branch's transaction set
Part.
Promoter can generate new branch's transaction component based on mechanism is provided in the prior art and replace original
Branch's transaction component, can also voluntarily realize, not limit.
For example, in whether promoter's timing inquiry has the newer application scenarios of script, promoter can read some point
After the updated script of branch transaction component, compiles updated script and obtain updated branch's transaction component, it will be updated
In branch's transaction component dynamic loading to the running environment of promoter, replace original same branch's transaction component, completes to divide
The upgrading of branch transaction component.
For another example, the promoter realized to being based on Java Spring (a kind of Java Development Frameworks of open source code), each
Branch's transaction component can be a Java Bean (a kind of Reusable Module of Java language).Spring applies journey in operation
It can monitor and detect the change to dynamic language script when sequence, and by the Bean automatic reloadings being modified to application program
In context.Specifically, after Spring containers detect that some Bean script updates, after compiling updated script
The new Bean generated, new Bean is assembled in the context of promoter, to replace the original identified with identical Bean
There is Bean.
In one example, it can be promoter or be that each branch's transaction component setting script refreshes and comes into force the period,
Script refreshing comes into force the period then, (script refreshing is arranged for promoter to come into force if there is update occurs for branch's transaction component script
In the case of period) or this branch transaction component script update occurs and (script is set for each branch's transaction component refreshes and come into force
In the case of period), the new branch's transaction component generated after updated script is compiled, new branch's transaction set is loaded
Part is to replace original branch's transaction component.
It can be based on Groovy (a kind of development language based on Java Virtual Machine) and the combination of Spring was last to realize
Example.Branch's transaction component script is written as Groovy Bean scripts with Groovy language, and is branch's transaction component
Groovy Bean's<lang:groovy>Element adds refresh-check-delay attributes, by refresh-check-
The script refreshing that the attribute value of delay is set as branch's transaction component comes into force the period.Rewrite the ScriptSource of Spring
Interface enables revised ScriptSource interfaces to obtain the script of the Groovy Bean write with Groovy language;Change
The ScriptFactoryPostProcessor interfaces (interface for carrying out script replacement) for writing Spring, make revised
ScriptFactoryPostProcessor interfaces can support Groovy Bean (to use Groovy Bean to carry out script to replace
It changes).
The period is come into force when the script of refresh-check-delay attributes setting refreshes then, if Spring containers are examined
The script for measuring some Groovy Bean updates, then Spring containers are connect using the ScriptSource of support Groovy
Mouthful, obtain script after the update of the changed Groovy Bean marks of script and the Groovy Bean with the mark;
Using the ScriptFactoryPostProcessor interfaces for supporting Groovy Bean, with updated script have and be somebody's turn to do
The load and initialization of the Groovy Bean of mark.
Step 130, the clothes of participant corresponding with branch's transaction component are called using replaced branch's transaction component
Business interface.
After completing branch's transaction component and replacing, during follow-up operation, promoter is calling and branch's transaction set
When the service interface of the corresponding participant of part, it will be carried out by updated branch's transaction component.
After application the present embodiment, by the update of branch's transaction component, it can both be connect in the service of corresponding participant
Mouth is adapted to new service interface when changing, and can also change the call parameters to corresponding participant's service interface, thus
Change the executive mode of branch's affairs in distributed transaction in promoter's operational process.
For example, when the service interface increase provided on participant, reducing or changing the ginseng transmitted by the service interface
When number, the branch's transaction component script for being matched with new demand servicing interface can be supplied to promoter, correspond to the participant in this way
Branch's transaction component after completing script and replacing, when calling the service interface of the participant, by increase, reduction or change logical
The parameter of service interface transmission is crossed, realizes the heat deployment of branch's transaction component.
For another example, it is assumed that the parameter that the service interface of some participant transmits includes being used to specify the specific business mistake of branch's affairs
The different values of the business operation code of journey, business operation code correspond to the different business procession of branch's affairs.It is updating
Corresponding to the participant branch's transaction component script when, business operation code can be changed to another by a value and taken
Value, in this way after completing branch's transaction component and replacing, replaced branch's transaction component can use and original branch's transaction component
Different business operation code value, to call the service interface of the participant, to change the business processing mistake of branch's affairs
Journey.
As it can be seen that in the embodiment of this specification, promoter is passed through into branch's transaction set to the calling of participant's service interface
Part is realized, after the script update of some branch's transaction component, is replaced with the branch's transaction component generated by script after update
Original branch's transaction component realizes the online upgrading of branch's transaction component, when the modification of the service interface of participant, uses
It matches branch's transaction component script of new demand servicing interface and interface adaptation can be completed to upgrade corresponding branch's transaction component, be not necessarily to
The code for changing promoter, reduces development amount while accelerating adaptation speed.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims
It is interior.In some cases, the action recorded in detail in the claims or step can be come according to different from the sequence in embodiment
It executes and desired result still may be implemented.In addition, the process described in the accompanying drawings not necessarily require show it is specific suitable
Sequence or consecutive order could realize desired result.In some embodiments, multitasking and parallel processing be also can
With or it may be advantageous.
In an application example of this specification, a distributed system carries out distributed transaction using TCC patterns.
The distributed system includes promoter, Service Manager and several participants.On promoter, each participant's service is connect
Mouthful calling realized with branch transaction component Groovy Bean.
The promoter based on Java Spring frames realize, by rewrite Spring ScriptSource interfaces and
ScriptFactoryPostProcessor interfaces enable revised ScriptSource interfaces to read with Groovy language
The component script write enables ScriptFactoryPostProcessor interfaces after rewriting to being write with Groovy language
Component script carries out script replacement, even if revised ScriptSource interfaces and ScriptFactoryPostProcessor
Interface supports the script of Groovy Bean to obtain and replace.For each branch's transaction component Groovy Bean's<lang:
groovy>Element adds refresh-check-delay attributes, and the attribute value of refresh-check-delay is set as 5 points
Clock (the script refreshing of branch's transaction component comes into force the period).
The script of each branch transaction component Groovy Bean is registered to DRM server, and promoter is to DRM server
Subscribe to each branch's transaction component Groovy Bean scripts.
A kind of operational process of promoter is as shown in Figure 2.
Step 205, promoter opens the local matter of the distributed transaction, is the execution distribution thing in local cache
Each participant of business creates proxy class.After proxy class creates successfully, a stage action blocker is added for each proxy class,
One stage action blocker is used for the stage service execution result that the corresponding participant of Receiving Agent class returns.
Step 210, each proxy class of promoter is respectively that the participant respectively acted on behalf of carries out second order to task manager
Section service registration.Service Manager receives registration, records all participants of the distributed transaction.
Promoter is called and is corresponded to by the branch transaction component Groovy Bean being assemblied in its application context
Each participant service interface, so that participant is executed stage service, and by one of the proxy class corresponding to the participant
Stage action blocker receives a stage service execution result of participant return.If all ginsengs of a distributed transaction
The stage implementing result returned with person is all success, and promoter submits the local matter of the distributed transaction, Service Manager
After learning that promoter submits local matter, the two-stage of all participants of the distributed transaction is called to submit service;If there is
The stage implementing result that participant returns is failure, the local matter of promoter's rollback distributed transaction, Service Manager
After learning promoter's rollback local matter, the two-stage rollback service of all participants of the distributed transaction is called.Above-mentioned mistake
Journey is that the flow of distributed transaction is executed on promoter, is not shown in fig. 2.
While promoter executes distributed transaction, step 215, when some branch transaction component Groovy Bean's
Script refreshing comes into force the period then, and Spring containers detect the foot of the transaction component branch of branch transaction component Groovy Bean
This update status.
After promoter subscribes to the script of branch transaction component Groovy Bean to DRM server, when subscribed branch thing
When the script of business component Groovy Bean has update, DRM server can by the mark for having newer Groovy Bean and more
Groovy Bean after new are pushed to the promoter.
Step 220, judge whether the script of branch transaction component Groovy Bean has update.Each branch can be enabled
The script of transaction component Groovy Bean carries its version number, can also be according to some branch's transaction component Groovy Bean foot
This last receiving time does not limit to judge whether script has update.If there is update, step 225 is executed, is otherwise turned
Step 215.
Step 225, it is changed to obtain script using the ScriptSource interfaces for supporting Groovy for Spring containers
Script after the update of Groovy Bean marks and the Groovy Bean with the mark.
Step 230, Spring containers are connect using the ScriptFactoryPostProcessor of support Groovy Bean
Mouthful, the load and initialization of the Groovy Bean with the mark are carried out with updated script, are replaced original with the mark
The Groovy Bean of knowledge.
The updated Groovy Bean of script are being loaded into the context of promoter and are completing Groovy Bean's
After initialization, promoter is the service interface for starting to call corresponding participant using replaced Groovy Bean, to carry out
Distributed transaction.
Corresponding with the realization of above-mentioned flow, the embodiment of this specification additionally provides a kind of distributed thing applied to promoter
The realization device for heat deployment of being engaged in.The device can also pass through hardware or the side of software and hardware combining by software realization
Formula is realized.For implemented in software, as the device on logical meaning, CPU (the Central Process of equipment where being
Unit, central processing unit) corresponding computer program instructions are read in memory what operation was formed.For hardware view,
Other than CPU shown in Fig. 3, memory and memory, it is applied to the realization device of the distributed transaction heat deployment of promoter
The equipment at place also typically includes other hardware such as the chip for carrying out wireless signal transmitting-receiving, and/or logical for realizing network
Other hardware such as board of telecommunication function.
Fig. 4 show a kind of realization device of distributed transaction heat deployment of this specification embodiment offer, is applied to hair
Person is played, the promoter includes at least one branch's transaction component, and each branch's transaction component corresponds to the distributed transaction
At least one participant, include the acquisition of more new script for calling the service interface of corresponding participant publication, described device
Unit, component replacement unit and component call unit, wherein:More new script acquiring unit is for obtaining some branch's transaction component
Updated script;Component replacement unit is used to generate new branch's transaction component according to updated script, replaces former
The branch's transaction component having;Component call unit is used to call and described point using replaced branch's transaction component
The corresponding participant's service interface of branch transaction component.
Optionally, the more new script acquiring unit is specifically used for:Receive the push of distributed resource management DRM server
The updated script of branch's transaction component.
Optionally, branch's transaction component is Java Bean;The component replacement unit is specifically used for:In Spring
After container detects that some Bean script updates, the new Bean generated after updated script is compiled, it will be new
The Bean is assembled in the context of promoter, replaces original Bean with identical Bean marks.
In one example, the component replacement unit is specifically used for:The period is come into force in script refreshing then, if branch's thing
Business component script updates, and compiles the branch's transaction component newly generated after updated script, loads new described
Branch's transaction component is to replace original branch's transaction component.
In above-mentioned example, the Bean is Groovy Bean;The Groovy Bean's<lang:groovy>Element
Refresh-check-delay attribute values are that script refreshing comes into force the period;The component replacement unit compiles updated script
The new branch's transaction component generated afterwards, loads new branch's transaction component to replace original branch's affairs
Component, including:By Spring containers using the ScriptFactoryPostProcessor components for supporting Groovy Bean, obtain
Script after the update of script changed Groovy Bean marks and the Groovy Bean with the mark is taken, with more
Script after new carries out the load and initialization of the Groovy Bean with the mark.
Optionally, replaced branch's transaction component increases, subtracts when calling the service interface of the participant
Less or change the parameter transmitted by the service interface.
The embodiment of this specification provides a kind of computer equipment, which includes memory and processor.
Wherein, the computer program that can be run by processor is stored on memory;Computer program of the processor in operation storage
When, execute each step for the implementation method for being applied to the distributed transaction heat deployment of promoter in this specification embodiment.It is right
The detailed description of each step of the implementation method of distributed transaction heat deployment applied to promoter refer to before content,
It is not repeated.
The embodiment of this specification provides a kind of computer readable storage medium, and computer is stored on the storage medium
Program, these computer programs execute the distribution for being applied to promoter in this specification embodiment when being run by processor
Each step of the implementation method of affairs heat deployment.To each of the implementation method of the distributed transaction heat deployment applied to promoter
The detailed description of a step refer to before content, be not repeated.
The foregoing is merely the preferred embodiments of this specification, all the application's not to limit the application
Within spirit and principle, any modification, equivalent substitution, improvement and etc. done should be included within the scope of the application protection.
In a typical configuration, computing device includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include computer-readable medium in volatile memory, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology realizes information storage.Information can be computer-readable instruction, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase transition internal memory (PRAM), static RAM (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), fast flash memory bank or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storages, magnetic tape cassette, tape magnetic disk storage or other magnetic storage apparatus
Or any other non-transmission medium, it can be used for storage and can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
Including so that process, method, commodity or equipment including a series of elements include not only those elements, but also wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that wanted including described
There is also other identical elements in the process of element, method, commodity or equipment.
It will be understood by those skilled in the art that the embodiment of this specification can be provided as method, system or computer program production
Product.Therefore, the embodiment of this specification can be used complete hardware embodiment, complete software embodiment or combine software and hardware side
The form of the embodiment in face.Moreover, it wherein includes that computer is available that the embodiment of this specification, which can be used in one or more,
It is real in the computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) of program code
The form for the computer program product applied.