The implementation method and device of affairs under SOA framework
Technical field
The application is related to the implementation method and device of affairs under technical field of data processing, more particularly to a kind of SOA framework.
Background technology
SOA (Service-Oriented Architecture, Services Oriented Achitecture) is a kind of new service rack
Structure, it is the service architecture of a kind of coarseness, loose coupling, is communicated by interface between service, is not related to programming on bottom layer to connect
Mouth and Communication Model.As compared with the past, the system of SOA framework can more at leisure in face of the drastically change of business.
In correlation technique, in the system of SOA framework, generally using the implementation of distributed transaction, distributed transaction
Implementation process generally comprise two stages, first stage is the preparatory stage, and second stage is presentation stage.Any one
In stage, as long as there is service that malloc failure malloc occurs, then may result in the rollback of global all services, influence the use body of user
Test.
The content of the invention
In view of this, the application provides the implementation method and device of affairs under a kind of SOA framework.
Specifically, the application is achieved by the following technical solution:
A kind of implementation method of affairs under SOA framework, methods described includes:
When called side calls the service related to global transaction, acquisition is corresponding with the service to call context, institute
The service stated includes key service and non-critical services;
When non-critical services malloc failure malloc, the context that calls of the non-critical services of the failure is saved in compensation task
In table;
When key service is called successfully, returned to the called side and call successful message;
According to compensation task table described in default time cycle poll, according to calling for being preserved in the compensation task table
Hereafter re-call the non-critical services of the failure.
A kind of implementation method of affairs under SOA framework, methods described includes:
When called side calls the service related to global transaction, acquisition is corresponding with the service to call context;
When service call fails, the context that calls of failed service is saved in compensation task table;
Returned to the called side and call successful message;
According to compensation task table described in default time cycle poll, according to calling for being preserved in the compensation task table
Hereafter re-call failed service.
Affairs realize device under a kind of SOA framework, and described device includes:
First acquisition unit, when called side calls the service related to global transaction, obtains corresponding with the service
Context is called, the service includes key service and non-critical services;
The non-critical services of the failure, when non-critical services malloc failure malloc, are called context by the first storage unit
It is saved in compensation task table;
First returning unit, when key service is called successfully, returns to the called side and calls successful message;
First call unit, according to compensation task table described in default time cycle poll, according to the compensation task table
The context that calls of middle preservation re-calls the non-critical services of the failure.
Affairs realize device under a kind of SOA framework, and described device includes:
Second acquisition unit, when called side calls the service related to global transaction, obtains corresponding with the service
Call context;
Second storage unit, when service call fails, compensation task table is saved in by the context that calls of failed service
In;
Second returning unit, returns to the called side and calls successful message;
Second call unit, according to compensation task table described in default time cycle poll, according to the compensation task table
The context that calls of middle preservation re-calls failed service.
By above description as can be seen that the application can be in non-critical services malloc failure malloc, by the non-key of the failure
The context that calls of service is saved in compensation task table, and when key service is called successfully, is returned to called side and called
Successful message, and ensure that the non-critical services of failure can be called successfully by the follow-up operation that re-calls, so that it is guaranteed that
The realization of global transaction, lifts the experience of user.
Brief description of the drawings
Fig. 1 is that the flow of the implementation method of affairs under a kind of SOA framework shown in the exemplary embodiment of the application one is illustrated
Figure.
Fig. 2 be shown in the exemplary embodiment of the application one it is a kind of by failed service call context be saved in compensation appoint
Schematic flow sheet in business table.
Fig. 3 is that a kind of shown in the exemplary embodiment of the application one realizes the structure of device one for affairs under SOA framework
Schematic diagram.
Fig. 4 is the block diagram for realizing device of affairs under a kind of SOA framework shown in the exemplary embodiment of the application one.
Fig. 5 is the block diagram for realizing device of affairs under another SOA framework shown in the exemplary embodiment of the application one.
Specific embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following description is related to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment
Described in implementation method do not represent all implementation methods consistent with the application.Conversely, they be only with it is such as appended
The example of the consistent apparatus and method of some aspects described in detail in claims, the application.
It is the purpose only merely for description specific embodiment in term used in this application, and is not intended to be limiting the application.
" one kind ", " described " and " being somebody's turn to do " of singulative used in the application and appended claims is also intended to include majority
Form, unless context clearly shows that other implications.It is also understood that term "and/or" used herein refers to and wraps
May be combined containing one or more associated any or all of project listed.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used for being distinguished from each other open same type of information.For example, not departing from
In the case of the application scope, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depending on linguistic context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determining ".
In correlation technique, local everything business is typically referred to only call an affairs for service, and global transaction is typically referred to
Needs call the affairs of multiple services, such as:Global transaction may need to call multiple databases, be likely to needs calls multiple
Service processes etc..For global transaction, generally using distributing real time system (Distributed Transaction
Processing, DTP) mode.
At present, distributing real time system generally follows XA specifications, and XA specifications define two ranks of distributing real time system
Section.First stage is to prepare presentation stage, is used to be confirmed whether that the service of all correlations can submit respective affairs point to
Branch.Called side can call each service related to global transaction by global transaction manager, and certain service is if it is confirmed that energy
Enough submit one's own transaction branch to, then can be returned to global transaction manager and prepare to submit successful response to, but now,
The service does not have and really submit to its transaction branch.If certain service confirmation cannot submit one's own transaction branch to,
Rolling back action can be carried out, and the response for preparing to submit failure to is returned to global transaction manager.Second stage is to be submitted to
Stage, global transaction manager can notify all clothes after the preparation successful response of submission that all services are returned is received
Business is submitted to, to complete the submission of global transaction, and return to global transaction to called side to call successful message.If
Receive any service and return to the response for preparing to submit failure to, be then notified that other all services carry out rolling back action, so should
Global transaction is rolled back, and the message of malloc failure malloc is returned to called side.
However, in such implementation, the success of the realization all related services of dependence of global transaction is called, as long as
There is service that malloc failure malloc occurs, then to may result in the rollback of global all services, have a strong impact on the experience of user.
Regarding to the issue above, the application provides the implementation method and device of affairs under a kind of SOA framework.
Refer to Fig. 1, Fig. 1 is the implementation method of affairs under a kind of SOA framework shown in the exemplary embodiment of the application one
Schematic flow sheet, the implementation method of affairs is applied in service end under the SOA framework, be may comprise steps of:
Step 101, when called side calls the service related to global transaction, obtains call corresponding with the service
Hereafter, the service includes key service and non-critical services.
In the present embodiment, the called side is usually the APP (Application, using journey of service provider's exploitation
Sequence), user can realize that miscellaneous service is operated by APP, such as:By taking the APP with payment function as an example, user can pass through
APP initiates transfer request, and such as:It is mobile phone charge filling etc. that what user can be provided by APP supplements entrance with money.
In the present embodiment, service end is considered as and receives for thing when user is received by APP initiating business requests
The call instruction of business, service end can confirm that this is initiated after the call instruction is received according to the type of service request
Affairs be global transaction or local affairs.When this affairs initiated is the global transaction for needing to call multiple to service,
Service end can notify that each service starts local matter by XA interface functions so that APP can be called to each service.Its
In, the service can include:Database Systems, business service process etc., the application is not particularly limited to this.
In the present embodiment, the service can be divided into key service and non-critical services, and developer can be according to complete
The all services related to the global transaction are divided into key service and non-critical services by the concrete application scene belonging to office's affairs
Two classes.Wherein, key service be typically successfully to realize local matter in the affiliated application scenarios of global transaction instantaneity requirement compared with
Service high, non-critical services be typically successfully to realize local matter in the affiliated application scenarios of global transaction instantaneity requirement compared with
Low service.In different application scenarios, the type of same service may be identical, it is also possible to different.
In the present embodiment, what service end can obtain that APP is called to each service calls context, and then caching is obtained
That gets calls context, such as:It is cached to the position specified in internal memory.
In the present embodiment, call result can be returned to service end, the tune by each service after the calling of APP is performed
Included with result:Call successfully and malloc failure malloc.Service end is returned receiving all key services related to global transaction
Return when calling successful message, step 103 can be performed.When service end receive certain non-critical services return call mistake
After the message for losing, step 102 can be performed.
Step 102, when non-critical services malloc failure malloc, the context that calls of the non-critical services of the failure is saved in
In compensation task table.
In the present embodiment, when one or more non-critical services malloc failure malloc related to global transaction, can be with
The context that calls of the non-critical services of the failure is saved in compensation task table.Such as:The mistake is read from caching
The non-critical services for losing call context, and call context to be saved in the compensation task table by described.Wherein, it is described
Parameter needed for calling context to include the non-critical services for calling the failure, such as:Transfer amounts, time of transferring accounts etc..
In this step, service end can also delete cache in caching call the context that calls for successfully servicing, the application is herein not
Repeat one by one again.
Step 103, when key service is called successfully, returns to the called side and calls successful message.
Based on abovementioned steps 101, successful message is called when all key services related to global transaction are all returned
When, service end can be returned to called side and call successful message, such as:Business is returned to the APP of initiating business request to perform
Successful message.Wherein, when only having a key service in all services related to global transaction, the key is being received
When successful message is called in service return, can be returned to called side and call successful message.When the institute related to global transaction
Have in service when there are multiple key services, receiving that whole key services return when calling successful message, to called side
Successful message is called in return.
Step 104, according to compensation task table described in default time cycle poll, preserves according in the compensation task table
The context that calls re-call the non-critical services of the failure.
In the present embodiment, service end can be according to compensation task table described in default time cycle poll, according to described
The context that calls recorded in compensation task table re-calls the non-critical services of failure.Wherein, the default time cycle
Can be configured by developer, such as:5 seconds time cycles etc., the application is not particularly limited to this.
In the present embodiment, when the non-critical services success of failure is re-called, the compensation task table can be deleted
Described in the non-critical services that fail call context.When the non-critical services of malloc failure malloc fail again, without deleting
The non-critical services failed described in the compensation task table call context.Reach the time cycle of next poll
When, the non-critical services of the failure are called according to the context that calls preserved in the compensation task table again, until being lost
The non-critical services for losing all are called successfully.
By above description as can be seen that the application is when global transaction is realized, when the non-key clothes related to global transaction
During business malloc failure malloc, the context that calls of the non-critical services of failure can be saved in compensation task table, and to called side
Successful message is called in return, subsequently can be according to compensation task table described in default time cycle poll, according to the compensation
The context that calls preserved in task list re-calls the non-critical services of failure, until the non-critical services of failure are called into
Work(.By the technical scheme of the application, when the non-critical services malloc failure malloc related to global transaction, without carrying out the overall situation
Rolling back action, returns to called side and calls successful message, improves the experience of user, and the application can be by follow-up
Re-calling operation ensures that the non-critical services of failure can be called successfully, so that it is guaranteed that the realization of global transaction.Meanwhile, use
The technical scheme that the application is provided, called side need not be concerned about whether each service is normal, and initiation is called, and is greatly reduced and is called
Follow-up processing flow caused by failure, saves the process resource of terminal.For service provider, when other services are adjusted
During with failure, this service need not carry out rolling back action, also save the process resource of relevant device.
Optionally, in one example of the application, Fig. 2 is refer to, when non-critical services malloc failure malloc, by the non-of failure
The context that calls of key service is saved in compensation task table, be may comprise steps of:
Step 201, when service call fails, judge failed service whether be the affiliated application scenarios of global transaction non-pass
Key is serviced.When all failed services are the non-critical services of the affiliated application scenarios of global transaction, step 202 can be performed.
Based on the call result of step 101 in embodiment illustrated in fig. 1, adjusted when certain service related to global transaction is returned
When using failure, can first judge failed service whether be the affiliated application scenarios of global transaction non-critical services.
As an example it is assumed that certain global transaction is transfer accounts affairs, in scene of transferring accounts, all clothes related to affairs of transferring accounts
In business, the Database Systems for storing account balance are key services, successfully notify that service processes are non-passes for notifying to transfer accounts
Key is serviced, and the friend relation maintenance process for the both sides that transfer accounts mutually to be added as a friend is also non-critical services.When user initiates one
During transfer request, for a user, successful necessary condition of transferring accounts is the successful variation of account balance, accordingly, it would be desirable to really
The database for protecting key service storage account balance can be called successfully.And successful notification message of transferring accounts is if some prolong
Late, or other side is subsequently added to the good friend of oneself again, all can be for a user receiving, therefore, in scene of transferring accounts,
The notice service processes and the friend relation maintenance process are all non-critical services.
By way of further example, it is assumed that certain global transaction is that good friend adds affairs, in the scene of addition good friend, friend relation dimension
Shield process is key service, is non-critical services for notifying that good friend adds successfully notice service processes.When user initiates one
During individual good friend addition request, for a user, it is other side is successfully added to oneself good to add successful necessary condition
In friendly list, it is desirable, therefore, to assure that key service friend relation is safeguarded can successfully call.And good friend's addition is successfully logical
Know if some delay, can be for a user receiving, thus addition good friend scene in, it is described notice service into
Journey is non-critical services.
In the present embodiment, according to the setting of developer, the non-critical services of each application scenarios can be preserved.When with it is complete
When certain related service call of office's affairs fails, the application scenarios belonging to the global transaction can be first determined, such as:Can be with
According to the global transaction carry scene identity determine it belonging to application scenarios, it is also possible to according to the global transaction carry
The service parameter application scenarios that determine belonging to it, the application is not particularly limited to this.It is determined that belonging to the global transaction
Application scenarios after, the non-critical services of the application scenarios of preservation can be searched, when it is determined that all failed services be it is non-
During key service, step 202 can be performed.When there are one or more not to be non-critical services in all failed services, that is, exist
When one or more failed services are key services, the message of malloc failure malloc can be returned to called side, while can also notify
Having called successful other services carries out rolling back action.
In the present embodiment, according to the setting of developer, it is also possible to preserve the key service of each application scenarios.When with it is complete
When certain related service call of office's affairs fails, the key service of preservation can be searched, when exist in failed service one or
When person's multiple failed service is key service, the message of malloc failure malloc can be returned to called side, while can also notify modulated
Rolling back action is carried out with successful other services.When it is determined that all failed services are not key service, i.e., all failed services
When being all non-critical services, step 202 can be performed.
Step 202, when all failed services are the non-critical services of the affiliated application scenarios of the global transaction, will lose
The context that calls for losing service is saved in compensation task table.
Based on the judged result of abovementioned steps 201, when it is determined that all failed services are belonging to the global transaction applies
During the non-critical services of scene, illustrate instantaneity that failed service local matter is successfully called required in the application scenarios compared with
It is low, the context that calls of failed service can be saved in compensation task table, subsequently re-called with waiting.
By above description as can be seen that the application is when compensating operation that failed service is re-called is realized, to unsuccessfully taking
Business carries out type classification, so that it is guaranteed that can just be returned to called side after the service call success higher to instantaneity requirement calling into
The message of work(, it is ensured that the experience of user.
The implementation process of the application is described with reference to specific example.
It is assumed that user A initiates a transfer request by Alipay client, ask to be transferred accounts 200 yuan of RMB to user B
It is whole.Service end opens a global transaction after the transfer request is received, and Alipay client can be by XA interface functions
Call the service related to affairs of transferring accounts.
Again it is assumed that the service related to the affairs of transferring accounts includes:Lead to for storing the Database Systems of user balance, message
Know process, friend relation maintenance process.Wherein, the message informing process be used for notified respectively after transferring accounts successfully user A with
User B.The friend relation maintenance process is used to mutually add as a friend user A and user B.It is described for storing user balance
Database Systems be the key service of scene of transferring accounts, it is non-pass that the message informing is carried out with the friend relation maintenance process
Key is serviced.
In this example, service end obtains each service right respectively when Alipay client call above three is serviced
That answers calls context, and calls context cache in internal memory by described.It is assumed that the data base set for storing user balance
Successful message is called in system return, i.e., the remaining sum of user's A accounts successfully reduced into 200 yuans, and by user's B accounts
Remaining sum increases by 200 yuans.Message informing process returns to the message of malloc failure malloc, i.e., sent without normal direction user A and user B and turned
The successful message of account.Friend relation maintenance process is returned and calls successful message, i.e., user B successfully is added into user A's
Good friend, and user A is successfully added to the good friend of user B.
For failed service:Message informing process, service end determines that the failed service is non-critical services, and then can be by
The context that calls of the failed service cached in internal memory is stored in compensation task table, and deletes the number cached in internal memory
According to storehouse system call context and good friend's relationship safeguard process call context.Wherein, the tune of the message informing process
Generally included with context:Transfer accounts account number of time, transfer amounts, account type, user A and user B etc..Additionally,
Service end can also be returned to Alipay client and call successful message, and Alipay client and then can show is transferred accounts successfully
The page to user.
Subsequently, service end can call context with compensation task table described in each second poll according to message informing process
Message informing process is re-called, if called successfully, that is, have been succeeded and send successful message of transferring accounts to user A and user B, then
Message informing process in the compensation task table can be deleted calls context.In another example, if weight for the first time
New message call notifies that process still fails, then in the next time cycle context can be called to re-call again according to
Message informing process, untill message informing process is successfully called.
By above description as can be seen that by the application provide global transaction implementation, when key service is called into
During work(, you can returned to user and call successful message, the experience of user is lifted, meanwhile, subsequently can be by adjusting again
Ensure that the non-critical services of failure can be called successfully with operation, so that it is guaranteed that the final realization of global transaction.
Optionally, in the application another embodiment, for the service related to global transaction, it is also possible to do not closed
Key services the differentiation with non-critical services.That is, when the service call related to global transaction fails, it is possible to by failed service
The context that calls be saved in additional mission table, and to called side return call successful message, subsequently through described in poll
Compensation task table, to ensure that failed service finally can be called successfully.After failed service success is re-called, can also delete
The embodiment called context, specifically may be referred to shown in earlier figures 1 of failed service in compensation task table, the application is herein not
Repeat one by one again.
Embodiment with the implementation method of affairs under foregoing SOA framework is corresponding, present invention also provides thing under SOA framework
The embodiment for realizing device of business.
The embodiment for realizing device of affairs can be applied in service end under the application SOA framework.Device embodiment can
Realized with by software, it is also possible to realized by way of hardware or software and hardware combining.As a example by implemented in software, as one
Device on logical meaning, is by corresponding computer program in nonvolatile memory by the processor of service end where it
Instruction runs what is formed in reading internal memory.From for hardware view, as shown in figure 3, being the reality of affairs under the application SOA framework
A kind of hardware structure diagram of service end where existing device, except the processor shown in Fig. 3, internal memory, network interface and non-volatile
Outside property memory, the service end in embodiment where device can also include it generally according to the actual functional capability of the service end
His hardware, repeats no more to this.
Fig. 4 is the block diagram for realizing device of affairs under a kind of SOA framework shown in the exemplary embodiment of the application one.
Fig. 4 is refer to, affairs realizes that device 300 can be applied in the service end shown in earlier figures 3 under the SOA framework
In, include:First acquisition unit 301, the first storage unit 302, the first returning unit 303, the first call unit 304, mistake
Lose rollback unit 305, context cache unit 306 and first and delete unit 307.
Wherein, the first acquisition unit 301, when called side calls the service related to global transaction, obtains and institute
State that service is corresponding to call context, the service includes key service and non-critical services;
First storage unit 302, when non-critical services malloc failure malloc, by calling for the non-critical services of the failure
Context is saved in compensation task table;
First returning unit 303, when key service is called successfully, returns to the called side and calls successfully
Message;
First call unit 304, according to compensation task table described in default time cycle poll, according to the compensation
The context that calls preserved in task list re-calls the non-critical services of the failure.
The failure rollback unit 305, when there is key service malloc failure malloc, malloc failure malloc is returned to the called side
Message, and notify to have called the successful service carry out rolling back action.
The context cache unit 306, obtain it is corresponding with the service call context after, the caching tune
Use context;
First storage unit 302, compensation is saved in by the context that calls of the non-critical services of the failure for caching
In task list.
Described first deletes unit 307, when the non-critical services success of the failure is re-called, deletes the compensation
The non-critical services of the failure calls context in task list.
Fig. 5 is the block diagram for realizing device of affairs under another SOA framework shown in the exemplary embodiment of the application one.
Fig. 5 is refer to, affairs realizes that device 400 can be applied in the service end shown in earlier figures 3 under the SOA framework
In, include:Second acquisition unit 401, the second storage unit 402, the second returning unit 403, the second call unit 404 and
Second deletes unit 405.
Wherein, the second acquisition unit 401, when called side calls the service related to global transaction, obtains and institute
The service stated corresponding calls context;
Second storage unit 402, when service call fails, compensation is saved in by the context that calls of failed service
In task list;
Second returning unit 403, returns to the called side and calls successful message;
Second call unit 404, according to compensation task table described in default time cycle poll, according to the compensation
The context that calls preserved in task list re-calls failed service.
Described second deletes unit 405, when the failed service success is re-called, in the deletion compensation task table
The failed service calls context.
The function of unit and the implementation process of effect correspond to step in specifically referring to the above method in said apparatus
Implementation process, will not be repeated here.
For device embodiment, because it corresponds essentially to embodiment of the method, so related part is referring to method reality
Apply the part explanation of example.Device embodiment described above is only schematical, wherein described as separating component
The unit of explanation can be or may not be physically separate, and the part shown as unit can be or can also
It is not physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can be according to reality
Selection some or all of module therein is needed to realize the purpose of application scheme.Those of ordinary skill in the art are not paying
In the case of going out creative work, you can to understand and implement.
The preferred embodiment of the application is the foregoing is only, is not used to limit the application, all essences in the application
Within god and principle, any modification, equivalent substitution and improvements done etc. should be included within the scope of the application protection.