[go: up one dir, main page]

WO2008110115A1 - Transaction coordinator, resource using terminal, service terminal, and method of distributed transaction processing - Google Patents

Transaction coordinator, resource using terminal, service terminal, and method of distributed transaction processing Download PDF

Info

Publication number
WO2008110115A1
WO2008110115A1 PCT/CN2008/070471 CN2008070471W WO2008110115A1 WO 2008110115 A1 WO2008110115 A1 WO 2008110115A1 CN 2008070471 W CN2008070471 W CN 2008070471W WO 2008110115 A1 WO2008110115 A1 WO 2008110115A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
resource
module
request
adapter
Prior art date
Application number
PCT/CN2008/070471
Other languages
French (fr)
Chinese (zh)
Inventor
Shikai Liu
Qingchun Shen
Original Assignee
Huawei 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 Huawei Technologies Co., Ltd. filed Critical Huawei Technologies Co., Ltd.
Publication of WO2008110115A1 publication Critical patent/WO2008110115A1/en

Links

Classifications

    • 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/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications

Definitions

  • the present invention relates to a distributed transaction processing technology, and more particularly to a method for a transaction coordinator, a transaction resource user, a server, a transaction resource user, and a server to process a distributed transaction.
  • a transaction is a series of operations performed as a single logical unit of work.
  • a distributed transaction is an ACID transaction between two or more transactional resources (for example, two separate databases).
  • J2EE Connector Architecture J2EE Connector Architecture
  • JCA J2EE Connector Architecture
  • the Resource Adapter provides a Connection and Connection Factory interface, and the connection factory is responsible for creating connections to the Application System.
  • the Connection Manager manages the connections of different application systems. When connection management receives a connection request from a connection factory, connection management obtains the connection from the connected cache container, Pool Manager. If there is no connection available in the connection pool, a new physical connection is created by calling the Managed Connection Factory.
  • the existing JCA-based transactional unified architecture has the following drawbacks: Interface is complex, implementation is difficult, and even some existing systems cannot implement JCA's standard interface in mechanism, which is only applicable to
  • the application system built by the J2EE specification cannot solve the data consistency requirements not based on the J2EE specification or non-Java application system, such as C++ application, #application, etc. Summary of the invention
  • the purpose of the embodiments of the present invention is to provide an interface device, a transaction coordinator that conforms to data consistency requirements, a transaction resource usage end, a transaction resource server, a transaction resource usage end, and a server-side distributed transaction processing method to implement a cross-system.
  • Distributed transaction processing and is applicable to a variety of application systems based on J2EE, J2SE (Java 2 Standard Edition), C++, #.
  • an embodiment of the present invention provides a distributed transaction processing method for a transaction resource usage end, which includes the following steps:
  • an embodiment of the present invention further provides a distributed transaction processing method of a transaction resource server, including: searching for a corresponding transaction adapter according to a transaction identifier carried in a service operation request; and replacing a current transaction with the transaction adapter Performing a business operation according to the business operation request; registering a resource manager to the transaction adapter; forwarding the submit request to the transaction adapter according to a transaction identifier carried in the submit request; and executing by the resource manager submit.
  • an embodiment of the present invention further provides a transaction coordinator, including: a transaction proxy module, configured to submit a submission request carrying a transaction identifier by using a registered transaction resource client; and a registration module, configured to register to participate in the current a transaction resource client of the transaction, and notifying the transaction agent module of the registration information; the transaction resource client is at least one; the submit request forwarding module is configured to submit a submit request to the transaction proxy module; and the logout module is configured to log off The transaction resource client of the current transaction, and notifies the transaction agent module of the logout information.
  • an embodiment of the present invention further provides a transaction resource usage end, including: a transaction coordinator, configured to coordinate transaction resources, and perform distributed transaction control, where the transaction coordinator includes: a transaction proxy module for registering The transaction resource client submits the commit request carrying the transaction identifier; the registration module is configured to register the transaction resource client participating in the current transaction, and notify the transaction proxy module of the registration information; the transaction resource client is at least one; submit the request a forwarding module, configured to submit a submit request to the transaction proxy module; and a logout module, configured to cancel the transaction resource client of the current transaction, and notify the transaction proxy module of the logout information;
  • a service operation requesting module configured to submit, by the transaction resource client, a business operation request carrying a transaction identifier
  • a transaction resource client used to communicate with a transaction resource server, submit a business operation request, and submit a request.
  • an embodiment of the present invention further provides a transaction resource server, including: a transaction mapping module, configured to search a transaction adapter corresponding to a transaction identifier; the transaction mapping module includes: a transaction adapter, configured to forward the submission request To the registered resource manager; a recording module, configured to record a correspondence between the transaction identifier and the transaction adapter, and a lookup module, configured to find a transaction adapter corresponding to the transaction identifier;
  • a transaction adapter creation module configured to create a transaction adapter, and save a transaction identifier and a transaction adapter to the recording module;
  • a resource manager configured to perform a submission according to the submit request
  • a transaction manager that replaces the current transaction with the transaction adapter and the registration and deregistration of the resource manager.
  • the transaction coordinator controls the transaction at the upper layer of the transaction manager, and realizes the atomicity, consistency, isolation, and durability required by the distributed transaction processing, and the transaction adapter as an interface is easy to use;
  • the example implements cross-system distributed transaction processing, which is based on
  • FIG. 1 is a schematic diagram of a first structure of a transaction resource usage end according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a first structure of a transaction resource server according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a distributed transaction processing system formed by a transaction resource use end and a transaction resource server according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a first structure of a transaction coordinator according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a second structure of a transaction coordinator according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a second structure of a transaction resource usage end according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a second structure of a transaction resource server according to an embodiment of the present invention.
  • FIG. 8 is a first flowchart of a distributed transaction processing method of a transaction resource usage end according to an embodiment of the present invention
  • FIG. 9 is a first flowchart of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention.
  • FIG. 10 is a second flow diagram of a distributed transaction processing method for a transaction resource usage end according to an embodiment of the present invention.
  • FIG. 11 is a second flow diagram of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention.
  • FIG. 12 is a third flow diagram of a distributed transaction processing method of a transaction resource usage end according to an embodiment of the present invention.
  • FIG. 13 is a third flowchart of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention. detailed description As shown in FIG. 1, a first structural diagram of a transaction resource usage end according to an embodiment of the present invention is shown.
  • the transaction resource use terminal 1 uses the service provided by the transaction resource server through the transaction resource client 12.
  • the transaction resource usage end 1 includes a transaction coordinator 11, a transaction resource client 12, a business operation request module 13, and a submission request module 14.
  • the transaction coordinator 11 is used to coordinate transaction resources and perform distributed transaction control, and the transaction resource user 1 starts the transaction through the transaction coordinator 11.
  • the transaction resource client 12 has a one-to-one correspondence with the transaction resource server 2 (not shown), and is used for communicating with the corresponding transaction resource server 2, submitting a business operation request carrying the transaction identifier and submitting the request, implementing the transaction.
  • the service operation requesting module 13 is configured to submit, by the transaction resource client 12, a service operation request carrying a transaction identifier, and the service operation includes adding, deleting, changing, checking, and publishing the data.
  • each transaction resource client 12 registers with the transaction coordinator 11.
  • the submit request module 14 is for initiating a commit request, the module sends a commit request to the transaction coordinator 11, and the transaction coordinator 11 sends a commit request to the transaction resource server 2 via the registered transaction resource client 12.
  • the business operation requesting module 13 may send the business operation request one by one to each transaction resource client 12 corresponding to the operation in the order of the operations included in the transaction, and each transaction resource client receives the service.
  • the operation request is registered in the transaction coordinator 11, so that the transaction coordinator 11 can collectively manage a plurality of transaction resources.
  • This embodiment implements cross-system distributed transaction processing based on non-JCA architecture, and is applicable to various systems based on J2EE, J2SE, ++, and #.
  • FIG. 2 it is a schematic diagram of a first structure of a transaction resource server according to an embodiment of the present invention.
  • the transaction resource server 2 is configured to provide a service resource for the transaction resource using terminal 1 (not shown) through the transaction resource client 12 (not shown), which includes the transaction mapping module 21, the resource manager 22, and the transaction.
  • the manager 23 and the transaction adapter create module 24.
  • the transaction mapping module 21 is configured to find a transaction adapter corresponding to the transaction identifier, and the transaction mapping module 21 includes a transaction adapter 211, a lookup module 212, and a recording module 213.
  • Transaction adapter 211 is used Receiving the submit request and forwarding the submit request to the registered resource manager, each transaction adapter 211 is used to manage the operation of a transaction in which the transaction resource server 2 participates, and when the transaction resource server 2 participates in multiple transactions, the transaction map Module 21 then includes a plurality of transaction adapters 211.
  • the lookup module 212 is configured to look up the transaction adapter 211 corresponding to the transaction identifier.
  • the recording module 213 is configured to record the correspondence between the transaction identifier and the transaction adapter.
  • the resource manager 22 is configured to perform the submission in accordance with the submission request, which supports the two-phase commit protocol.
  • the transaction manager 23 is used to replace the current transaction with the registration and deregistration of the transaction adapter and the resource manager, and to manage transaction resources such as a physical database, an in-memory database that supports transactions, and an application system that supports the transaction interface.
  • the transaction adapter creation module 24 is configured to create a transaction adapter 211. After receiving the business operation request, the transaction resource server 2 creates a transaction adapter 211 if the transaction identifier corresponding to the transaction identifier is not found, and the transaction adapter 211 and the corresponding transaction. The identification is saved to the recording module 213.
  • This embodiment implements cross-system distributed transaction processing based on non-JCA architecture.
  • the transaction adapter is responsible for the management of one transaction operation.
  • the transaction adapter as an interface is easy to use, and is suitable for J2EE, J2SE, ++, and #, etc. A variety of application systems.
  • FIG. 3 it is a schematic structural diagram of a distributed transaction processing system formed by a transaction resource use end and a transaction resource server according to an embodiment of the present invention.
  • the transaction resource use terminal 1 is connected to the transaction resource service system 2 through the transaction resource client 12, and the transaction resource client 12 corresponds to the transaction resource monthly service system 2.
  • FIG. 4 it is a schematic diagram of a first structure of a transaction coordinator according to an embodiment of the present invention.
  • the transaction coordinator 11 includes a registration module 112, a submission request forwarding module 113, a logout module 114, and a transaction proxy module 115.
  • the registration module 112 is configured to register the transaction resource client 12 participating in the current transaction and notify the transaction agent module 115 of the registration information.
  • the transaction resource client 12 registers as a resource agent to the registration module 112.
  • the submit request forwarding module 113 submits the commit request carrying the transaction identifier through the transaction proxy module 115.
  • Transaction proxy module 115 A transaction resource client 12 registered as a resource agent is managed in a transaction, which submits a commit request carrying a transaction identifier through the transaction resource client 12, and supports submitting the commit request in a two-phase commit manner.
  • the logout module 114 is configured to log out the transaction resource client 12 of the current transaction after submitting the commit request, and notify the transaction proxy module 115 of the logout information.
  • the non-JCA-based transaction coordinator of the embodiment implements distributed transaction management across systems, and satisfies the data operation consistency requirements of multiple application systems based on J2EE, J2SE, C++, and #.
  • the transaction coordinator of an embodiment of the present invention may further include a creation module 111 for creating a transaction proxy module 115 and generating a transaction identifier.
  • the two-phase commit is divided into two phases: commit preparation and commit operation.
  • commit preparation phase the transaction resource performs data modification and log record processing after receiving the request. After the processing is completed, the transaction status is changed to "can submit" and then returned. As a result, the report is ready. If all transaction resources are ready, enter the commit phase.
  • commit phase the transaction's "deliverable” status is changed to the "commit complete” status.
  • FIG. 6 it is a schematic diagram of a second structure of a transaction resource usage end according to an embodiment of the present invention.
  • the transaction coordinator 11 shown in FIG. 5 is applied to the transaction resource usage end embodiment 1 shown in FIG. 2, and the transaction proxy module 115 specifically includes a preparation request module 1151 and an operation request module 1152.
  • the preparation request module 1151 is configured to submit a submission preparation request carrying a transaction identifier; the operation request module 1152 is configured to continue to submit the submission operation request carrying the transaction identifier to the registered transaction resource client if the submission preparation is successful.
  • the submission of the submission request adopts a two-stage manner, that is, the first phase is the submission preparation, and the second phase is the submission operation, so that the use terminal can effectively control the consistency of the data operation, thereby realizing the transaction unification across the transaction manager.
  • FIG. 7 is a schematic structural diagram of Embodiment 2 of a transaction resource server according to the present invention.
  • the difference between the embodiment and the embodiment shown in FIG. 2 is that the transaction mapping module 21 further includes a deletion module 214.
  • the transaction manager 23 specifically includes a transaction switching module 231, a resource registration module 232, and a resource logout module 233.
  • the transaction switching module 231 is configured to replace the current transaction by the transaction manager 23 with the transaction identifier corresponding to the transaction identifier 211 after receiving the business operation request, and replace the current transaction with the transaction adapter 211 by the transaction adapter 211 after the commit is performed.
  • the transaction of manager 23 is configured to replace the current transaction by the transaction manager 23 with the transaction identifier corresponding to the transaction identifier 211 after receiving the business operation request, and replace the current transaction with the transaction adapter 211 by the transaction adapter 211 after the commit is performed.
  • the transaction of manager 23 is configured to replace the current transaction by the transaction manager 23 with the transaction identifier corresponding to
  • the resource registration module 232 is configured to register the resource manager 22 participating in the transaction to the transaction adapter 211 corresponding to the transaction identifier, whereby the transaction adapter 211 can forward the received submission request to the corresponding resource manager 22.
  • the resource logout module 233 is used to log out of the resource manager 22 from the transaction adapter 211 after the commit is performed.
  • the delete module 213 of the transaction mapping module 21 is configured to delete the transaction adapter 211 corresponding to the transaction identifier and the correspondence between the transaction identifier and the transaction adapter after the commit is performed, so that the space can be released in time.
  • a first flowchart of a distributed transaction processing method for a transaction resource usage end includes the following steps:
  • Step A101 Registering a transaction resource client
  • Step A102 Submit, by using the registered transaction resource client, a submit request carrying a transaction identifier to the transaction resource server;
  • Step A103 Unregister the transaction resource client.
  • This embodiment implements cross-system distributed transaction processing based on non-JCA architecture, and is applicable to J2SE-based, J2EE-based application systems and non-Java application systems based on C++ and C#.
  • the first flowchart of the distributed transaction processing method of the transaction resource server in the embodiment of the present invention includes the following steps:
  • Step B101 Search for a transaction adapter corresponding to the transaction identifier according to the transaction identifier carried in the service operation request.
  • Step B102 Replace the current transaction with the transaction manager by the transaction manager;
  • Step B103 Perform a business operation according to the service operation request, where the business operation includes adding, deleting, changing, checking, and publishing the data;
  • Step B104 Register the resource manager to a transaction adapter corresponding to the transaction identifier.
  • Step B105 Forward the submit request to the corresponding transaction adapter according to the transaction identifier carried in the submit request, and the transaction adapter performs the commit through the registered resource manager.
  • This embodiment implements cross-system distributed transaction processing based on non-JCA architecture. It is applicable to J2SE-based or non-Java application systems.
  • the transaction adapter is responsible for the management of one transaction operation, and the transaction adapter as an interface is easy to use.
  • FIG. 10 it is a second flowchart of a distributed transaction processing method for a transaction resource usage end according to an embodiment of the present invention.
  • the transaction coordinator manages the coordinated transaction operation through the transaction proxy module, and adopts a two-phase commit mode when submitting the submit request, so that the use terminal can effectively control the transaction unification.
  • This embodiment includes the following steps:
  • Step A201 Create a transaction proxy module, and generate a transaction identifier.
  • Step A202 Send a service operation request to a transaction resource client participating in the transaction;
  • Step A203 registering the transaction resource client and notifying the transaction agent module of the registration information;
  • Step A204 The transaction resource client submits a service operation request carrying the transaction identifier to the transaction resource server;
  • Step A205 determining whether the service operation request is successful, if step A206 is successfully executed;
  • Step A206 Submit a submit request to the transaction proxy module
  • Step A207 The transaction proxy module submits a submission preparation request carrying the transaction identifier to the transaction resource server by using the registered transaction resource client;
  • Step A208 determining whether the submission preparation is successful, if step A209 is successfully executed;
  • Step A209 The transaction proxy module submits a submit operation request carrying the transaction identifier to the transaction resource server through the registered transaction resource client.
  • the submission of the submission request adopts a two-phase submission mode, that is, the first phase submits the submission preparation request, and the second phase submits the submission operation request, so that the use end can effectively control the consistency of the data operation, thereby realizing the cross-transaction management.
  • the affairs of the device are unified.
  • the distributed transaction processing method of the transaction resource server is the first embodiment of the present invention.
  • the two-phase submission mode of the transaction resource usage end includes the following steps: Step B201: Receive a service operation request, and search for a corresponding transaction adapter according to the transaction identifier carried in the service operation request.
  • Step B202 Replace the current transaction by the transaction manager with the transaction adapter;
  • Step B203 perform a business operation;
  • Step B204 Register the resource manager to a transaction adapter corresponding to the transaction identifier
  • Step B205 Receive a submission preparation request, and forward the submission preparation request to the corresponding transaction adapter according to the transaction identifier carried in the submission preparation request, and the transaction adapter performs the preparation of the submission through the registered resource manager and returns the execution result;
  • Step B206 Receive a submit operation request, and forward the submit preparation request to the corresponding transaction adapter according to the transaction identifier carried in the submit operation request, and the transaction adapter performs the submit operation by using the registered resource manager.
  • This embodiment implements non-JCA-based cross-system transaction coordination.
  • the transaction unification can be uniformly controlled by the transaction resource use end, and the upper layer of the transaction manager controls the transaction to realize the distributed transaction processing requirement. Atomicity, consistency, isolation and durability.
  • FIG. 12 it is a third flowchart of a distributed transaction processing method for a transaction resource usage end according to an embodiment of the present invention.
  • multiple transaction resource clients need to initiate service requests one by one, register them, and send submission requests and submit operation requests one by one.
  • This embodiment includes the following steps:
  • Step A301 The transaction resource use end application starts a transaction by using a transaction coordinator
  • Step A302 The transaction coordinator creates a transaction proxy module and generates a transaction identifier, where the transaction identifier may be a transaction serial number;
  • Step A303 The transaction resource use end application sends a service operation request to the transaction resource client participating in the transaction;
  • Step A304 The transaction resource client registers as a resource proxy to the transaction coordinator;
  • Step A305 The transaction coordinator notifies the transaction agent module of the registration information;
  • Step A306 The transaction resource client submits a service operation request carrying the transaction identifier to the transaction resource server.
  • Step A307 Determine whether the service operation request is successful, if step A308 is successfully executed; for each transaction resource, the method for determining whether each service operation request is successful may be different, and some systems may return a response regardless of whether the execution succeeds or fails, and some systems return The response will only be returned when an exception occurs, which needs to be determined based on the specific definition of the system;
  • Step A308 determining whether all transaction resource clients participating in the transaction have been registered, and have sent a business operation request, and if yes, executing step A309, otherwise, performing step A303;
  • Step A309 The transaction resource use end application submits a submit request to the transaction coordinator;
  • Step A310 The transaction coordinator forwards the submit request to the transaction proxy module.
  • Step A311 The transaction proxy module submits a submission preparation request carrying the transaction identifier to the registered transaction resource client.
  • Step A312 The transaction resource client submits a submission preparation request carrying a transaction identifier to the transaction resource server.
  • Step A313 The transaction resource client receives the response returned by the transaction resource server.
  • Step A314 The transaction resource client forwards the response to the transaction proxy module.
  • Step A315 the transaction agent module determines whether the submission preparation is successful, if the step A316 is successfully executed; Step A316, determining whether the submission preparation request has been sent to the registered transaction resource clients, if yes, executing step A317, otherwise performing step A311;
  • Step A317 The transaction proxy module submits a submit operation request carrying the transaction identifier to the registered transaction resource client.
  • Step A318 The transaction resource client submits a submit operation request carrying the transaction identifier to the transaction resource server.
  • Step A319 the transaction coordinator cancels the transaction resource client
  • Step A320 The transaction coordinator notifies the transaction agent module of the logout information
  • Step A321 Determine whether a submit operation request has been sent to each registered transaction resource client. If no, go to step A317.
  • This embodiment implements non-JCA-based cross-system transaction coordination.
  • the transaction coordinator can actively control the transaction uniformity across the transaction manager, control the transaction at the upper layer of the transaction manager, and implement distributed The atomicity, consistency, isolation, and durability required for transaction processing.
  • FIG. 13 is a third flowchart of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention.
  • the execution of the transaction in this embodiment involves multiple resource managers.
  • the request is forwarded to each resource manager in turn, and after the transaction is executed, the resource managers are deleted and the transaction identifier is deleted.
  • This embodiment specifically includes the following steps:
  • Step B301 The transaction resource server application receives the service operation request.
  • Step B302 the transaction resource server application sends a query request to the transaction mapping module;
  • Step B303 the transaction mapping module looks up the transaction adapter corresponding to the transaction identifier; if found, proceeds to step B306, otherwise, step B304;
  • Step B304 The transaction resource server application creates a transaction adapter.
  • Step B305 the transaction resource server saves the transaction adapter and the transaction identifier;
  • Step B306 the transaction resource server replaces the current transaction by the transaction manager transaction with the transaction identifier corresponding to the transaction identifier;
  • Step B307 The transaction resource server application performs a business operation
  • Step B308 Calling multiple resource managers during a business operation
  • Step B309 Each resource manager obtains a transaction
  • Step B310 each resource manager is registered to the transaction adapter
  • Step B311 The transaction resource server application receives the submission preparation request.
  • Step B312 The transaction resource server application queries the transaction mapping module for the transaction adapter corresponding to the transaction identifier.
  • Step B313 The transaction mapping module searches for a transaction adapter corresponding to the transaction identifier and returns a search result to the transaction resource server application.
  • Step B314 The transaction resource server application forwards the submit preparation request to the transaction adapter corresponding to the transaction identifier.
  • Step B315 the transaction adapter sends a submit preparation request to the registered resource manager;
  • Step B316 the resource manager performs the preparation of the submission, and returns the execution result to the transaction adapter;
  • Step B317 the transaction adapter determines whether the submission preparation is successful, and if so, proceeds to step B318;
  • Step B318, the transaction adapter determines whether the registered resource managers have performed the submission preparation, and if so, step B319 is performed, otherwise, step B315 is performed;
  • Step B319 The transaction adapter returns an execution result to the transaction resource server application.
  • Step B320 The transaction resource server application returns an execution result to the transaction resource client.
  • Step B321 The transaction resource server application receives the submit operation request.
  • Step B322 The transaction resource server application queries the transaction mapping module for the transaction adapter corresponding to the transaction identifier.
  • Step B323 The transaction mapping module searches for a transaction adapter corresponding to the transaction identifier and returns a search result to the transaction resource server application.
  • Step B324 The transaction resource server application forwards the submit operation request to the transaction adapter corresponding to the transaction identifier;
  • Step B325 the transaction adapter sends a submit operation request to the registered resource manager;
  • Step B326 the resource manager performs a commit operation; and the resource manager is logged out from the transaction adapter;
  • Step B327 the transaction adapter determines whether each resource manager registered is Performing a submit operation, if yes, executing step B328, otherwise, performing step B325;
  • Step B328 The transaction resource server deletes the transaction adapter corresponding to the transaction identifier in the transaction mapping module.
  • Step B329 the transaction resource server will replace the current transaction by the transaction adapter with the transaction of the transaction manager.
  • This embodiment implements non-JCA-based multi-transaction resource coordination, by exposing the transaction manager's commit preparation interface, the transaction unification can be uniformly controlled by the transaction resource use end, on the transaction manager Layers control transactions, achieving atomicity, consistency, isolation, and persistence required for distributed transaction processing.
  • the embodiment of the invention implements non-JCA-based transaction unification, satisfies the data operation consistency requirement of the J2EE, J2SE (Java 2 Standard Edition) based application system and the non-Java application system based on C++, C#, etc.; exposes the transaction manager
  • the commit preparation interface is unified by the transaction controlling the transaction manager; the transaction is controlled at the upper level of the transaction manager, and the atomicity, consistency, isolation, and persistence required for distributed transaction processing are realized, and compared with the JCA architecture.
  • the interface cartridge is easy to use.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A transaction coordinator (11), transaction resource using terminal (1) and service terminal (2) are disclosed, a method for processing the distributed transaction by the transaction resource using terminal (1) and the service terminal (2) is also disclosed. The using terminal (1) registers the transaction resource client terminal (12); submitts a submitting request through the registered transaction resource client terminal (12); logs out the transaction resource client terminal (12). According to the transaction identifier in the service operation request, the service terminal (2) looks up the corresponding transaction adapter (211); replaces the current transaction with the transaction adapter (211); executes the service operation; registers the resource manager (22) to the transaction adapter (211) cooresponding to the transaction identifier; according to the transaction identifier in the submitting request, conveys the submitting request to the corresponding transaction adapter (211), executes the submit through the registered resource manager (22).

Description

事务协调器、 资源使用端、 服务端及分布式事务处理方法 技术领域  Transaction coordinator, resource usage end, server side, and distributed transaction processing method
本发明涉及分布式事务处理技术, 尤其涉及能够实现跨系统分布式事务 处理的事务协调器、 事务资源使用端、 服务端以及事务资源使用端、 服务端 处理分布式事务的方法。 背景技术  The present invention relates to a distributed transaction processing technology, and more particularly to a method for a transaction coordinator, a transaction resource user, a server, a transaction resource user, and a server to process a distributed transaction. Background technique
随着企业应用系统的广泛发展, 财务管理系统、 管理分析系统、 营业系 统, 客户关系管理系统、 物流管理系统、 计费系统等系统间存在着越来越多 的信息交互, 这要求企业数据具有一致性。 企业数据一致性的需求要求数据 操作具有原子性,一致性,隔离性,持久性(Atomicity, Consistency, Isolation, Durability, 筒称 ACID), 即要求进行分布式事务处理, 并且事务处理需要在 多个事务性资源间实现。  With the extensive development of enterprise application systems, there are more and more information interactions between financial management systems, management analysis systems, business systems, customer relationship management systems, logistics management systems, billing systems, etc., which requires enterprise data to have consistency. The need for enterprise data consistency requires atomicity, consistency, isolation, and persistence (Atomicity, Consistency, Isolation, Durability, ACID), which requires distributed transaction processing, and transaction processing needs to be multiple Implemented between transactional resources.
事务是指作为工作的单一逻辑单元而执行的一系列操作。 分布式事务是 指两个或更多事务资源 (比如, 两个单独的数据库)之间的 ACID事务。  A transaction is a series of operations performed as a single logical unit of work. A distributed transaction is an ACID transaction between two or more transactional resources (for example, two separate databases).
现有的基于 J2EE连接架构(J2EE Connector Architecture, 筒称 JCA )的 事务统一框架实现了跨系统的事务统一。 在该框架下, 资源适配器(Resource Adapter )提供了连接 ( Connection )和连接工厂 ( Connection Factory )接口, 连接工厂负责创建与应用系统 ( Application System ) 的连接。 连结管理 ( Connection Manager )统一管理不同应用系统的连接。 当连接管理接收到来 自连接工厂的连接请求时, 连接管理从连接的緩存容器一一连接池(Pool Manager ) 中获取连接。 如果连接池无可用的连接, 则会调用管理连接工厂 ( Managed Connection Factory )创建一个新的物理连接。  The existing transactional unified framework based on the J2EE Connector Architecture (J2EE Connector Architecture, JCA) implements cross-system transaction unification. Under this framework, the Resource Adapter provides a Connection and Connection Factory interface, and the connection factory is responsible for creating connections to the Application System. The Connection Manager manages the connections of different application systems. When connection management receives a connection request from a connection factory, connection management obtains the connection from the connected cache container, Pool Manager. If there is no connection available in the connection pool, a new physical connection is created by calling the Managed Connection Factory.
现有的基于 JCA的事务统一构架存在如下缺陷: 接口复杂, 实现困难, 甚至有些现有系统在机制上就无法实现 JCA 的标准接口, 其仅适用于基于 J2EE规范构建的应用系统, 并不能解决不基于 J2EE规范或者非 Java应用系 统的数据一致性需求, 如 C++应用, #应用等。 发明内容 The existing JCA-based transactional unified architecture has the following drawbacks: Interface is complex, implementation is difficult, and even some existing systems cannot implement JCA's standard interface in mechanism, which is only applicable to The application system built by the J2EE specification cannot solve the data consistency requirements not based on the J2EE specification or non-Java application system, such as C++ application, #application, etc. Summary of the invention
本发明实施例的目的在于提供了接口筒单, 符合数据一致性要求的事务 协调器、 事务资源使用端、 事务资源服务端、 以及事务资源使用端、 服务端 的分布式事务处理方法, 实现跨系统分布式事务处理, 并适用于基于 J2EE、 J2SE ( Java 2 Standard Edition )、 C++、 #等多种应用系统。  The purpose of the embodiments of the present invention is to provide an interface device, a transaction coordinator that conforms to data consistency requirements, a transaction resource usage end, a transaction resource server, a transaction resource usage end, and a server-side distributed transaction processing method to implement a cross-system. Distributed transaction processing, and is applicable to a variety of application systems based on J2EE, J2SE (Java 2 Standard Edition), C++, #.
为了实现上述目的, 本发明实施例提供了一种事务资源使用端的分布式 事务处理方法, 包括如下步骤:  In order to achieve the above object, an embodiment of the present invention provides a distributed transaction processing method for a transaction resource usage end, which includes the following steps:
注册事务资源客户端;  Register a transactional resource client;
利用所述事务资源客户端向事务资源服务端提交携带有事务标识的提交 请求; 及  Submitting, by the transaction resource client, a submission request carrying a transaction identifier to a transaction resource server; and
注销事务资源客户端。  Log out of the transaction resource client.
为了实现上述目的, 本发明实施例还提供了一种事务资源服务端的分布 式事务处理方法, 包括: 根据业务操作请求中携带的事务标识查找对应的事 务适配器; 将当前事务替换为所述事务适配器; 根据所述业务操作请求执行 业务操作; 将资源管理器注册到所述事务适配器; 根据提交请求中携带的事 务标识将所述提交请求转发至所述事务适配器; 及通过所述资源管理器执行 提交。  In order to achieve the above object, an embodiment of the present invention further provides a distributed transaction processing method of a transaction resource server, including: searching for a corresponding transaction adapter according to a transaction identifier carried in a service operation request; and replacing a current transaction with the transaction adapter Performing a business operation according to the business operation request; registering a resource manager to the transaction adapter; forwarding the submit request to the transaction adapter according to a transaction identifier carried in the submit request; and executing by the resource manager submit.
为了实现上述目的, 本发明实施例又提供了一种事务协调器, 包括: 事 务代理模块, 用于通过注册的事务资源客户端提交携带有事务标识的提交请 求; 注册模块, 用于注册参与当前事务的事务资源客户端, 并将注册信息通 知所述事务代理模块; 所述事务资源客户端至少为一个; 提交请求转发模块, 用于向事务代理模块提交提交请求; 以及注销模块, 用于注销当前事务的事 务资源客户端, 并将注销信息通知所述事务代理模块。 为了实现上述目的, 本发明实施例还提供了一种事务资源使用端, 包括: 事务协调器, 用于协调事务资源, 进行分布式事务控制, 该事务协调器 包括: 事务代理模块用于通过注册的事务资源客户端提交携带有事务标识的 提交请求; 注册模块, 用于注册参与当前事务的事务资源客户端, 并将注册 信息通知事务代理模块; 所述事务资源客户端至少为一个; 提交请求转发模 块, 用于向事务代理模块提交提交请求; 及注销模块, 用于注销当前事务的 事务资源客户端, 并将注销信息通知事务代理模块; In order to achieve the above object, an embodiment of the present invention further provides a transaction coordinator, including: a transaction proxy module, configured to submit a submission request carrying a transaction identifier by using a registered transaction resource client; and a registration module, configured to register to participate in the current a transaction resource client of the transaction, and notifying the transaction agent module of the registration information; the transaction resource client is at least one; the submit request forwarding module is configured to submit a submit request to the transaction proxy module; and the logout module is configured to log off The transaction resource client of the current transaction, and notifies the transaction agent module of the logout information. In order to achieve the above object, an embodiment of the present invention further provides a transaction resource usage end, including: a transaction coordinator, configured to coordinate transaction resources, and perform distributed transaction control, where the transaction coordinator includes: a transaction proxy module for registering The transaction resource client submits the commit request carrying the transaction identifier; the registration module is configured to register the transaction resource client participating in the current transaction, and notify the transaction proxy module of the registration information; the transaction resource client is at least one; submit the request a forwarding module, configured to submit a submit request to the transaction proxy module; and a logout module, configured to cancel the transaction resource client of the current transaction, and notify the transaction proxy module of the logout information;
业务操作请求模块, 用于通过的事务资源客户端提交携带有事务标识的 业务操作请求;  a service operation requesting module, configured to submit, by the transaction resource client, a business operation request carrying a transaction identifier;
提交请求模块, 用于发起提交请求;  Submit a request module for initiating a submit request;
事务资源客户端, 用于与事务资源服务端通信, 提交业务操作请求及提 交请求。  A transaction resource client, used to communicate with a transaction resource server, submit a business operation request, and submit a request.
为了实现上述目的, 本发明实施例再提供了一种事务资源服务端, 包括: 事务映射模块, 用于查找事务标识对应的事务适配器; 该事务映射模块 包括: 事务适配器, 用于将提交请求转发至注册的资源管理器; 记录模块, 用于记录事务标识与事务适配器的对应关系及查找模块, 用于查找事务标识 对应的事务适配器;  In order to achieve the above object, an embodiment of the present invention further provides a transaction resource server, including: a transaction mapping module, configured to search a transaction adapter corresponding to a transaction identifier; the transaction mapping module includes: a transaction adapter, configured to forward the submission request To the registered resource manager; a recording module, configured to record a correspondence between the transaction identifier and the transaction adapter, and a lookup module, configured to find a transaction adapter corresponding to the transaction identifier;
事务适配器创建模块, 用于创建事务适配器, 并将事务标识与事务适配 器保存至所述记录模块;  a transaction adapter creation module, configured to create a transaction adapter, and save a transaction identifier and a transaction adapter to the recording module;
资源管理器, 用于根据所述提交请求执行提交;  a resource manager, configured to perform a submission according to the submit request;
事务管理器, 用于将当前事务替换为所述事务适配器以及资源管理器的 注册及注销。 本发明实施例由事务协调器在事务管理器上层控制事务, 实现了分布式 事务处理要求的原子性、 一致性、 隔离性和持久性, 并且作为接口的事务适 配器筒单易用; 本发明实施例实现了跨系统的分布式事务处理, 满足了基于 A transaction manager that replaces the current transaction with the transaction adapter and the registration and deregistration of the resource manager. In the embodiment of the present invention, the transaction coordinator controls the transaction at the upper layer of the transaction manager, and realizes the atomicity, consistency, isolation, and durability required by the distributed transaction processing, and the transaction adapter as an interface is easy to use; The example implements cross-system distributed transaction processing, which is based on
J2EE、 J2SE ( Java 2 Standard Edition )、 C++、 C#等多种应用系统的数据操作 一致性需求。 Data manipulation of various application systems such as J2EE, J2SE (Java 2 Standard Edition), C++, C#, etc. Consistency requirements.
下面通过附图和实施例, 对本发明的技术方案做进一步的详细描述。 附图说明  The technical solution of the present invention will be further described in detail below through the accompanying drawings and embodiments. DRAWINGS
图 1为本发明实施例事务资源使用端的第一结构示意图;  1 is a schematic diagram of a first structure of a transaction resource usage end according to an embodiment of the present invention;
图 2为本发明实施例事务资源服务端的第一结构示意图;  2 is a schematic diagram of a first structure of a transaction resource server according to an embodiment of the present invention;
图 3为本发明实施例事务资源使用端及事务资源服务端构成的分布式事 务处理系统的结构示意图;  3 is a schematic structural diagram of a distributed transaction processing system formed by a transaction resource use end and a transaction resource server according to an embodiment of the present invention;
图 4为本发明实施例事务协调器的第一结构示意图;  4 is a schematic diagram of a first structure of a transaction coordinator according to an embodiment of the present invention;
图 5为本发明实施例事务协调器的第二结构示意图;  FIG. 5 is a schematic diagram of a second structure of a transaction coordinator according to an embodiment of the present invention;
图 6为本发明实施例事务资源使用端的第二结构示意图;  6 is a schematic diagram of a second structure of a transaction resource usage end according to an embodiment of the present invention;
图 7为本发明实施例事务资源服务端的第二结构示意图;  7 is a schematic diagram of a second structure of a transaction resource server according to an embodiment of the present invention;
图 8为本发明实施例事务资源使用端的分布式事务处理方法的第一流程 图;  8 is a first flowchart of a distributed transaction processing method of a transaction resource usage end according to an embodiment of the present invention;
图 9为本发明实施例事务资源服务端的分布式事务处理方法的第一流程 图;  9 is a first flowchart of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention;
图 10 为本发明实施例事务资源使用端的分布式事务处理方法的第二流 程图;  10 is a second flow diagram of a distributed transaction processing method for a transaction resource usage end according to an embodiment of the present invention;
图 11 为本发明实施例事务资源服务端的分布式事务处理方法的第二流 程图;  11 is a second flow diagram of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention;
图 12 为本发明实施例事务资源使用端的分布式事务处理方法的第三流 程图;  12 is a third flow diagram of a distributed transaction processing method of a transaction resource usage end according to an embodiment of the present invention;
图 13 为本发明实施例事务资源服务端的分布式事务处理方法的第三流 程图。 具体实施方式 如图 1所示, 本发明实施例事务资源使用端的第一结构示意图。 事务资 源使用端 1通过事务资源客户端 12使用事务资源服务端提供的服务。事务资 源使用端 1 包括事务协调器 11、 事务资源客户端 12、 业务操作请求模块 13 以及提交请求模块 14。 FIG. 13 is a third flowchart of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention. detailed description As shown in FIG. 1, a first structural diagram of a transaction resource usage end according to an embodiment of the present invention is shown. The transaction resource use terminal 1 uses the service provided by the transaction resource server through the transaction resource client 12. The transaction resource usage end 1 includes a transaction coordinator 11, a transaction resource client 12, a business operation request module 13, and a submission request module 14.
事务协调器 11用于协调事务资源并进行分布式事务控制,事务资源使用 端 1通过事务协调器 11开始事务。 事务资源客户端 12与事务资源服务端 2 (图中未示出)一一对应, 其用于与相应的事务资源服务端 2通信, 提交携 带有事务标识的业务操作请求及提交请求, 实现事务资源服务端 2的业务调 用。 业务操作请求模块 13用于通过事务资源客户端 12提交携带有事务标识 的业务操作请求, 业务操作包括数据的增、 删、 改、 查及消息发布等。 各事 务资源客户端 12接收到业务操作请求后, 注册到事务协调器 11 中。 提交请 求模块 14用于发起提交请求, 该模块将提交请求发送至事务协调器 11 , 事 务协调器 11通过注册的事务资源客户端 12向事务资源服务端 2发送提交请 求。  The transaction coordinator 11 is used to coordinate transaction resources and perform distributed transaction control, and the transaction resource user 1 starts the transaction through the transaction coordinator 11. The transaction resource client 12 has a one-to-one correspondence with the transaction resource server 2 (not shown), and is used for communicating with the corresponding transaction resource server 2, submitting a business operation request carrying the transaction identifier and submitting the request, implementing the transaction. The service call of resource server 2. The service operation requesting module 13 is configured to submit, by the transaction resource client 12, a service operation request carrying a transaction identifier, and the service operation includes adding, deleting, changing, checking, and publishing the data. After receiving the business operation request, each transaction resource client 12 registers with the transaction coordinator 11. The submit request module 14 is for initiating a commit request, the module sends a commit request to the transaction coordinator 11, and the transaction coordinator 11 sends a commit request to the transaction resource server 2 via the registered transaction resource client 12.
当事务涉及多个事务资源客户端时,业务操作请求模块 13可按照事务包 含的各项操作的顺序向操作对应的各事务资源客户端 12逐个发送业务操作 请求, 各事务资源客户端接收到业务操作请求后注册到事务协调器 11中, 从 而事务协调器 11可统一管理多个事务资源。  When the transaction involves multiple transaction resource clients, the business operation requesting module 13 may send the business operation request one by one to each transaction resource client 12 corresponding to the operation in the order of the operations included in the transaction, and each transaction resource client receives the service. The operation request is registered in the transaction coordinator 11, so that the transaction coordinator 11 can collectively manage a plurality of transaction resources.
本实施例基于非 JCA体系结构实现了跨系统分布式事务处理, 适用于基 于 J2EE、 J2SE、 ++及 #等多种系统。  This embodiment implements cross-system distributed transaction processing based on non-JCA architecture, and is applicable to various systems based on J2EE, J2SE, ++, and #.
如图 2所示, 为本发明实施例事务资源服务端的第一结构示意图。 事务 资源服务端 2用于通过事务资源客户端 12 (图中未示出)为事务资源使用端 1 (图中未示出 )提供服务资源, 其包括事务映射模块 21、 资源管理器 22、 事务管理器 23及事务适配器创建模块 24。  As shown in FIG. 2, it is a schematic diagram of a first structure of a transaction resource server according to an embodiment of the present invention. The transaction resource server 2 is configured to provide a service resource for the transaction resource using terminal 1 (not shown) through the transaction resource client 12 (not shown), which includes the transaction mapping module 21, the resource manager 22, and the transaction. The manager 23 and the transaction adapter create module 24.
事务映射模块 21用于查找事务标识对应的事务适配器,该事务映射模块 21包括事务适配器 211、查找模块 212及记录模块 213。事务适配器 211用于 接收提交请求并将提交请求转发至注册的资源管理器, 每一事务适配器 211 用于管理事务资源服务端 2参与的一个事务的操作, 当事务资源服务端 2参 与了多个事务时,事务映射模块 21则包括多个事务适配器 211。查找模块 212 用于查找事务标识对应的事务适配器 211。 记录模块 213用于记录事务标识 与事务适配器的对应关系。 The transaction mapping module 21 is configured to find a transaction adapter corresponding to the transaction identifier, and the transaction mapping module 21 includes a transaction adapter 211, a lookup module 212, and a recording module 213. Transaction adapter 211 is used Receiving the submit request and forwarding the submit request to the registered resource manager, each transaction adapter 211 is used to manage the operation of a transaction in which the transaction resource server 2 participates, and when the transaction resource server 2 participates in multiple transactions, the transaction map Module 21 then includes a plurality of transaction adapters 211. The lookup module 212 is configured to look up the transaction adapter 211 corresponding to the transaction identifier. The recording module 213 is configured to record the correspondence between the transaction identifier and the transaction adapter.
资源管理器 22用于根据提交请求执行提交, 其支持两阶段提交协议。 事 务管理器 23 用于将当前事务替换为所述事务适配器以及资源管理器的注册 及注销, 管理事务资源, 如物理数据库、 支持事务的内存数据库以及支持事 务接口的应用系统。 事务适配器创建模块 24用于创建事务适配器 211 , 事务 资源服务端 2接收到业务操作请求后, 若没有查找到事务标识相应的事务适 配器,则创建事务适配器 211 ,并将事务适配器 211及对应的事务标识保存至 记录模块 213。  The resource manager 22 is configured to perform the submission in accordance with the submission request, which supports the two-phase commit protocol. The transaction manager 23 is used to replace the current transaction with the registration and deregistration of the transaction adapter and the resource manager, and to manage transaction resources such as a physical database, an in-memory database that supports transactions, and an application system that supports the transaction interface. The transaction adapter creation module 24 is configured to create a transaction adapter 211. After receiving the business operation request, the transaction resource server 2 creates a transaction adapter 211 if the transaction identifier corresponding to the transaction identifier is not found, and the transaction adapter 211 and the corresponding transaction. The identification is saved to the recording module 213.
本实施例基于非 JCA体系结构实现了跨系统分布式事务处理, 由事务适 配器负责一次事务操作的管理, 作为接口的事务适配器筒单易用, 适用于基 于 J2EE、 J2SE、 ++及 #等的多种应用系统。  This embodiment implements cross-system distributed transaction processing based on non-JCA architecture. The transaction adapter is responsible for the management of one transaction operation. The transaction adapter as an interface is easy to use, and is suitable for J2EE, J2SE, ++, and #, etc. A variety of application systems.
如图 3所示, 为本发明实施例事务资源使用端及事务资源服务端构成的 分布式事务处理系统结构示意图。 从本图中可以看出, 事务资源使用端 1通 过事务资源客户端 12与事务资源服务系统 2连接, 事务资源客户端 12与事 务资源月良务系统 2——对应。  As shown in FIG. 3, it is a schematic structural diagram of a distributed transaction processing system formed by a transaction resource use end and a transaction resource server according to an embodiment of the present invention. As can be seen from the figure, the transaction resource use terminal 1 is connected to the transaction resource service system 2 through the transaction resource client 12, and the transaction resource client 12 corresponds to the transaction resource monthly service system 2.
如图 4所示, 为本发明实施例事务协调器第一结构示意图。 事务协调器 11包括注册模块 112、提交请求转发模块 113、注销模块 114及事务代理模块 115。  As shown in FIG. 4, it is a schematic diagram of a first structure of a transaction coordinator according to an embodiment of the present invention. The transaction coordinator 11 includes a registration module 112, a submission request forwarding module 113, a logout module 114, and a transaction proxy module 115.
注册模块 112用于注册参与当前事务的事务资源客户端 12, 并将注册信 息通知事务代理模块 115。 事务资源客户端 12作为资源代理注册到注册模块 112。 提交请求转发模块 113接收到提交请求模块 14发送的提交请求后, 通 过事务代理模块 115提交携带有事务标识的提交请求。 事务代理模块 115在 一个事务中管理参与本事务的, 即作为资源代理注册的事务资源客户端 12, 其通过事务资源客户端 12提交携带有事务标识的提交请求,并且支持以两阶 段提交方式提交该提交请求。 注销模块 114用于在提交提交请求后将当前事 务的事务资源客户端 12注销, 并将注销信息通知事务代理模块 115。 The registration module 112 is configured to register the transaction resource client 12 participating in the current transaction and notify the transaction agent module 115 of the registration information. The transaction resource client 12 registers as a resource agent to the registration module 112. After receiving the submit request sent by the submit request module 14, the submit request forwarding module 113 submits the commit request carrying the transaction identifier through the transaction proxy module 115. Transaction proxy module 115 A transaction resource client 12 registered as a resource agent is managed in a transaction, which submits a commit request carrying a transaction identifier through the transaction resource client 12, and supports submitting the commit request in a two-phase commit manner. The logout module 114 is configured to log out the transaction resource client 12 of the current transaction after submitting the commit request, and notify the transaction proxy module 115 of the logout information.
本实施例的基于非 JCA的事务协调器实现了跨系统的分布式事务管理, 满足基于 J2EE、 J2SE、 C++及 #等的多种应用系统的数据操作一致性需求。  The non-JCA-based transaction coordinator of the embodiment implements distributed transaction management across systems, and satisfies the data operation consistency requirements of multiple application systems based on J2EE, J2SE, C++, and #.
如图 5所示,本发明实施例的事务协调器还可包括创建模块 111 ,该模块 用于创建事务代理模块 115 , 并生成事务标识。  As shown in FIG. 5, the transaction coordinator of an embodiment of the present invention may further include a creation module 111 for creating a transaction proxy module 115 and generating a transaction identifier.
两阶段提交分为提交准备以及提交操作两阶段, 在提交准备阶段, 事务 资源收到请求后执行数据修改和日志记录等处理, 处理完成后只是把事务的 状态改成 "可以提交", 然后返回结果, 报告是否准备完毕。 如果所有的事务 资源都准备就绪, 则进入提交操作阶段。 在提交操作阶段, 事务的 "可以提 交" 状态改为 "提交完成" 状态。  The two-phase commit is divided into two phases: commit preparation and commit operation. In the commit preparation phase, the transaction resource performs data modification and log record processing after receiving the request. After the processing is completed, the transaction status is changed to "can submit" and then returned. As a result, the report is ready. If all transaction resources are ready, enter the commit phase. During the commit phase, the transaction's "deliverable" status is changed to the "commit complete" status.
如图 6所示, 为本发明实施例事务资源使用端第二结构示意图。 本实施 例将图 5所示事务协调器 11应用于图 2所示的事务资源使用端实施例一,并 且事务代理模块 115具体包括准备请求模块 1151以及操作请求模块 1152。  As shown in FIG. 6, it is a schematic diagram of a second structure of a transaction resource usage end according to an embodiment of the present invention. In this embodiment, the transaction coordinator 11 shown in FIG. 5 is applied to the transaction resource usage end embodiment 1 shown in FIG. 2, and the transaction proxy module 115 specifically includes a preparation request module 1151 and an operation request module 1152.
准备请求模块 1151用于提交携带有事务标识的提交准备请求;操作请求 模块 1152 用于在提交准备成功的情况下继续向注册的事务资源客户端提交 携带有事务标识的提交操作请求。  The preparation request module 1151 is configured to submit a submission preparation request carrying a transaction identifier; the operation request module 1152 is configured to continue to submit the submission operation request carrying the transaction identifier to the registered transaction resource client if the submission preparation is successful.
本实施例中, 提交请求的提交采用两阶段方式, 即第一阶段是提交准备, 第二阶段提交操作, 这样, 使用端可有效控制数据操作一致性, 从而实现跨 事务管理器的事务统一。  In this embodiment, the submission of the submission request adopts a two-stage manner, that is, the first phase is the submission preparation, and the second phase is the submission operation, so that the use terminal can effectively control the consistency of the data operation, thereby realizing the transaction unification across the transaction manager.
如图 7所示, 为本发明的事务资源服务端实施例二结构示意图。 本实施 例与图 2所示实施例的区别在于, 事务映射模块 21 进一步加入了删除模块 214, 事务管理器 23具体包括事务切换模块 231、 资源注册模块 232及资源 注销模块 233。 事务切换模块 231用于在接收到业务操作请求后, 将当前事务由事务管 理器 23的事务替换为事务标识对应的事务适配器 211 , 以及在执行提交后, 将当前事务由事务适配器 211替换为事务管理器 23的事务。 FIG. 7 is a schematic structural diagram of Embodiment 2 of a transaction resource server according to the present invention. The difference between the embodiment and the embodiment shown in FIG. 2 is that the transaction mapping module 21 further includes a deletion module 214. The transaction manager 23 specifically includes a transaction switching module 231, a resource registration module 232, and a resource logout module 233. The transaction switching module 231 is configured to replace the current transaction by the transaction manager 23 with the transaction identifier corresponding to the transaction identifier 211 after receiving the business operation request, and replace the current transaction with the transaction adapter 211 by the transaction adapter 211 after the commit is performed. The transaction of manager 23.
资源注册模块 232用于将参与本次事务的资源管理器 22注册到事务标识 对应的事务适配器 211 ,从而,事务适配器 211可以将接收到的提交请求转发 至相应的资源管理器 22。  The resource registration module 232 is configured to register the resource manager 22 participating in the transaction to the transaction adapter 211 corresponding to the transaction identifier, whereby the transaction adapter 211 can forward the received submission request to the corresponding resource manager 22.
资源注销模块 233用于在执行提交后将资源管理器 22从事务适配器 211 中注销。  The resource logout module 233 is used to log out of the resource manager 22 from the transaction adapter 211 after the commit is performed.
事务映射模块 21的删除模块 213用于在执行提交后,删除事务标识对应 的事务适配器 211及事务标识与事务适配器的对应关系, 从而可及时释放空 间。  The delete module 213 of the transaction mapping module 21 is configured to delete the transaction adapter 211 corresponding to the transaction identifier and the correspondence between the transaction identifier and the transaction adapter after the commit is performed, so that the space can be released in time.
如图 8所示, 为本发明实施例的事务资源使用端的分布式事务处理方法 第一流程图, 包括如下步骤:  As shown in FIG. 8, a first flowchart of a distributed transaction processing method for a transaction resource usage end according to an embodiment of the present invention includes the following steps:
步骤 A101、 注册事务资源客户端;  Step A101: Registering a transaction resource client;
步骤 A102、利用注册的事务资源客户端向事务资源服务端提交携带有事 务标识的提交请求;  Step A102: Submit, by using the registered transaction resource client, a submit request carrying a transaction identifier to the transaction resource server;
步骤 A103、 注销事务资源客户端。  Step A103: Unregister the transaction resource client.
本实施例基于非 JCA体系结构实现了跨系统分布式事务处理, 适用于基 于 J2SE、 J2EE的应用系统以及基于 C++、 C#等的非 Java应用系统。  This embodiment implements cross-system distributed transaction processing based on non-JCA architecture, and is applicable to J2SE-based, J2EE-based application systems and non-Java application systems based on C++ and C#.
如图 9所示, 为本发明实施例事务资源服务端的分布式事务处理方法第 一流程图, 包括如下步骤:  As shown in FIG. 9, the first flowchart of the distributed transaction processing method of the transaction resource server in the embodiment of the present invention includes the following steps:
步骤 B101、根据业务操作请求中携带的事务标识, 查找事务标识对应的 事务适配器;  Step B101: Search for a transaction adapter corresponding to the transaction identifier according to the transaction identifier carried in the service operation request.
步骤 B102、 将当前事务由事务管理器的事务替换为事务适配器;; 步骤 B103、 根据业务操作请求执行业务操作, 业务操作包括数据的增、 删、 改、 查及消息发布等; 步骤 B104、 将资源管理器注册到事务标识对应的事务适配器; Step B102: Replace the current transaction with the transaction manager by the transaction manager; Step B103: Perform a business operation according to the service operation request, where the business operation includes adding, deleting, changing, checking, and publishing the data; Step B104: Register the resource manager to a transaction adapter corresponding to the transaction identifier.
步骤 B105、根据提交请求中携带的事务标识将提交请求转发至相应的事 务适配器, 事务适配器通过注册的资源管理器执行提交。  Step B105: Forward the submit request to the corresponding transaction adapter according to the transaction identifier carried in the submit request, and the transaction adapter performs the commit through the registered resource manager.
本实施例基于非 JCA体系结构实现了跨系统分布式事务处理, 适用于基 于 J2SE或者非 Java应用系统, 由事务适配器负责一次事务操作的管理, 作 为接口的事务适配器筒单易用。  This embodiment implements cross-system distributed transaction processing based on non-JCA architecture. It is applicable to J2SE-based or non-Java application systems. The transaction adapter is responsible for the management of one transaction operation, and the transaction adapter as an interface is easy to use.
如图 10所示,为本发明实施例事务资源使用端的分布式事务处理方法第 二流程图。 本实施例事务协调器通过事务代理模块管理协调事务操作, 在提 交提交请求时采用两阶段提交方式, 从而使用端可有效地控制事务统一。 本 实施例包括如下步骤:  As shown in FIG. 10, it is a second flowchart of a distributed transaction processing method for a transaction resource usage end according to an embodiment of the present invention. In this embodiment, the transaction coordinator manages the coordinated transaction operation through the transaction proxy module, and adopts a two-phase commit mode when submitting the submit request, so that the use terminal can effectively control the transaction unification. This embodiment includes the following steps:
步骤 A201、 创建事务代理模块, 生成事务标识;  Step A201: Create a transaction proxy module, and generate a transaction identifier.
步骤 A202、 向参与事务的事务资源客户端发送业务操作请求;  Step A202: Send a service operation request to a transaction resource client participating in the transaction;
步骤 A203对事务资源客户端进行注册并将注册信息通知事务代理模块; 步骤 A204 事务资源客户端向事务资源服务端提交携带有事务标识的业 务操作请求;  Step A203: registering the transaction resource client and notifying the transaction agent module of the registration information; Step A204: The transaction resource client submits a service operation request carrying the transaction identifier to the transaction resource server;
步骤 A205、 判断业务操作请求是否成功, 若成功执行步骤 A206;  Step A205, determining whether the service operation request is successful, if step A206 is successfully executed;
步骤 A206、 向事务代理模块提交提交请求;  Step A206: Submit a submit request to the transaction proxy module;
步骤 A207、事务代理模块通过注册的事务资源客户端向事务资源服务端 提交携带有事务标识的提交准备请求;  Step A207: The transaction proxy module submits a submission preparation request carrying the transaction identifier to the transaction resource server by using the registered transaction resource client;
步骤 A208、 判断提交准备是否成功, 若成功执行步骤 A209;  Step A208, determining whether the submission preparation is successful, if step A209 is successfully executed;
步骤 A209、事务代理模块通过注册的事务资源客户端向事务资源服务端 提交携带有事务标识的提交操作请求。  Step A209: The transaction proxy module submits a submit operation request carrying the transaction identifier to the transaction resource server through the registered transaction resource client.
本实施例中, 提交请求的提交采用两阶段提交方式, 即第一阶段提交提 交准备请求, 第二阶段进行提交提交操作请求, 这样, 使用端可有效控制数 据操作一致性, 从而实现跨事务管理器的事务统一。  In this embodiment, the submission of the submission request adopts a two-phase submission mode, that is, the first phase submits the submission preparation request, and the second phase submits the submission operation request, so that the use end can effectively control the consistency of the data operation, thereby realizing the cross-transaction management. The affairs of the device are unified.
如图 11所示,为本发明实施例事务资源服务端的分布式事务处理方法第 二流程图。 本实施例配合事务资源使用端的两阶段提交方式, 包括如下步骤: 步骤 B201、接收业务操作请求,根据业务操作请求中携带的事务标识查 找对应的事务适配器; As shown in FIG. 11, the distributed transaction processing method of the transaction resource server is the first embodiment of the present invention. Second flow chart. In this embodiment, the two-phase submission mode of the transaction resource usage end includes the following steps: Step B201: Receive a service operation request, and search for a corresponding transaction adapter according to the transaction identifier carried in the service operation request.
步骤 B202、 将当前事务由事务管理器的事务替换为事务适配器; 步骤 B203、 执行业务操作;  Step B202: Replace the current transaction by the transaction manager with the transaction adapter; Step B203, perform a business operation;
步骤 B204、 将资源管理器注册到事务标识对应的事务适配器;  Step B204: Register the resource manager to a transaction adapter corresponding to the transaction identifier;
步骤 B205、接收提交准备请求,根据提交准备请求中携带的事务标识将 提交准备请求转发至相应的事务适配器, 事务适配器通过注册的资源管理器 执行提交准备并返回执行结果;  Step B205: Receive a submission preparation request, and forward the submission preparation request to the corresponding transaction adapter according to the transaction identifier carried in the submission preparation request, and the transaction adapter performs the preparation of the submission through the registered resource manager and returns the execution result;
步骤 B206、接收提交操作请求,根据提交操作请求中携带的事务标识将 提交准备请求转发至相应的事务适配器, 事务适配器通过注册的资源管理器 执行提交操作。  Step B206: Receive a submit operation request, and forward the submit preparation request to the corresponding transaction adapter according to the transaction identifier carried in the submit operation request, and the transaction adapter performs the submit operation by using the registered resource manager.
本实施例实现了基于非 JCA的跨系统事务协调, 通过暴露事务管理器的 提交准备接口, 事务统一可由事务资源使用端统一控制, 在事务管理器的上 层控制事务, 实现分布式事务处理要求的原子性、 一致性、 隔离性和持久性。  This embodiment implements non-JCA-based cross-system transaction coordination. By exposing the transaction manager's commit preparation interface, the transaction unification can be uniformly controlled by the transaction resource use end, and the upper layer of the transaction manager controls the transaction to realize the distributed transaction processing requirement. Atomicity, consistency, isolation and durability.
如图 12所示,为本发明实施例事务资源使用端的分布式事务处理方法第 三流程图。 本实施例中参与事务的事务资源有多个, 在创建事务时, 需要对 多个事务资源客户端逐个发起业务请求, 对其进行注册, 并逐个发送提交准 备请求及提交操作请求。 本实施例包括如下步骤:  As shown in FIG. 12, it is a third flowchart of a distributed transaction processing method for a transaction resource usage end according to an embodiment of the present invention. In this embodiment, there are multiple transaction resources participating in the transaction. When creating a transaction, multiple transaction resource clients need to initiate service requests one by one, register them, and send submission requests and submit operation requests one by one. This embodiment includes the following steps:
步骤 A301、 事务资源使用端应用通过事务协调器开始事务;  Step A301: The transaction resource use end application starts a transaction by using a transaction coordinator;
步骤 A302、 事务协调器创建事务代理模块并生成事务标识, 该事务标识 可以为事务序列号;  Step A302: The transaction coordinator creates a transaction proxy module and generates a transaction identifier, where the transaction identifier may be a transaction serial number;
步骤 A303、事务资源使用端应用向参与事务的事务资源客户端发送业务 操作请求;  Step A303: The transaction resource use end application sends a service operation request to the transaction resource client participating in the transaction;
步骤 A304、 事务资源客户端作为资源代理注册到事务协调器;  Step A304: The transaction resource client registers as a resource proxy to the transaction coordinator;
步骤 A305、 事务协调器将注册信息通知事务代理模块; 步骤 A306、事务资源客户端向事务资源服务端提交携带有事务标识的业 务操作请求; Step A305: The transaction coordinator notifies the transaction agent module of the registration information; Step A306: The transaction resource client submits a service operation request carrying the transaction identifier to the transaction resource server.
步骤 A307、 判断业务操作请求是否成功, 若成功执行步骤 A308; 对于 各事务资源, 判断各业务操作请求是否成功的方法可能不同, 有的系统无论 执行成功还是失败, 均会返回响应, 有的系统只会在出现异常时返回响应, 这需要根据系统的具体定义来确定;  Step A307: Determine whether the service operation request is successful, if step A308 is successfully executed; for each transaction resource, the method for determining whether each service operation request is successful may be different, and some systems may return a response regardless of whether the execution succeeds or fails, and some systems return The response will only be returned when an exception occurs, which needs to be determined based on the specific definition of the system;
步骤 A308、 判断是否参与本次事务的所有事务资源客户端均已注册, 并 已发送业务操作请求, 若是, 执行步骤 A309, 否则, 执行步骤 A303;  Step A308, determining whether all transaction resource clients participating in the transaction have been registered, and have sent a business operation request, and if yes, executing step A309, otherwise, performing step A303;
步骤 A309、 事务资源使用端应用向事务协调器提交提交请求;  Step A309: The transaction resource use end application submits a submit request to the transaction coordinator;
步骤 A310、 事务协调器向事务代理模块转发提交请求;  Step A310: The transaction coordinator forwards the submit request to the transaction proxy module.
步骤 A311、事务代理模块向注册的事务资源客户端提交携带有事务标识 的提交准备请求;  Step A311: The transaction proxy module submits a submission preparation request carrying the transaction identifier to the registered transaction resource client.
步骤 A312、事务资源客户端向事务资源服务端提交携带有事务标识的提 交准备请求;  Step A312: The transaction resource client submits a submission preparation request carrying a transaction identifier to the transaction resource server.
步骤 A313、 事务资源客户端接收事务资源服务端返回的响应  Step A313: The transaction resource client receives the response returned by the transaction resource server.
步骤 A314、 事务资源客户端将响应转发至事务代理模块;  Step A314: The transaction resource client forwards the response to the transaction proxy module.
步骤 A315、事务代理模块判断提交准备是否成功,若成功执行步骤 A316; 步骤 A316、 判断是否已向注册的各事务资源客户端发送提交准备请求, 若是, 执行步骤 A317, 否则执行步骤 A311 ;  Step A315, the transaction agent module determines whether the submission preparation is successful, if the step A316 is successfully executed; Step A316, determining whether the submission preparation request has been sent to the registered transaction resource clients, if yes, executing step A317, otherwise performing step A311;
步骤 A317、事务代理模块向注册的事务资源客户端提交携带有事务标识 的提交操作请求;  Step A317: The transaction proxy module submits a submit operation request carrying the transaction identifier to the registered transaction resource client.
步骤 A318、事务资源客户端向事务资源服务端提交携带有事务标识的提 交操作请求;  Step A318: The transaction resource client submits a submit operation request carrying the transaction identifier to the transaction resource server.
步骤 A319、 事务协调器注销事务资源客户端;  Step A319, the transaction coordinator cancels the transaction resource client;
步骤 A320、 事务协调器将注销信息通知事务代理模块;  Step A320: The transaction coordinator notifies the transaction agent module of the logout information;
步骤 A321、 判断是否已向注册的各事务资源客户端发送提交操作请求, 若否, 执行步骤 A317。 Step A321: Determine whether a submit operation request has been sent to each registered transaction resource client. If no, go to step A317.
本实施例实现了基于非 JCA的跨系统事务协调, 通过暴露事务管理器的 提交准备接口, 事务协调器可主动控制跨越事务管理器的事务统一, 在事务 管理器的上层控制事务, 实现分布式事务处理要求的原子性、 一致性、 隔离 性和持久性。  This embodiment implements non-JCA-based cross-system transaction coordination. By exposing the transaction manager's commit preparation interface, the transaction coordinator can actively control the transaction uniformity across the transaction manager, control the transaction at the upper layer of the transaction manager, and implement distributed The atomicity, consistency, isolation, and durability required for transaction processing.
如图 13所示,为本发明实施例事务资源服务端的分布式事务处理方法第 三流程图。 本实施例中事务的执行涉及多个资源管理器, 在执行业务操作以 及执行提交时, 依次向各资源管理器转发请求, 在事务执行完毕后注销各资 源管理器并删除事务标识。 本实施例具体包括如下步骤:  FIG. 13 is a third flowchart of a distributed transaction processing method of a transaction resource server according to an embodiment of the present invention. The execution of the transaction in this embodiment involves multiple resource managers. When performing the business operation and executing the commit, the request is forwarded to each resource manager in turn, and after the transaction is executed, the resource managers are deleted and the transaction identifier is deleted. This embodiment specifically includes the following steps:
步骤 B301、 事务资源服务端应用接收业务操作请求;  Step B301: The transaction resource server application receives the service operation request.
步骤 B302、 事务资源服务端应用向事务映射模块发查询请求; 步骤 B303、 事务映射模块查找事务标识对应的事务适配器; 若查找到, 执行步骤 B306, 否则, 执行步骤 B304;  Step B302, the transaction resource server application sends a query request to the transaction mapping module; Step B303, the transaction mapping module looks up the transaction adapter corresponding to the transaction identifier; if found, proceeds to step B306, otherwise, step B304;
步骤 B304、 事务资源服务端应用创建事务适配器;  Step B304: The transaction resource server application creates a transaction adapter.
步骤 B305、 事务资源服务端将事务适配器与事务标识进行保存; 步骤 B306、事务资源服务端将当前事务由事务管理器的事务替换为事务 标识对应的事务适配器;  Step B305, the transaction resource server saves the transaction adapter and the transaction identifier; Step B306, the transaction resource server replaces the current transaction by the transaction manager transaction with the transaction identifier corresponding to the transaction identifier;
步骤 B307、 事务资源服务端应用执行业务操作;  Step B307: The transaction resource server application performs a business operation;
步骤 B308、 执行业务操作过程中调用多个资源管理器;  Step B308: Calling multiple resource managers during a business operation;
步骤 B309、 各资源管理器获取事务;  Step B309: Each resource manager obtains a transaction;
步骤 B310、 各资源管理器注册到事务适配器;  Step B310, each resource manager is registered to the transaction adapter;
步骤 B311、 事务资源服务端应用接收提交准备请求;  Step B311: The transaction resource server application receives the submission preparation request.
步骤 B312、事务资源服务端应用向事务映射模块查询事务标识对应的事 务适配器;  Step B312: The transaction resource server application queries the transaction mapping module for the transaction adapter corresponding to the transaction identifier.
步骤 B313、事务映射模块查找事务标识对应的事务适配器并向事务资源 服务端应用返回查找结果; 步骤 B314、事务资源服务端应用将提交准备请求转发至事务标识对应的 事务适配器; Step B313: The transaction mapping module searches for a transaction adapter corresponding to the transaction identifier and returns a search result to the transaction resource server application. Step B314: The transaction resource server application forwards the submit preparation request to the transaction adapter corresponding to the transaction identifier.
步骤 B315、 事务适配器向注册的资源管理器发送提交准备请求; 步骤 B316、 资源管理器执行提交准备, 向事务适配器返回执行结果; 步骤 B317、 事务适配器判断提交准备是否成功, 若是, 执行步骤 B318; 步骤 B318、 事务适配器判断是否注册的各资源管理器均已执行提交准 备, 若是, 执行步骤 B319, 否则, 执行步骤 B315;  Step B315, the transaction adapter sends a submit preparation request to the registered resource manager; Step B316, the resource manager performs the preparation of the submission, and returns the execution result to the transaction adapter; Step B317, the transaction adapter determines whether the submission preparation is successful, and if so, proceeds to step B318; Step B318, the transaction adapter determines whether the registered resource managers have performed the submission preparation, and if so, step B319 is performed, otherwise, step B315 is performed;
步骤 B319、 事务适配器向事务资源服务端应用返回执行结果;  Step B319: The transaction adapter returns an execution result to the transaction resource server application.
步骤 B320、 事务资源服务端应用向事务资源客户端返回执行结果; 步骤 B321、 事务资源服务端应用接收提交操作请求;  Step B320: The transaction resource server application returns an execution result to the transaction resource client. Step B321: The transaction resource server application receives the submit operation request.
步骤 B322、事务资源服务端应用向事务映射模块查询事务标识对应的事 务适配器;  Step B322: The transaction resource server application queries the transaction mapping module for the transaction adapter corresponding to the transaction identifier.
步骤 B323、事务映射模块查找事务标识对应的事务适配器并向事务资源 服务端应用返回查找结果;  Step B323: The transaction mapping module searches for a transaction adapter corresponding to the transaction identifier and returns a search result to the transaction resource server application.
步骤 B324、事务资源服务端应用将提交操作请求转发至事务标识对应的 事务适配器;  Step B324: The transaction resource server application forwards the submit operation request to the transaction adapter corresponding to the transaction identifier;
步骤 B325、 事务适配器向注册的资源管理器发送提交操作请求; 步骤 B326、资源管理器执行提交操作;从事务适配器中注销资源管理器; 步骤 B327、 事务适配器判断是否注册的各资源管理器均已执行提交操 作, 若是, 执行步骤 B328, 否则, 执行步骤 B325;  Step B325, the transaction adapter sends a submit operation request to the registered resource manager; Step B326, the resource manager performs a commit operation; and the resource manager is logged out from the transaction adapter; Step B327, the transaction adapter determines whether each resource manager registered is Performing a submit operation, if yes, executing step B328, otherwise, performing step B325;
步骤 B328、事务资源服务端删除事务映射模块中的事务标识对应的事务 适配器;  Step B328: The transaction resource server deletes the transaction adapter corresponding to the transaction identifier in the transaction mapping module.
步骤 B329、事务资源服务端将将当前事务由事务适配器替换为事务管理 器的事务。  Step B329, the transaction resource server will replace the current transaction by the transaction adapter with the transaction of the transaction manager.
本实施例实现了基于非 JCA的多事务资源协调, 通过暴露事务管理器的 提交准备接口, 事务统一可由事务资源使用端统一控制, 在事务管理器的上 层控制事务, 实现分布式事务处理要求的原子性、 一致性、 隔离性和持久性。 本发明实施例实现了基于非 JCA的事务统一, 满足了基于 J2EE、 J2SE ( Java 2 Standard Edition ) 的应用系统以及基于 C++、 C#等的非 Java应用系 统的数据操作一致性需求; 暴露事务管理器的提交准备接口, 由使用端控制 事务管理器的事务统一; 在事务管理器上层控制事务, 实现了分布式事务处 理要求的原子性、 一致性、 隔离性和持久性, 并且与 JCA架构相比, 接口筒 单易用。 This embodiment implements non-JCA-based multi-transaction resource coordination, by exposing the transaction manager's commit preparation interface, the transaction unification can be uniformly controlled by the transaction resource use end, on the transaction manager Layers control transactions, achieving atomicity, consistency, isolation, and persistence required for distributed transaction processing. The embodiment of the invention implements non-JCA-based transaction unification, satisfies the data operation consistency requirement of the J2EE, J2SE (Java 2 Standard Edition) based application system and the non-Java application system based on C++, C#, etc.; exposes the transaction manager The commit preparation interface is unified by the transaction controlling the transaction manager; the transaction is controlled at the upper level of the transaction manager, and the atomicity, consistency, isolation, and persistence required for distributed transaction processing are realized, and compared with the JCA architecture. The interface cartridge is easy to use.
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对其 限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通技术 人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或 者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不使相应技 术方案的本质脱离本发明各实施例技术方案的精神和范围。  It should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that: The technical solutions described in the foregoing embodiments are modified, or some of the technical features are equivalently replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

权利 要求 Rights request
1、 一种事务资源使用端的分布式事务处理方法, 其特征在于, 所述方法 包括如下步骤:  A distributed transaction processing method for a transaction resource usage end, characterized in that the method comprises the following steps:
注册事务资源客户端;  Register a transactional resource client;
利用所述事务资源客户端向事务资源服务端提交携带有事务标识的提交 请求; 及  Submitting, by the transaction resource client, a submission request carrying a transaction identifier to a transaction resource server; and
注销所述事务资源客户端。  Log out of the transaction resource client.
2、根据权利要求 1所述的事务资源使用端的分布式事务处理方法, 其特 征在于, 所述注册事务资源客户端的步骤之前还包括如下步骤: 创建事务代 理模块; 及生成事务标识; 所述事务代理模块, 用于通过注册的事务资源客 户端提交携带有事务标识的提交请求。  The method for processing a transaction resource usage end according to claim 1, wherein the step of registering a transaction resource client further comprises the steps of: creating a transaction proxy module; and generating a transaction identifier; A proxy module, configured to submit a submit request carrying a transaction identifier through a registered transaction resource client.
3、根据权利要求 2所述的事务资源使用端的分布式事务处理方法, 其特 征在于, 所述生成事务标识的步骤之后, 所述分布式事务处理方法还包括: 向事务资源客户端发送携带有事务标识的业务操作请求的步骤。  The distributed transaction processing method of the transaction resource usage end according to claim 2, wherein after the step of generating a transaction identifier, the distributed transaction processing method further comprises: transmitting, carrying, to the transaction resource client The step of the business operation request for the transaction identifier.
4、根据权利要求 2所述的事务资源使用端的分布式事务处理方法, 其特 征在于, 在对事务资源客户端进行注册的步骤之后还包括: 将注册信息通知 事务代理模块的步骤。  The distributed transaction processing method of the transaction resource usage end according to claim 2, wherein after the step of registering the transaction resource client, the method further comprises: the step of notifying the transaction information module of the registration information.
5、根据权利要求 1所述的事务资源使用端的分布式事务处理方法, 其特 征在于, 所述通过注册的事务资源客户端向事务资源服务端提交携带有事务 标识的提交请求的步骤具体为: 采用两阶段提交方式通过注册的事务资源客 户端向事务资源服务端提交携带有事务标识的提交请求。  The transaction processing method of the transaction resource usage end according to claim 1, wherein the step of submitting the submission request carrying the transaction identifier to the transaction resource server by the registered transaction resource client is specifically: A two-phase commit method is used to submit a commit request carrying a transaction identifier to a transaction resource server through a registered transaction resource client.
6、根据权利要求 3所述的事务资源使用端的分布式事务处理方法, 其特 征在于, 所述向事务资源客户端发送业务操作请求的步骤具体为: 依次向各 参与当前事务的事务资源客户端发送业务操作请求。  The method for processing a transaction resource usage end according to claim 3, wherein the step of transmitting a service operation request to the transaction resource client is specifically: sequentially accessing a transaction resource client participating in the current transaction Send a business operation request.
7、根据权利要求 1至 6任意一项所述的分布式事务处理方法, 其特征在 于, 所述注册事务资源客户端的步骤具体为: 依次注册参与当前事务的各事 务资源客户端。 The distributed transaction processing method according to any one of claims 1 to 6, wherein the step of registering a transaction resource client is specifically: sequentially registering events participating in the current transaction Resource client.
8、根据权利要求 1至 6任意一项所述的事务资源使用端的分布式事务处 理方法, 其特征在于, 所述通过注册的事务资源客户端向事务资源服务端提 交携带有事务标识的提交请求的步骤具体为: 向注册的多个事务资源客户端 依次提交携带有事务标识的提交准备请求, 若均成功, 则向该多个事务资源 客户端依次提交携带有事务标识的提交操作请求。  The distributed transaction processing method for a transaction resource usage end according to any one of claims 1 to 6, wherein the registered transaction resource client submits a submission request carrying a transaction identifier to a transaction resource server. The step is specifically: submitting a submitting preparation request carrying a transaction identifier to the plurality of registered transaction resource clients, and if successful, submitting a submit operation request carrying the transaction identifier to the plurality of transaction resource clients in sequence.
9、 一种事务资源服务端的分布式事务处理方法, 其特征在于, 所述方法 包括:  A distributed transaction processing method for a transaction resource server, the method comprising:
根据业务操作请求中携带的事务标识查找对应的事务适配器;  Finding a corresponding transaction adapter according to the transaction identifier carried in the service operation request;
将当前事务替换为所述事务适配器;  Replace the current transaction with the transaction adapter;
根据所述业务操作请求执行业务操作;  Performing a business operation according to the business operation request;
将资源管理器注册到所述事务适配器;  Registering a resource manager to the transaction adapter;
根据提交请求中携带的事务标识将所述提交请求转发至所述事务适配 器; 及  Forwarding the submit request to the transaction adapter based on the transaction identifier carried in the submission request; and
通过所述资源管理器执行提交。  The submission is performed by the resource manager.
10、 根据权利要求 9所述的事务资源服务端的分布式事务处理方法, 其 特征在于, 所述根据业务操作请求中携带的事务标识查找对应的事务适配器 的步骤后, 若不存在事务标识对应的事务适配器, 则创建事务适配器, 并记 录事务标识与事务适配器的对应关系。  The distributed transaction processing method of the transaction resource server according to claim 9, wherein after the step of searching for the corresponding transaction adapter according to the transaction identifier carried in the service operation request, if there is no corresponding transaction identifier The transaction adapter creates a transaction adapter and records the correspondence between the transaction ID and the transaction adapter.
11、 根据权利要求 9所述的事务资源服务端的分布式事务处理方法, 其 特征在于, 在执行提交后, 删除所述事务适配器以及所述事务标识与事务适 配器的对应关系, 并将当前事务由事务适配器替换为事务管理器的事务。  The distributed transaction processing method of the transaction resource server according to claim 9, wherein after the commit is performed, the transaction adapter and the correspondence between the transaction identifier and the transaction adapter are deleted, and the current transaction is The transaction adapter is replaced with the transaction of the transaction manager.
12、根据权利要求 9所述的事务资源服务端的处理分布式事务处理方法, 其特征在于, 所述根据提交请求中携带的事务标识将所述提交请求转发至所 述事务适配器的步骤具体为: 根据提交请求中携带的事务标识查找对应的事 务适配器, 将提交请求转发至该事务适配器。 The method for processing a distributed transaction processing of the transaction resource server according to claim 9, wherein the step of forwarding the submit request to the transaction adapter according to the transaction identifier carried in the submit request is specifically: The corresponding transaction adapter is found according to the transaction identifier carried in the submission request, and the submission request is forwarded to the transaction adapter.
13、 一种事务协调器, 其特征在于, 所述事务协调器包括: 事务代理模块, 用于利用注册的事务资源客户端提交携带有事务标识的 提交请求; A transaction coordinator, the transaction coordinator comprising: a transaction proxy module, configured to submit, by using a registered transaction resource client, a submit request carrying a transaction identifier;
注册模块, 用于注册参与当前事务的事务资源客户端, 并将注册信息通 知所述事务代理模块, 所述事务资源客户端至少为一个;  a registration module, configured to register a transaction resource client participating in the current transaction, and notify the transaction proxy module of the registration information, where the transaction resource client is at least one;
提交请求转发模块, 用于向事务代理模块转发提交请求; 及  Submitting a request forwarding module for forwarding a submit request to a transaction proxy module; and
注销模块, 用于注销当前事务的事务资源客户端, 并将注销信息通知所 述事务代理模块。  The logout module, which is used to log off the transaction resource client of the current transaction, and notifies the transaction agent module of the logout information.
14、 根据权利要求 13所述的事务协调器, 其特征在于, 所述事务协调器 还包括: 创建模块, 用于创建事务代理模块, 生成事务标识。  The transaction coordinator according to claim 13, wherein the transaction coordinator further comprises: a creation module, configured to create a transaction proxy module, and generate a transaction identifier.
15、 根据权利要求 13或 14所述的事务协调器, 其特征在于, 所述事务 代理模块具体为采用两阶段提交方式提交携带有事务标识的提交请求的事务 代理模块。  The transaction coordinator according to claim 13 or 14, wherein the transaction proxy module specifically submits a transaction proxy module carrying a commit request with a transaction identifier in a two-phase commit manner.
16、 根据权利要求 13或 14所述的事务协调器, 其特征在于, 所述事务 代理模块具体包括:  The transaction coordinator according to claim 13 or 14, wherein the transaction proxy module specifically comprises:
准备请求模块, 用于提交携带有事务标识的提交准备请求;  a request preparation module, configured to submit a submission preparation request carrying a transaction identifier;
操作请求模块, 用于向注册的事务资源客户端提交携带有事务标识的提 交操作请求。  The operation request module is configured to submit a submit operation request carrying the transaction identifier to the registered transaction resource client.
17、 一种事务资源使用端, 其特征在于, 所述事务资源使用端包括: 事务协调器, 用于协调事务资源, 进行分布式事务控制; 该事务协调器 包括:  A transaction resource usage end, wherein the transaction resource usage end comprises: a transaction coordinator, configured to coordinate transaction resources, and perform distributed transaction control; the transaction coordinator includes:
事务代理模块, 用于通过注册的事务资源客户端提交携带有事务标 识的提交请求;  a transaction proxy module, configured to submit a submission request carrying a transaction identifier through a registered transaction resource client;
注册模块, 用于注册参与当前事务的事务资源客户端, 并将注册信 息通知事务代理模块; 所述事务资源客户端至少为一个;  a registration module, configured to register a transaction resource client participating in the current transaction, and notify the transaction proxy module of the registration information; the transaction resource client is at least one;
提交请求转发模块, 用于向事务代理模块转发提交请求; 及 注销模块, 用于注销当前事务的事务资源客户端, 并将注销信息通 知事务代理模块; Submitting a request forwarding module for forwarding a submit request to a transaction proxy module; and a logout module, used to cancel the transaction resource client of the current transaction, and notify the transaction agent module of the logout information;
业务操作请求模块, 用于通过的事务资源客户端提交携带有事务标识的 业务操作请求; 及  a service operation request module, configured to submit, by the transaction resource client, a service operation request carrying a transaction identifier; and
提交请求模块, 用于发起提交请求;  Submit a request module for initiating a submit request;
事务资源客户端, 用于与事务资源服务端通信, 提交业务操作请求及提 交请求。  A transaction resource client, used to communicate with a transaction resource server, submit a business operation request, and submit a request.
18、 根据权利要求 17所述的事务资源使用端, 其特征在于, 所述事务协 调器还包括: 创建模块, 用于创建事务代理模块, 生成事务标识。  The transaction resource usage end according to claim 17, wherein the transaction coordinator further comprises: a creation module, configured to create a transaction proxy module, and generate a transaction identifier.
19、 根据权利要求 17所述的事务资源使用端, 其特征在于, 所述事务代 理模块具体为采用两阶段提交方式提交携带有事务标识的提交请求的事务代 理模块。  The transaction resource usage end according to claim 17, wherein the transaction proxy module specifically submits a transaction proxy module carrying a submission request with a transaction identifier in a two-phase commit manner.
20、 根据权利要求 17所述的事务资源使用端, 其特征在于, 所述事务代 理模块具体包括:  The transaction resource usage end according to claim 17, wherein the transaction proxy module specifically includes:
准备请求模块, 用于提交携带有事务标识的提交准备请求;  a request preparation module, configured to submit a submission preparation request carrying a transaction identifier;
操作请求模块, 用于向注册的事务资源客户端提交携带有事务标识的提 交操作请求。  The operation request module is configured to submit a submit operation request carrying the transaction identifier to the registered transaction resource client.
21、 一种事务资源服务端, 其特征在于, 所述事务资源服务端包括: 事务映射模块, 用于查找事务标识对应的事务适配器; 该事务映射模块 包括:  A transaction resource server, wherein the transaction resource server includes: a transaction mapping module, configured to search for a transaction adapter corresponding to the transaction identifier; the transaction mapping module includes:
事务适配器, 用于将提交请求转发至注册的资源管理器; 记录模块, 用于记录事务标识与事务适配器的对应关系; 及 查找模块, 用于查找事务标识对应的事务适配器;  a transaction adapter, configured to forward the submit request to the registered resource manager; a record module, configured to record a correspondence between the transaction identifier and the transaction adapter; and a lookup module, configured to find a transaction adapter corresponding to the transaction identifier;
事务适配器创建模块, 用于创建事务适配器, 并将事务标识与事务适配 器保存至所述记录模块;  a transaction adapter creation module, configured to create a transaction adapter, and save a transaction identifier and a transaction adapter to the recording module;
资源管理器, 用于根据所述提交请求执行提交; 及 事务管理器, 用于将当前事务替换为所述事务适配器以及资源管理器的 注册及注销。 a resource manager, configured to perform the submission according to the submit request; and A transaction manager that replaces the current transaction with the transaction adapter and the registration and deregistration of the resource manager.
22、 根据权利要求 21所述的事务资源服务端, 其特征在于, 所述事务管 理器具体包括:  The transaction resource server according to claim 21, wherein the transaction manager specifically comprises:
事务切换模块, 用于将当前事务由事务管理器的事务替换为事务标识对 应的事务适配器, 以及在执行提交后, 将当前事务由事务适配器替换为事务 管理器的事务;  a transaction switching module, configured to replace the current transaction by the transaction manager's transaction with the transaction adapter corresponding to the transaction identifier, and replace the current transaction with the transaction manager by the transaction adapter after the commit is performed;
资源注册模块, 用于将资源管理器注册到事务标识对应的事务适配器; 资源注销模块, 用于将资源管理器从事务适配器中注销。  a resource registration module, configured to register a resource manager with a transaction adapter corresponding to the transaction identifier; and a resource logout module, configured to log the resource manager from the transaction adapter.
23、 根据权利要求 21或 22所述的事务资源服务端, 其特征在于, 所述 事务映射模块进一步包括: 删除模块, 用于在执行提交后, 删除事务标识对 应的事务适配器。  The transaction resource server according to claim 21 or 22, wherein the transaction mapping module further comprises: a deletion module, configured to delete the transaction adapter corresponding to the transaction identifier after performing the commit.
PCT/CN2008/070471 2007-03-14 2008-03-11 Transaction coordinator, resource using terminal, service terminal, and method of distributed transaction processing WO2008110115A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN200710064412.1 2007-03-14
CNA2007100644121A CN101046815A (en) 2007-03-14 2007-03-14 Affairs coordinator, resource using end, service end and distribution affairs process method

Publications (1)

Publication Number Publication Date
WO2008110115A1 true WO2008110115A1 (en) 2008-09-18

Family

ID=38771431

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2008/070471 WO2008110115A1 (en) 2007-03-14 2008-03-11 Transaction coordinator, resource using terminal, service terminal, and method of distributed transaction processing

Country Status (2)

Country Link
CN (1) CN101046815A (en)
WO (1) WO2008110115A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102306197A (en) * 2011-09-22 2012-01-04 用友软件股份有限公司 Device and method for guaranteeing consistency of data-source-crossing operation results
CN113760519A (en) * 2020-06-07 2021-12-07 北京金山云网络技术有限公司 Distributed transaction processing method, device and system and electronic equipment

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046815A (en) * 2007-03-14 2007-10-03 华为技术有限公司 Affairs coordinator, resource using end, service end and distribution affairs process method
CN102541847A (en) * 2010-12-08 2012-07-04 金蝶软件(中国)有限公司 Method and device for loading resource files, and ERP (Enterprise Resource Planning) system
CN102347986B (en) * 2011-10-17 2014-10-22 百度在线网络技术(北京)有限公司 Multi-transaction synchronized cooperation management method, system and device thereof
JP6231675B2 (en) 2013-10-29 2017-11-15 華為技術有限公司Huawei Technologies Co.,Ltd. Transaction processing method and apparatus
CN107045453A (en) * 2016-02-05 2017-08-15 慧与发展有限责任合伙企业 Two-phase commitment protocol for distributed transaction is mixed
CN106571958A (en) * 2016-11-02 2017-04-19 新智数字科技有限公司 Method and device for building communication connection with SAP system
CN107016029B (en) * 2016-12-13 2020-11-06 创新先进技术有限公司 Method, device and system for processing service data
CN107329809B (en) * 2017-07-05 2020-11-27 国网信息通信产业集团有限公司 A distributed transaction processing method and system for multiple data sources
CN107528912A (en) * 2017-09-11 2017-12-29 金蝶软件(中国)有限公司 A kind of automatic method, system and relevant apparatus for realizing distributing real time system
CN108491252B (en) * 2018-03-13 2022-03-22 万惠投资管理有限公司 Distributed transaction processing method and distributed system
CN114422398B (en) * 2021-12-28 2024-05-14 中国电信股份有限公司 Transaction node abnormality recognition system, method and device
CN114880081A (en) * 2022-05-20 2022-08-09 中国银行股份有限公司 Distributed transaction management system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5920863A (en) * 1997-05-31 1999-07-06 International Business Machines Corporation System and method for supporting transactions for a thin client lacking a persistent store in a distributed object-oriented environment
US6038589A (en) * 1997-08-01 2000-03-14 International Business Machines Corporation Apparatus, method and computer program product for client/server computing with a transaction representation located on each transactionally involved server
JP2004295272A (en) * 2003-03-26 2004-10-21 Hitachi Ltd Transaction control method
CN101046815A (en) * 2007-03-14 2007-10-03 华为技术有限公司 Affairs coordinator, resource using end, service end and distribution affairs process method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5920863A (en) * 1997-05-31 1999-07-06 International Business Machines Corporation System and method for supporting transactions for a thin client lacking a persistent store in a distributed object-oriented environment
US6038589A (en) * 1997-08-01 2000-03-14 International Business Machines Corporation Apparatus, method and computer program product for client/server computing with a transaction representation located on each transactionally involved server
JP2004295272A (en) * 2003-03-26 2004-10-21 Hitachi Ltd Transaction control method
CN101046815A (en) * 2007-03-14 2007-10-03 华为技术有限公司 Affairs coordinator, resource using end, service end and distribution affairs process method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102306197A (en) * 2011-09-22 2012-01-04 用友软件股份有限公司 Device and method for guaranteeing consistency of data-source-crossing operation results
CN113760519A (en) * 2020-06-07 2021-12-07 北京金山云网络技术有限公司 Distributed transaction processing method, device and system and electronic equipment

Also Published As

Publication number Publication date
CN101046815A (en) 2007-10-03

Similar Documents

Publication Publication Date Title
WO2008110115A1 (en) Transaction coordinator, resource using terminal, service terminal, and method of distributed transaction processing
CN113169952B (en) A container cloud management system based on blockchain technology
EP2706700A1 (en) Computer account management system and implementation method thereof
CN104731943B (en) A kind of server and data processing method
CN113268471B (en) Method, proxy connection pool, system, device and medium for processing distributed transaction
EP3961417B1 (en) Multi-cluster database management system
US11948005B2 (en) Managed integration of constituent services of multi-service applications
WO2013066889A2 (en) Oracle rewind: metadata-driven undo
US11695840B2 (en) Dynamically routing code for executing
US6233587B1 (en) Extensible framework of key resource manager and transaction manager events for providing native support for foreign-initiated transactions
CN105915588A (en) Hybrid cloud computing management system based on data virtualization
CN105867907A (en) JSS multi-layer Web development framework design method removing service coupling
CN116157788A (en) Attachable and detachable database sessions
US12047377B2 (en) Restricted operations due to attachment of compute instances owned by different tenancies
US12099948B2 (en) Attachment and detachment of compute instances owned by different tenancies
CN109408201B (en) Transaction Management Method Based on Distributed Database
CN114328026A (en) A virtual disk backup method, device, device and medium
WO2011103729A1 (en) Method for registering, canceling self-defined shell program and corresponding system
US9135457B1 (en) System and method for recording and applying access privileges in a virtualized environment
KR20050055240A (en) Integrated management system for matadata and method thereof
US12189813B2 (en) Multiple synonymous identifiers in data privacy integration protocols
CN114443225B (en) A method for implementing an Openstack virtual machine docking with a CephFS file system
CN112733118B (en) Cloud security product user management method, device and system and readable storage medium
Paokin et al. Unified approach for provision of supercomputer center resources
Jankowski et al. Grid checkpointing architecture-a revised proposal

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 08715207

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 08715207

Country of ref document: EP

Kind code of ref document: A1