Response timeout processing method, server and client end response timeout treatment system
Technical field
The present invention relates to computer application technology more particularly to a kind of response timeout processing methods, server and visitor
Family end response timeout processing system.
Background technique
In client-server system, client reliance server provides required service, and system normally interacts
When, as shown in Fig. 2, user end to server sends request A, server makes an immediate response after receiving request A and ties processing
Fruit receipt, when system is influenced by factors such as network delays or network interruption, is serviced to client, but in practical application scene
Device, which may postpone to receive not receive perhaps, requests the corresponding server of A that can be delayed corresponding or not respond, at this point, due to
Client does not receive the processing result receipt of server within a preset time, and client can voluntarily start fusing mechanism, prompts to use
Family time-out is abnormal, while carrying out rolling back action in time for request A, so that user can initiate weight to request A in the client
Operation is completed in examination.
For the prior art when overtime anomalous event occurs, server generally takes artificial exclusion or automatic rollback mechanism
Processing is abnormal, due to manually excluding to take a long time and accuracy is bad, affects the usage experience of user, therefore be not suitable for big face
Product is promoted, and for automatic rollback mechanism, although having the characteristics that efficient timely, server can not supervise processing result
Identification is surveyed, i.e., can not judge that processing result is to handle or completion processing, since the processing result that is handling can not be into
Row rolling back action, if server is insisted on rollback, it will and cause system to report an error.
Summary of the invention
The purpose of the present invention is to provide a kind of response timeout processing method, server and client end response timeout treatment systems
System can timely, efficiently, accurately start rollback mechanism processing exception, improve user experience.
To achieve the goals above, an aspect of of the present present invention provides a kind of response timeout processing method, comprising:
Step S1, server receives the service request that client is sent, while being arranged in the treatment progress of service request
Progress identifies character;
Step S2, server request receipt to client feedback, and when requesting receipt is response timeout, by inquiring institute
It states progress mark character and judges whether current service request is completed;
Step S3 executes rolling back action to the service request, if current industry if current service request processing is completed
Business request processing does not complete, then changes the progress mark character;
Step S4 checks whether the progress mark character becomes after the treatment progress of service request is finished
More, when inspection result be rolling back action then to be executed to the service request, while deleting progress mark character, work as inspection
As a result character is identified otherwise directly to delete the progress;
Step S5, return step S1 send service request to server again by client, until asking in step S2
Until asking receipt response to have not timed out.
Preferably, in step sl, the method that progress identifies character is set in the treatment progress of service request are as follows:
In service request treatment progress, by redis cache in setnx method be arranged progress identify character.
Preferably, in step s 2, server requests receipt to client feedback, and is response timeout in request receipt
When, include: by inquiring the method that the progress mark character judges whether current service request is completed
Identifier of the server based on current service request inquires the progress identifier word in current service request treatment progress
Symbol;
If currently processed process is not finished and query result exists, exports current service request processing and do not complete, otherwise
Output current service request processing is completed.
Optionally, the progress mark character is state value.
Optionally, the service request is non-idempotent service request.
Illustratively, the identifier of the service request is business serial number or service order number.
Compared with prior art, response timeout processing method provided by the invention has the advantages that
In response timeout processing method provided by the invention, server receive client transmission service request after,
Progress is set first in the treatment progress of service request and identifies character, to pass through identification progress identifier word in down-stream
Symbol is to judge whether current service request handles completion, and detailed process is as follows, when client does not receive service within a preset time
The request receipt of device feedback, then it is assumed that the request receipt response timeout can be reported an error at this time by client to user and from trend
Server sends call instruction, enables the server to inquire the progress mark being previously arranged in service request according to call instruction
Character learning symbol, and judge whether current service request is completed based on progress mark character, if judging result is current service request
Processing is completed, then directly can execute rolling back action to completed service request, if current service request processing does not complete,
Temporarily rolling back action is not executed to the service request, operation only is changed to above-mentioned progress mark character, until above-mentioned business
After request treatment progress is finished, identify whether character changes by verification progress, when result, which is, is, then explanation should
Service request was previously not carried out rolling back action, at this time only need to the service request execute rolling back action, while delete into
Scale character learning symbol, when result be it is no when, then illustrate that the service request had previously executed rolling back action, need to only delete at this time this into
Scale character learning symbol can be without repeating to execute rolling back action to the service request, and end user is by client again to service
Device sends service request, executes aforesaid operations until the request receipt response of user has not timed out.
As it can be seen that the present invention identifies character by the way that progress is arranged in the treatment progress of service request, and identified based on progress
Character judges the processing progress of current service request, and to realize, when current service request processing is completed, server can be held automatically
Row rolling back action, and in the untreated completion of current service request, current service request is not held first in order to avoid system reports an error
Row rolling back action is only taken to the measure that changes of progress mark character, make its after treatment progress is finished according into
The change verification result selectivity of scale character learning symbol carries out rolling back action to the service request for being not carried out rolling back action, thus
Effectively avoid service request is carried out the defect that rolling back action bring system reports an error before treatment progress terminates, and ensure that
Rolling back action starts the accuracy on opportunity and the stability of system;In addition, being compared in the prior art by manually solving
The treatment mechanism of response timeout is also had the characteristics that fast and efficiently using timeout treatment method provided by the invention.
Another aspect of the present invention provides a kind of server response timeout processing system, is applied to described in above-mentioned technical proposal
Response timeout processing method in, the system comprises:
Server setting unit, server receive client send service request, for the processing in service request into
Progress is set in journey and identifies character;
Server judging unit, server requests receipt to client feedback, and is judging to request receipt for response timeout
When, judge whether current service request is completed by inquiring the progress mark character;
Server execution unit, for being completed if current service request is handled, to the business according to judging result
Request executes rolling back action, if current service request processing does not complete, changes the progress mark character;
Server inspection unit after being finished for the treatment progress in service request, checks the progress identifier word
Whether symbol changes, and being when inspection result is then to execute rolling back action to the service request, while deleting the progress mark
Character learning symbol, when inspection result is otherwise directly to delete the progress to identify character;
Server retries unit, for sending service request to server again by client.
Preferably, the server judging unit includes:
Server enquiry module, for by identifier of the server based on current service request, inquiry current business to be asked
The progress in treatment progress is asked to identify character;
Server judgment module, for currently processed process be not finished and query result exist, then export current business
Request processing does not complete, and otherwise exports current service request processing and is completed.
Compared with prior art, the beneficial effect of server response timeout processing system provided by the invention and above-mentioned technology
The beneficial effect for the response timeout processing method that scheme provides is identical, and this will not be repeated here.
The third aspect of the present invention provides a kind of client end response timeout treatment system, is applied to described in above-mentioned technical proposal
Response timeout processing method in, the system comprises:
Client setting unit, user end to server send service request when, for the processing in service request into
Progress is set in journey and identifies character;
Client judging unit, client receives the request receipt of server feedback, and is judging to request receipt for response
When overtime, for judging whether current service request is completed by inquiring the progress mark character;
Client executing unit, for being completed if current service request is handled, to the business according to judging result
Request executes rolling back action, if current service request processing does not complete, changes the progress mark character;
Client inspection unit after being finished for the treatment progress in service request, checks the progress identifier word
Whether symbol changes, and being when inspection result is then to execute rolling back action to the service request, while deleting the progress mark
Character learning symbol, when inspection result is otherwise directly to delete the progress to identify character;
Client retries unit, for sending service request to server again by client.
Preferably, the client judging unit includes:
Client query module, for by identifier of the client based on current service request, inquiry current business to be asked
The progress in treatment progress is asked to identify character;
Client judgment module, for currently processed process be not finished and query result exist, then export current business
Request processing does not complete, and otherwise exports current service request processing and is completed.
Compared with prior art, the beneficial effect of client end response timeout treatment system provided by the invention and above-mentioned technology
The beneficial effect for the response timeout processing method that scheme provides is identical, and this will not be repeated here.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present invention, constitutes a part of the invention, this hair
Bright illustrative embodiments and their description are used to explain the present invention, and are not constituted improper limitations of the present invention.In the accompanying drawings:
Fig. 1 is the flow diagram of response timeout processing method in the embodiment of the present invention one;
Fig. 2 is the principle exemplary diagram of response timeout in the embodiment of the present invention one;
Fig. 3 is the structural block diagram of server response timeout processing system in the embodiment of the present invention two;
Fig. 4 is the structural block diagram of client end response timeout treatment system in the embodiment of the present invention three.
Appended drawing reference:
1- server setting unit, 2- server judging unit;
3- server execution unit, 4- server inspection unit;
5- server retries unit, 21- server enquiry module;
22- server judgment module, 6- client setting unit;
7- client judging unit, 8- client executing unit;
9- client inspection unit, 10- client retry unit;
71- client query module, 72- client judgment module.
Specific embodiment
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, implement below in conjunction with the present invention
Attached drawing in example, technical scheme in the embodiment of the invention is clearly and completely described.Obviously, described embodiment
Only a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, the common skill in this field
Art personnel all other embodiment obtained without creative labor belongs to the model that the present invention protects
It encloses.
Embodiment one
Fig. 1 is response timeout processing method in the embodiment of the present invention one.Referring to Fig. 1, the present embodiment provides a kind of responses
Timeout treatment method, comprising:
Step S1, server receives the service request that client is sent, while being arranged in the treatment progress of service request
Progress identifies character;Step S2, server request receipt to client feedback, and when requesting receipt is response timeout, pass through
Inquiry progress mark character judges whether current service request is completed;Step S3 is right if current service request processing is completed
Service request executes rolling back action, if current service request processing does not complete, changes progress mark character;Step S4, in industry
After the treatment progress of business request is finished, whether inspection progress mark character is changed, and being when inspection result is then to industry
Business request executes rolling back action, while deleting progress mark character, when inspection result is otherwise directly to delete progress to identify character;
Step S5, return step S1 send service request to server again by client, until the request receipt in step S2 is rung
Until should having not timed out.
In response timeout processing method provided in this embodiment, server is in the service request for receiving client transmission
Afterwards, progress is set first in the treatment progress of service request and identifies character, to pass through identification progress mark in down-stream
Character learning symbol is to judge whether current service request handles completion, and detailed process is as follows, when client does not receive within a preset time
The request receipt of server feedback, then it is assumed that the request receipt response timeout can be reported an error simultaneously certainly by client to user at this time
Trend server send call instruction, enable the server to according to call instruction inquire previously be arranged in service request into
Scale character learning symbol, and judge whether current service request is completed based on progress mark character, if judging result is current business
Request processing is completed, then directly can execute rolling back action to completed service request, if current service request processing is not complete
At, then it is temporary rolling back action not to be executed to the service request, operation only is changed to above-mentioned progress mark character, until above-mentioned
After service request treatment progress is finished, identifies whether character changes by verification progress, when result, which is, is, then say
The bright service request was previously not carried out rolling back action, only need to execute rolling back action to the service request at this time, delete simultaneously
Except progress identifies character, when result is no, then illustrates that the service request had previously executed rolling back action, only need to delete at this time
The progress identify character can without repeat to the service request execute rolling back action, end user by client again to
Server sends service request, executes aforesaid operations until the request receipt response of user has not timed out.
As it can be seen that the present embodiment identifies character by the way that progress is arranged in the treatment progress of service request, and it is based on progress mark
Character learning symbol judges the processing progress of current service request, and to realize, when current service request processing is completed, server can be automatic
Rolling back action is executed, and in the untreated completion of current service request, in order to avoid system reports an error first not to current service request
Rolling back action is executed, the measure changed to progress mark character is only taken, makes its basis after treatment progress is finished
The change verification result selectivity of progress mark character carries out rolling back action to the service request for being not carried out rolling back action, from
And effectively avoid service request and be carried out the defect that rolling back action bring system reports an error before treatment progress terminates, guarantee
The accuracy on rolling back action starting opportunity and the stability of system;In addition, being compared in the prior art by manually solving
The certainly treatment mechanism of response timeout is also had the characteristics that fast and efficiently using response timeout processing method provided in this embodiment.
It is understood that the service request in above-described embodiment refers to non-idempotent service request, in order to make this field skill
Art personnel can better understand response timeout processing method, and the present embodiment carries out as described below so that order locks certificate as an example:
When user chooses commodity in shopping cart, can the suitable discount coupon of simultaneous selection carry out order submission, take at this time
Business device can handle to service request while be requested back to client feedback immediately after the service request for receiving order submission
It holds, wherein service request processing includes calling commodity stocks resource and promotional offer resource respectively to selected commodity and selected excellent
Favour certificate is locked, but whether user does not know server when client receives the response timeout of request receipt
Selected commodity and the locking of selected discount coupon are finished, if insisting on executing rollback to it in the case where above-mentioned lock operation does not finish
Operation, it will lead to the unstability of server, and in order to guarantee the shopping experience of user, it can not be one-side in order to true
Above-mentioned lock operation is protected to be finished and leave the server excessive execution time for, it is this to be brought by sacrificing period of reservation of number
The method of response timeout processing will reduce the shopping experience of user, it is clear that also unreasonable.Therefore how to be completed in lock operation
Executing rolling back action as early as possible afterwards becomes the present embodiment critical issue to be solved, and the present embodiment passes through in lock operation process
Middle setting progress identifies character, and the processing progress of Current lock operation is judged based on progress mark character, is locked with realizing currently
Rolling back action can be executed automatically by determining server when operation processing is completed, and when Current lock operates untreated completion, in order to
It avoids system from reporting an error first not operate execution rolling back action to Current lock, only take and arrange to what progress mark character changed
Apply, make its after lock operation is finished according to progress identify character change verify result selectivity to be not carried out return
The lock operation of rolling operation carries out rolling back action, is carried out back before treatment progress terminates to effectively avoid lock operation
The defect that rolling operation bring system reports an error.
Illustratively, in above-described embodiment step S1, progress is set in the treatment progress of service request and identifies character
Method are as follows: in service request treatment progress, by redis cache in setnx method be arranged progress identify character.It is optional
Ground, above-mentioned progress mark character is state value.
Further, in above-described embodiment step S2, server requests receipt to client feedback, and is in request receipt
When response timeout, include: by inquiring the method that the progress mark character judges whether current service request is completed
Identifier of the server based on current service request inquires the progress identifier word in current service request treatment progress
Symbol;If currently processed process is not finished and query result exists, exports current service request processing and do not complete, otherwise output is worked as
Preceding service request processing is completed.Illustratively, the identifier of service request is business serial number or service order number.
Embodiment two
Fig. 1 and Fig. 3 are please referred to, the present embodiment provides a kind of server response timeout processing systems, comprising:
Server setting unit 1, when server receives the service request that client is sent, at the place of service request
Progress is set in reason process and identifies character;
Server judging unit 2, server requests receipt to client feedback, and is judging to request receipt for response timeout
When, judge whether current service request is completed by inquiring the progress mark character;
Server execution unit 3, for being completed if current service request is handled, to the industry according to judging result
Business request executes rolling back action, if current service request processing does not complete, changes the progress mark character;
Server inspection unit 4 after being finished for the treatment progress in service request, checks the progress identifier word
Whether symbol changes, and being when inspection result is then to execute rolling back action to the service request, while deleting the progress mark
Character learning symbol, when inspection result is otherwise directly to delete the progress to identify character;
Server retries unit, for sending service request to server again by client.
Preferably, server judging unit 2 includes:
Server enquiry module 21, for inquiring current business by identifier of the server based on current service request
The progress in treatment progress is requested to identify character;
Server judgment module 22, for currently processed process be not finished and query result exist, then export current industry
Business request processing does not complete, and otherwise exports current service request processing and is completed.
Compared with prior art, the beneficial effect of server response timeout processing system provided in an embodiment of the present invention with it is upper
The beneficial effect for stating the response timeout processing method of the offer of embodiment one is identical, and this will not be repeated here.
Embodiment three
Fig. 1 and Fig. 4 are please referred to, the present embodiment provides a kind of client end response timeout treatment systems, comprising:
Client setting unit 6, user end to server send service request when, for the processing in service request into
Progress is set in journey and identifies character;
Client judging unit 7, client receives the request receipt of server feedback, and is judging to request receipt for response
When overtime, for judging whether current service request is completed by inquiring the progress mark character;
Client executing unit 8, for being completed if current service request is handled, to the industry according to judging result
Business request executes rolling back action, if current service request processing does not complete, changes the progress mark character;
Client inspection unit 9 after being finished for the treatment progress in service request, checks the progress identifier word
Whether symbol changes, and being when inspection result is then to execute rolling back action to the service request, while deleting the progress mark
Character learning symbol, when inspection result is otherwise directly to delete the progress to identify character;
Client retries unit 10, for sending service request to server again by client.
Preferably, client judging unit 7 includes:
Client query module 71, for inquiring current business by identifier of the client based on current service request
The progress in treatment progress is requested to identify character;
Client judgment module 72, for currently processed process be not finished and query result exist, then export current industry
Business request processing does not complete, and otherwise exports current service request processing and is completed.
Compared with prior art, the beneficial effect of client end response timeout treatment system provided in an embodiment of the present invention with it is upper
The beneficial effect for stating the response timeout processing method of the offer of embodiment one is identical, and this will not be repeated here.
It will appreciated by the skilled person that realizing that all or part of the steps in foregoing invention method is can to lead to
Program is crossed to instruct relevant hardware and complete, above procedure can store in computer-readable storage medium, the program
When being executed, each step including above-described embodiment method, and the storage medium may is that ROM/RAM, magnetic disk, CD,
Storage card etc..
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.