Embodiment
As shown in Figure 1, first structural representation of embodiment of the invention transaction resource use side.The service that transactionresource use side 1 uses the transaction resource service end to provide by transaction resource client 12.Transactionresource use side 1 comprisesaffairs coordinator 11,transaction resource client 12, businessoperation request module 13 and submitsrequest module 14 to.
Affairs coordinator 11 is used for the coordinate transactions resource and carries out distributed transaction control, and transactionresource use side 1 is byaffairs coordinator 11 beginning affairs.Transaction resource client 12 is corresponding one by one with transaction resource service end 2 (not shown)s, it is used for communicating by letter with correspondent transactionresource service end 2, submission carries the business operation request of Transaction Identifier and submits request to, realizes the calling service of transaction resource service end 2.Businessoperation request module 13 is used for submitting the business operation request that carries Transaction Identifier to bytransaction resource client 12, and business operation comprises increasing, delete, change, looking into of data and message issue etc.After eachtransaction resource client 12 receives the business operation request, be registered in the affairs coordinator 11.Submit to requestmodule 14 to be used for initiating to submit to request, this module will submit to request to be sent toaffairs coordinator 11, andaffairs coordinator 11 sends the request of submitting to by thetransaction resource client 12 of registration to transactionresource service end 2.
When affairs relate to a plurality of transaction resource client, the order of the operations that businessoperation request module 13 can comprise according to affairs sends the business operation request one by one to each correspondingtransaction resource client 12 of operation, each transaction resource client receives business operation request post-registration inaffairs coordinator 11, thus but a plurality of transaction resources ofaffairs coordinator 11 unified managements.
Present embodiment has been realized interdepartmental system distributed transaction processing based on non-JCA architecture, is applicable to based on multiple systems such as J2EE, J2SE, C++ and C#.
As shown in Figure 2, be first structural representation of embodiment of the invention transaction resource service end.Transactionresource service end 2 is used for providing Service Source by transaction resource client 12 (not shown)s for transaction resource use side 1 (not shown), and it comprisesaffairs mapping block 21,explorer 22,task manager 23 and transactionadapter creation module 24.
Affairs mapping block 21 is used to search the transaction adapter of Transaction Identifier correspondence, and thisaffairs mapping block 21 comprisestransaction adapter 211,searches module 212 and logging modle 213.Transaction adapter 211 is used to receive to be submitted request to and will submit to request to be forwarded to the explorer of registration, eachtransaction adapter 211 is used for the operation of affairs of management transactionresource service end 2 participations, when transactionresource service end 2 had participated in a plurality of affairs, 21 of affairs mapping blocks comprised a plurality of transaction adapter 211.Search module 212 and be used to search thetransaction adapter 211 of Transaction Identifiercorrespondence.Logging modle 213 is used to write down the corresponding relation of Transaction Identifier and transaction adapter.
Explorer 22 is used for submitting to according to submitting to request to carry out, and it supports two-phase commitmentprotocol.Task manager 23 is used for current affairs are replaced with the registration and the cancellation of described transaction adapter and explorer, and the management transaction resource is as the application system of physical database, the memory database of supporting affairs and support transaction interface.Transactionadapter creation module 24 is used to createtransaction adapter 211, after transactionresource service end 2 receives the business operation request, if do not find the Transaction Identifier correspondent transaction adapter, then createtransaction adapter 211, andtransaction adapter 211 and corresponding Transaction Identifier are saved to loggingmodle 213.
Present embodiment has been realized interdepartmental system distributed transaction processing based on non-JCA architecture, be responsible for the management of a transaction operation by transaction adapter, transaction adapter as interface is simple and easy to usefulness, is applicable to the multiple application system based on J2EE, J2SE, C++ and C# etc.
As shown in Figure 3, the distributed transaction disposal system structural representation that constitutes for embodiment of the invention transaction resource use side and transaction resource service end.As can be seen, transactionresource use side 1 is connected with transactionresource service system 2 bytransaction resource client 12 from this figure, andtransaction resource client 12 is corresponding one by one with transactionresource service system 2.
As shown in Figure 4, be embodiment of the invention affairs coordinator first structuralrepresentation.Affairs coordinator 11 comprisesRegistering modules 112, submitsrequest forwarding module 113 to,nullifies module 114 andtransaction proxy module 115.
Registering modules 112 is used to register thetransaction resource client 12 that participates in current affairs, and notifiestransaction proxy module 115 with log-on message.Transaction resource client 12 is registered to Registeringmodules 112 as Resource Broker.After submitting to requestforwarding module 113 to receive the submission request of submittingrequest module 14 transmissions to, submit the submission request that carries Transaction Identifier to by transaction proxy module 115.Transaction proxy module 115 is managed these affairs of participation in affairs, promptly as thetransaction resource client 12 of Resource Broker registration, it submits the submission request that carries Transaction Identifier to bytransaction resource client 12, and supports to submit this submission request to two stage ways of submission.Nullifymodule 114 and be used for after submitting request to, thetransaction resource client 12 of current affairs being nullified, and notifytransaction proxy module 115 log-off message.
The affairs coordinator based on non-JCA of present embodiment has been realized the distributed transaction management of interdepartmental system, satisfies the data manipulation conformance requirement based on the multiple application system of J2EE, J2SE, C++ and C# etc.
As shown in Figure 5, the affairs coordinator of the embodiment of the invention also can comprisecreation module 111, and this module is used to createtransaction proxy module 115, and generates Transaction Identifier.
Two stages submitted to be divided into submitting to and prepare and two stages of submit operation, submitting to the preparatory stage, transaction resource is received processing such as request back execution data modification and log record, and the back of finishing dealing with is just made the state of affairs into " can submit to ", whether return results is reported ready then.If all transaction resources are all ready, then enter the submit operation stage.In the submit operation stage, " can submit to " state of affairs changes " submission is finished " state into.
As shown in Figure 6, be embodiment of the invention transaction resource use side second structural representation.Present embodiment is applied to transaction resource use side embodiment one shown in Figure 2 withaffairs coordinator 11 shown in Figure 5, andtransaction proxy module 115 specifically comprisespreparation request module 1151 andoperation requests module 1152.
Preparation request module 1151 is used to submit to the submission preparation request that carries Transaction Identifier;Operation requests module 1152 is used for submitting to the transaction resource client of preparing to continue under the case of successful to registration to submit the submit operation request that carries Transaction Identifier to.
In the present embodiment, two stage manner are adopted in the submission of submission request, and promptly the phase one is to submit to prepare, the subordinate phase submit operation, and like this, use side is the control data operational consistency effectively, thereby realizes striding the affairs unification of task manager.
As shown in Figure 7, be transaction resource service end embodiment two structural representations of the present invention.Present embodiment and difference embodiment illustrated in fig. 2 are thataffairs mapping block 21 has further added removingmodule 214, andtask manager 23 comprises that specificallyaffairs handover module 231,resource registering module 232 and resource nullifymodule 233.
Affairs handover module 231 is used for after receiving the business operation request, current affairs are replaced with thetransaction adapter 211 of Transaction Identifier correspondence by the affairs oftask manager 23, and after carrying out submission, current affairs are replaced with the affairs oftask manager 23 bytransaction adapter 211.
Theexplorer 22 thatresource registering module 232 is used for participating in these affairs is registered to thetransaction adapter 211 of Transaction Identifier correspondence, therebytransaction adapter 211 can be forwarded to the submission request that receivescorresponding explorer 22.
Resource is nullifiedmodule 233 and is used for after carrying outsubmission explorer 22 being nullified fromtransaction adapter 211.
The removingmodule 213 ofaffairs mapping block 21 is used for after carry out submitting to, thetransaction adapter 211 of deletion Transaction Identifier correspondence and the corresponding relation of Transaction Identifier and transaction adapter, thereby timely Free up Memory.
As shown in Figure 8, the distributed transaction processing method first pass figure for the transaction resource use side of the embodiment of the invention comprises the steps:
Steps A 101, registration transactions resource client;
The transaction resource client of steps A 102, utilization registration is submitted the submission request that carries Transaction Identifier to the transaction resource service end;
Steps A 103, cancellation transaction resource client.
Present embodiment has realized that based on non-JCA architecture interdepartmental system distributed transaction handles, and is applicable to based on the application system of J2SE, J2EE and based on the non-Java application system of C++, C# etc.
As shown in Figure 9, the distributed transaction processing method first pass figure for embodiment of the invention transaction resource service end comprises the steps:
Step B101, according to the Transaction Identifier that carries in the business operation request, search the transaction adapter of Transaction Identifier correspondence;
Step B102, current affairs are replaced with transaction adapter by the affairs of task manager;
Step B103, carry out business operation according to the business operation request, business operation comprises increasing, delete, change, looking into of data and message issue etc.;
Step B104, explorer is registered to the transaction adapter of Transaction Identifier correspondence;
Step B105, according to submitting to the Transaction Identifier that carries in the request will submit request to be forwarded to correspondent transaction adapter, transaction adapter is carried out submission by the explorer of registration.
Present embodiment has realized that based on non-JCA architecture interdepartmental system distributed transaction handles, and is applicable to based on J2SE or non-Java application system, is responsible for the management of a transaction operation by transaction adapter, is simple and easy to use as the transaction adapter of interface.
As shown in figure 10, be distributed transaction processing method second process flow diagram of embodiment of the invention transaction resource use side.The present embodiment affairs coordinator adopts two stage ways of submission by the operation of transaction proxy module management coordinate transactions when submitting request to, thereby control affairs is unified effectively for use side.Present embodiment comprises the steps:
Steps A 201, establishment transaction proxy module generate Transaction Identifier;
Steps A 202, send the business operation request to the transaction resource client that participates in affairs;
203 pairs of transaction resource clients of steps A are registered and are notified the transaction proxy module with log-on message;
Steps A 204 transaction resource clients are submitted the business operation request that carries Transaction Identifier to the transaction resource service end;
Steps A 205, judge whether success of business operation request, if successful execution steps A 206;
Steps A 206, submit to submit request to the transaction proxy module;
Steps A 207, transaction proxy module are submitted the submission preparation request that carries Transaction Identifier to by the transaction resource client of registration to the transaction resource service end;
Whether steps A 208, judgement submit to preparation successful, if successful execution steps A 209;
Steps A 209, transaction proxy module are submitted the submit operation request that carries Transaction Identifier to by the transaction resource client of registration to the transaction resource service end.
In the present embodiment, submit to the submission of request to adopt two stage ways of submission, promptly the phase one is submitted preparation request to, subordinate phase is submitted the submit operation request to, like this, use side is the control data operational consistency effectively, thereby realizes striding the affairs unification of task manager.
As shown in figure 11, be distributed transaction processing method second process flow diagram of embodiment of the invention transaction resource service end.Present embodiment cooperates two stage ways of submission of transaction resource use side, comprises the steps:
Step B201, the request of reception business operation are searched corresponding transaction adapter according to the Transaction Identifier that carries in the business operation request;
Step B202, current affairs are replaced with transaction adapter by the affairs of task manager;
Step B203, execution business operation;
Step B204, explorer is registered to the transaction adapter of Transaction Identifier correspondence;
Preparation request is submitted in step B205, reception to, and according to submitting to the Transaction Identifier that carries in the preparation request will submit to preparation request to be forwarded to correspondent transaction adapter, transaction adapter is carried out submission by the explorer of registration and prepared and return execution result;
Step B206, the request of reception submit operation will submit to preparation request to be forwarded to correspondent transaction adapter according to the Transaction Identifier that carries in the submit operation request, and transaction adapter is carried out submit operation by the explorer of registration.
Present embodiment has been realized the interdepartmental system transaction coordination based on non-JCA, prepare interface by the submission that exposes task manager, the affairs unification can be by the unified control of transaction resource use side, in the upper strata of task manager control affairs, realize atomicity, consistance, isolation and the persistence of distributed transaction processing requirements.
As shown in figure 12, be distributed transaction processing method the 3rd process flow diagram of embodiment of the invention transaction resource use side.The transaction resource that participates in affairs in the present embodiment has a plurality of, when creating affairs, need initiate service request one by one to a plurality of transaction resource clients, it is registered, and send preparation request and the submit operation request submitted to one by one.Present embodiment comprises the steps:
Steps A 301, transaction resource use side are used and are begun affairs by affairs coordinator;
Steps A 302, affairs coordinator are created the transaction proxy module and are also generated Transaction Identifier, and this Transaction Identifier can be transaction sequence number;
Steps A 303, transaction resource use side are used to the transaction resource client that participates in affairs and are sent the business operation request;
Steps A 304, transaction resource client are registered to affairs coordinator as Resource Broker;
Steps A 305, affairs coordinator are notified the transaction proxy module with log-on message;
Steps A 306, transaction resource client are submitted the business operation request that carries Transaction Identifier to the transaction resource service end;
Steps A 307, judge whether success of business operation request, if successful execution steps A 308; For each transaction resource, whether the successful method possibility is different to judge each business operation request, and no matter the system that has runs succeeded is still failed, and all can return response, the system that has only can return response when appearance is unusual, this need determine according to the concrete definition of system;
Steps A 308, all transaction resource clients that judge whether to participate in these affairs are all registered, and have sent the business operation request, if, execution in step A309, otherwise, execution in step A303;
Steps A 309, transaction resource use side are used to affairs coordinator and are submitted request to;
Steps A 310, affairs coordinator are submitted request to the transaction proxy module forwards;
Steps A 311, transaction proxy module are submitted the submission preparation request that carries Transaction Identifier to the transaction resource client of registration;
Steps A 312, transaction resource client are submitted the submission preparation request that carries Transaction Identifier to the transaction resource service end;
Steps A 313, transaction resource client receive the response that the transaction resource service end is returned
Steps A 314, transaction resource client are forwarded to the transaction proxy module with response;
Steps A 315, transaction proxy module judge whether the submission preparation is successful, if successful execution steps A 316;
Steps A 316, judge whether that each transaction resource client to registration sends and submit preparation request to, if, execution in step A317, otherwise execution in step A311;
Steps A 317, transaction proxy module are submitted the submit operation request that carries Transaction Identifier to the transaction resource client of registration;
Steps A 318, transaction resource client are submitted the submit operation request that carries Transaction Identifier to the transaction resource service end;
Steps A 319, affairs coordinator are nullified the transaction resource client;
Steps A 320, affairs coordinator are notified the transaction proxy module with log-off message;
Steps A 321, judge whether to send submit operation request to each transaction resource client of registration, if not, execution in step A317.
Present embodiment has been realized the interdepartmental system transaction coordination based on non-JCA, prepare interface by the submission that exposes task manager, it is unified that but the affairs coordinator ACTIVE CONTROL is crossed over the affairs of task manager, in the upper strata of task manager control affairs, realize atomicity, consistance, isolation and the persistence of distributed transaction processing requirements.
As shown in figure 13, be distributed transaction processing method the 3rd process flow diagram of embodiment of the invention transaction resource service end.The execution of affairs relates to a plurality of explorers in the present embodiment, carrying out business operation and carrying out when submitting to, transmits request to each explorer successively, nullifies each explorer and deletes Transaction Identifier in the affairs back that is finished.Present embodiment specifically comprises the steps:
Step B301, transaction resource service end are used the business operation request that receives;
Step B302, transaction resource service end are used and are sent out query requests to the affairs mapping block;
Step B303, affairs mapping block are searched the transaction adapter of Transaction Identifier correspondence; If find, execution in step B306, otherwise, execution in step B304;
Step B304, transaction resource service end are used and are created transaction adapter;
Step B305, transaction resource service end are preserved transaction adapter and Transaction Identifier;
Step B306, transaction resource service end are replaced with current affairs the transaction adapter of Transaction Identifier correspondence by the affairs of task manager;
Step B307, transaction resource service end are used and are carried out business operation;
Call a plurality of explorers in step B308, the execution business operation process;
Step B309, each explorer obtain affairs;
Step B310, each explorer are registered to transaction adapter;
Step B311, transaction resource service end are used to receive and are submitted preparation request to;
Step B312, transaction resource service end are used to the corresponding transaction adapter of affairs mapping block inquiry transaction sign;
Step B313, affairs mapping block are searched the transaction adapter of Transaction Identifier correspondence and are returned lookup result to the application of transaction resource service end;
Step B314, transaction resource service end are used and will be submitted to preparation request to be forwarded to the transaction adapter of Transaction Identifier correspondence;
Step B315, transaction adapter send the submission preparation request to the explorer of registration;
Step B316, explorer are carried out to submit to and are prepared, and return execution result to transaction adapter;
Step B317, transaction adapter judge whether the submission preparation is successful, if, execution in step B318;
Step B318, transaction adapter judge whether the equal executed submission of each explorer of registering preparation, if, execution in step B319, otherwise, execution in step B315;
Step B319, transaction adapter are used to the transaction resource service end and are returned execution result;
Step B320, transaction resource service end are used and are returned execution result to the transaction resource client;
Step B321, transaction resource service end are used the submit operation request that receives;
Step B322, transaction resource service end are used to the corresponding transaction adapter of affairs mapping block inquiry transaction sign;
Step B323, affairs mapping block are searched the transaction adapter of Transaction Identifier correspondence and are returned lookup result to the application of transaction resource service end;
Step B324, transaction resource service end are used the transaction adapter that the submit operation request is forwarded to the Transaction Identifier correspondence;
Step B325, transaction adapter send the submit operation request to the explorer of registration;
Step B326, explorer are carried out submit operation; From transaction adapter, nullify explorer;
Step B327, transaction adapter judge whether the equal executed submit operation of each explorer of registering, if, execution in step B328, otherwise, execution in step B325;
The transaction adapter of the Transaction Identifier correspondence in step B328, the transaction resource service end deletion affairs mapping block;
Step B329, the just current affairs of transaction resource service end are replaced with the affairs of task manager by transaction adapter.
Present embodiment has been realized the eventful affair resource coordination based on non-JCA, prepare interface by the submission that exposes task manager, the affairs unification can be by the unified control of transaction resource use side, in the upper strata of task manager control affairs, realize atomicity, consistance, isolation and the persistence of distributed transaction processing requirements.
The embodiment of the invention has realized based on the affairs of non-JCA unified, has satisfied based on the application system of J2EE, J2SE (Java 2 Standard Edition) and based on the data manipulation conformance requirement of the non-Java application system of C++, C# etc.; Interface is prepared in the submission that exposes task manager, and is unified by the affairs of use side control affairs manager; In task manager upper strata control affairs, realized atomicity, consistance, isolation and the persistence of distributed transaction processing requirements, and compared that interface is simple and easy to use with the JCA framework.
Should be noted that at last: above embodiment is only in order to illustrate that technical scheme of the present invention is not intended to limit; The specific embodiment of the present invention made amendment or the part technical characterictic is equal to replacement, and do not break away from technical solution of the present invention spirit, it all should be encompassed in the middle of the technical scheme scope that the present invention asks for protection.