Transacter under the Web service environment
Technical field
What the present invention relates to is a kind of system of networking technology area, specifically is the transacter under a kind of Web service environment.
Background technology
Issued transaction is the combination of sequence of operations, these discrete operations make system from the state evolution of a unanimity to another consistent state.The operation that these are discrete or all successes, or all failures.And if the affairs failure, system can roll back to the state of predictable unanimity.Issued transaction is to simplify programmed logic, makes up the basic technology of reliable Distributed Application.The application program that Web service can be used under the various environment is integrated, from simple data sharing to large-scale ecommerce and moneytary operations.Web service provides interoperability between application program based on the standard of unified XML at Fabric Interface between the application program, thus these application programs can between the different enterprises, realize the seamless communication of cross-platform and language between the different platform.The Web service technology is one of mainstream technology of structure Distributed Calculation, but does not also well support issued transaction.If Web service is used to industry, must guarantee that they move in transaction environment in, work in reliable and predictable mode.But in traditional issued transaction, Web service is merely able to use the affairs that are independent of other assemblies---rule that realizes with the affairs bottom of obeying it that divide in the method scope of Web service---and physically can not leave Web service or enter another Web service.And, traditional issued transaction must satisfy the attribute of affairs ACID, thereby need in the process that affairs continue, lock and prevent that other affairs from conducting interviews to this resource the resource that participates in affairs, but the affairs duration under the Web service environment may be longer than Traditional affair far away, can't bear the high cost of long-time resource lock, need the ACID attribute of affairs be relaxed, reach in logic affairs ACID attribute by other modes such as affairs compensation and so on.
Through literature search, do not find identical with theme of the present invention or similar bibliographical information so far as yet to prior art.
Summary of the invention
The objective of the invention is at the limitation of Traditional affair processing under the Web service environment, transacter under a kind of Web service environment is provided, make its support that issued transaction can be provided the transactional Distributed Calculation of crossing over a plurality of Web services, use Web service can move in a kind of predictable mode as the operation system of Distributed Calculation.
The present invention is achieved by the following technical solutions, the present invention includes: telegon assembly, coordination service assembly, activate serviced component, registration service assembly, participate in serviced component, finish serviced component, transaction coordination context component and client component.Wherein the transaction coordination context component is the message of an XML form, and remaining assembly will be disposed as Web service, and they all are the necessary component of system; Client component then is that for convenience application program is initiated and submitted affairs to and the calling interface that provides, is the expansion of system.Client application is initiated new affairs by client component to the coordination service components request, the coordination service assembly is that new affairs are created a correspondent transaction telegon and preserved by the telegon assembly, and the coordination service assembly can be created a new transaction coordination context component and return this new transaction coordination context component and give client component simultaneously to activating the serviced component request.After this client application and the Web service that participate in affairs all can be registered to the registration service assembly by this transaction coordination context component.Last client application can require to carry out affairs submission or termination to client component, client component then calls finishes submission or the termination that serviced component carries out affairs, finally finishes serviced component and can participate in serviced component by the telegon component call and all participants that participate in these affairs are submitted to or terminate.
Described telegon assembly is preserved a telegon example for each activity, and preservation affairs participant's tabulation, acceptance are finished the request of submission of service request affairs or rollback and called the service of participation the participant is submitted to or rollback.
Described coordination service assembly is accepted the request of client component and is created the correspondent transaction telegon for the new activity of initiating, and is responsible for preserving and management transaction telegon assembly.The coordination service assembly also is responsible for creating new coordination context to activating services request.
Described activation serviced component is accepted the request of client component and is created new transaction coordination context component when new affairs are initiated; This new transaction coordination context component will return to the telegon assembly and preserve, and after this each ingredient of system can obtain this new transaction coordination context component by the ID of affairs from the telegon assembly.
Described registration service assembly allows Web service to be registered in the transaction coordination context component as the affairs participant, and participant's the address and the information such as matchmaking protocol of use will be stored in the telegon assembly.
Described participation serviced component is used to respond the transactional operation requests that the telegon assembly is initiated, and the correspondent transaction participant is submitted to or transactional operation such as rollback according to the request of telegon assembly.
The described serviced component of finishing is used to receive and handle the transactional request that requires affairs to submit to or stop that client component is initiated; Finish serviced component and will initiate transactions requests, and finally finish the correspondent transaction request by participating in service to the telegon assembly of correspondence.
Described transaction coordination context component is similar to the transaction context in the Traditional affair processing, preserved relevant informations such as affairs participant and affairs coordinator, the behavior that each ingredient of system carries out the feasible a plurality of Web services that distribute of communication by the transaction coordination context component focuses in the same transaction environment.
Described client component, the request of accepting client applications is initiated, is terminated or submits affairs to.The application programming interfaces that client should be provided for dividing transaction boundaries call for CLIENT PROGRAM, thereby simplify the coding work of transactional Web service application system.
Compare with the Traditional affair processing, thereby the present invention can adjust the behavior that the context of affairs will be distributed in the participant of a plurality of Web services and gather together, and further, by guaranteeing that each participant agrees fully that all each comfortable operation of coordinating to carry out in context component produces expected result, perhaps when having different opinions cancel all executed operation to get back to expected still be consistent result.
The present invention can provide the support of issued transaction to the transactional Distributed Calculation of crossing over a plurality of Web services, can be by expansion Traditional affair disposal system, traditional issued transaction is integrated to the Web service environment, thus original service inner use Web service that Traditional affair handles can be with the support of issued transaction from single service internal extended to crossing over a plurality of affairs.Especially, the present invention has expanded the JTA affairs under the J2EE environment, and the feasible Web service that has been deployed on the J2EE platform can be supported the affairs of Web service under the situation that need not revise code.This is to realize by specific JTA affairs being exported to the Web service environment and the affairs under the Web service environment are imported to the J2EE environment from the J2EE environment.
The Handler of the present invention by expansion Axis makes propagating that the transaction coordination context component can implicit expression between a plurality of Web services, thereby affairs can be carried out the propagation of implicit expression between a plurality of Web services, and need not the propagation that Web service transaction coordination context component is controlled in extra programming, thereby simplify also mitigation system integrated programming personnel's work.
Description of drawings
Fig. 1 is a system architecture synoptic diagram of the present invention.
The actual precedence diagram that calls that Fig. 2 handles for processing transactions of the present invention.
Embodiment
As shown in Figure 1, the present invention includes: telegon assembly, coordination service assembly, activate serviced component, registration service assembly, participate in serviced component, finish serviced component, transaction coordination context component and client component.Client application is initiated new affairs by client component to the coordination service components request, the coordination service assembly is that new affairs are created a correspondent transaction telegon and preserved by the telegon assembly, and the coordination service assembly can be created a new transaction coordination context component and return this new transaction coordination context component and give client component simultaneously to activating the serviced component request.After this client application and the Web service that participate in affairs all can be registered to the registration service assembly by this transaction coordination context component.Last client application can require to carry out affairs submission or termination to client component, client component then calls finishes submission or the termination that serviced component carries out affairs, finally finishes serviced component and can participate in serviced component by the telegon component call and all participants that participate in these affairs are submitted to or terminate.
Each assembly of the present invention is the center with the coordination service assembly, each participant at the affairs of participation activity adjusts the transaction coordination context component with the communication between the corresponding telegon, thereby make affairs can cross over a plurality of Web services, realize the affairs support under the Web service environment.
These serviced components of whole Web service transacter can be deployed on the same machine, also can be deployed on the different machines.They itself also are some Web services, use the mode identical with common Web service to visit.Client component then is simple application programming interfaces, can be used as built-in function and issues, and application program only need simply be called and get final product.
Activating serviced component provides createCoordinationContext operation response coordination service components request to create the message " createCoordinationContext " of new transaction coordination context component.
The registration service assembly provides registerParticipant operation response telegon components request registration participant's message " registerParticipant ".
The message " createCoordinationContext " that the coordination service assembly provides the requirement of getCoordinationContext operation customer in response end assembly to create a new telegon, the message " createCoordinator " that provides the getCoordinator operation to be used for a new telegon of customer in response end assembly requirement establishment.
The telegon assembly then provides the getCoordinationContext operation to obtain to coordinate context component for client and participant; Provide registerParticipant to be registered in the current transaction environment for the participant; Provide getTransactionID to return the ID of current affairs; Provide commit and rollback operation to call, to submit to or affairs of rollback for finishing serviced component.
Finishing serviced component provides commit and rollback operation to call for client component to submit to or affairs of rollback, and concrete operation will be called the operation of response of the telegon assembly of affairs correspondence again.
Participate in serviced component commit be provided, prepare, the rollback operation is for the telegon component call, be used for to concrete affairs participant require to submit to, preparation or rollback.
Client component then provides the operation of beginTransaction, cancelTransaction and confirmTransaction simply to initiate and finish affairs for client applications.
As shown in Figure 2, the invoked procedure of the issued transaction of a reality of the present invention, client sends " beginTransaction " message request to client component and initiates new affairs, client component then sends a new telegon of message request establishment of " getCoordinator " to the coordination service assembly, the coordination service assembly is to carry out index by affairs ID in a new affairs new telegon of establishment and the Hash table that is kept at the telegon assembly; After new telegon is created, the coordination service assembly is again to activating new transaction coordination context component of message requirement establishment that serviced component sends " createCoordinationContext ", the activation serviced component is then created a new context component and is placed on and returns to the coordination service assembly in " CoordinationContext ", final telegon context component can return to client component by message " getCoordinatorResponse ", and the message that client component then sends one " transactionBegun " informs that the client application affairs create.
After this call a businesslike web service at every turn, all at first become the participant to the message request registration that the registration service assembly sends " registerParticipant " by this service, the registration service assembly will be preserved participant's tabulation by telegon, finally return " registerResponse " message and give the participant.
Finally, client application selects to submit to affairs, client component sends " submission " message to finishing serviced component, the service of finishing further sends " submission " message to the telegon assembly, the telegon assembly sends " submission " message to participating in serviced component again, final participation serviced component returns " submitting response to " message and gives the telegon assembly after finishing the affairs submission, the telegon assembly returns to client component with " submission response " message by finishing serviced component again.Finally application program judges according to the message of " submitting response to " of obtaining from client component whether affairs are successful.
Compare with traditional distributed transaction technology, the present invention has used one to be similar to the contextual transaction coordination context component of Traditional affair, and increased activation serviced component, registration service assembly, participated in serviced component, finished that serviced component is created and management transaction is coordinated context component, thereby the affairs participant's that distributes behavior has been focused on the transaction environment of transaction coordination context component representative.