CN113704222A - Method and device for processing service request - Google Patents

Method and device for processing service request Download PDF

Info

Publication number
CN113704222A
CN113704222A CN202010436981.XA CN202010436981A CN113704222A CN 113704222 A CN113704222 A CN 113704222A CN 202010436981 A CN202010436981 A CN 202010436981A CN 113704222 A CN113704222 A CN 113704222A
Authority
CN
China
Prior art keywords
request
service
response information
unique identifier
processing
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202010436981.XA
Other languages
Chinese (zh)
Inventor
于泷
申作军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Shangke Information Technology Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Shangke Information Technology Co Ltd
Beijing Wodong Tianjun Information Technology 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 Beijing Jingdong Shangke Information Technology Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Shangke Information Technology Co Ltd
Priority to CN202010436981.XA priority Critical patent/CN113704222A/en
Publication of CN113704222A publication Critical patent/CN113704222A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a method and a device for processing a service request, and relates to the technical field of computers. One embodiment of the method comprises: receiving a service request, searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data; and when the operation result indicates that the storage is successful, processing the service request, analyzing corresponding response information to obtain a service processing instruction, and judging whether to allow the service request to be processed again according to the service processing instruction. The implementation method can partially solve the problem that operation and maintenance personnel are relied to perform manual operation when the business needs to be allowed to be processed for multiple times under a specific scene, thereby improving the efficiency of processing the business and reducing the operation and maintenance cost of a business system.

Description

Method and device for processing service request
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a service request.
Background
In a software application system, the idempotency of business operation is generally required to be ensured, and the idempotency means that the result generated by calling the interface of the system B for multiple times by the system A is consistent with the result generated by calling the interface of the system B for one time, so as to avoid the influence on the system and the business caused by repeated request operation, such as transfer request, and multiple transfers caused by repeated submitted operation without idempotency processing. The existing method for implementing idempotency usually includes creating a duplicate prevention data table related to a service identifier in a relational database, and after a service end receives a service request, querying the duplicate prevention data table before service execution to determine whether the service has been executed so as to ensure idempotency of service operation. In some specific scenarios or specific time frames, multiple invocations of service requests need to be allowed according to specific requirements.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
when the interception operation with idempotency needs to be changed and the service is allowed to be processed for multiple times in a specific scene, the existing implementation needs the operation and maintenance personnel to perform manual operation to remove the service request from the anti-duplication data table, and when the demand is large, the workload and the operation and maintenance cost of the operation and maintenance personnel are increased, and meanwhile, the efficiency of processing the service is reduced.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for processing a service request, which can receive a service request, search for a request unique identifier in request history data, and execute an operation of storing the request unique identifier in the request history data when the request unique identifier is not found; and when the operation result indicates that the storage is successful, processing the service request, analyzing corresponding response information to obtain a service processing instruction, and judging whether to allow the service request to be processed again according to the service processing instruction. The implementation method can solve the problem that operation and maintenance personnel are relied to perform manual operation when the business needs to be allowed to be processed for multiple times in a specific scene, thereby improving the efficiency of processing the business and reducing the operation and maintenance cost of a business system.
To achieve the above object, according to an aspect of the embodiments of the present invention, there is provided a method for processing a service request, including: receiving a service request, wherein the service request at least comprises a request unique identifier; searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data; when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information; and processing the service request according to the service processing instruction.
Optionally, the method of processing a service request is characterized in that,
when the request unique identifier is found in the request historical data or when the operation result indicates that the request unique identifier exists, the service request is not processed, and response information of the service request stored in the request historical data is sent.
Optionally, the method of processing a service request is characterized in that,
acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information, wherein the method comprises the following steps:
and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
Optionally, the method of processing a service request is characterized in that,
processing the service request according to the service processing instruction, including:
and when the service processing instruction indicates that the service is not completed, sending response information containing the service incomplete information aiming at the service request, and deleting the request unique identifier from the request historical data.
Optionally, the method of processing a service request is characterized in that,
processing the service request according to the service processing instruction, including:
and when the service processing instruction indicates that the service is completed, storing response information of the service request corresponding to the unique request identifier into the request historical data, and sending the response information containing the service completion information.
Optionally, the method of processing a service request is characterized in that,
performing operations of saving the request unique identifier into request history data, including:
when the request history data is stored in a relational database, the request unique identification is saved by using a rule of a unique index.
Optionally, the method of processing a service request is characterized in that,
performing operations of saving the request unique identifier into request history data, including:
when the request historical data is stored in the non-relational database, the request unique identification is saved by using the rule of the distributed lock.
To achieve the above object, according to a second aspect of the embodiments of the present invention, there is provided an apparatus for processing a service request, including: a service identification storage module, a response information analysis module and a service request processing module; wherein the content of the first and second substances,
the service identification storage module is used for receiving a service request, and the service request at least comprises a request unique identification; searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data;
the analysis response information module is used for processing the service request when the operation result indicates that the storage is successful, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
and the service request processing module is used for processing the service request according to the service processing instruction.
Optionally, the apparatus for processing a service request is characterized in that,
when the request unique identifier is found in the request historical data or when the operation result indicates that the request unique identifier exists, the service request is not processed, and response information of the service request stored in the request historical data is sent.
Optionally, the apparatus for processing a service request is characterized in that,
acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information, wherein the method comprises the following steps:
and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
Optionally, the apparatus for processing a service request is characterized in that,
processing the service request according to the service processing instruction, including:
and when the service processing instruction indicates that the service is not completed, sending response information containing the service incomplete information aiming at the service request, and deleting the request unique identifier from the request historical data.
Optionally, the apparatus for processing a service request is characterized in that,
processing the service request according to the service processing instruction, including:
and when the service processing instruction indicates that the service is completed, storing response information of the service request corresponding to the unique request identifier into the request historical data, and sending the response information containing the service completion information.
Optionally, the apparatus for processing a service request is characterized in that,
performing operations of saving the request unique identifier into request history data, including:
when the request history data is stored in a relational database, the request unique identification is saved by using a rule of a unique index.
Optionally, the apparatus for processing a service request is characterized in that,
performing operations of saving the request unique identifier into request history data, including:
when the request historical data is stored in the non-relational database, the request unique identification is saved by using the rule of the distributed lock.
To achieve the above object, according to a third aspect of the embodiments of the present invention, there is provided an electronic device for processing a service request, including: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to carry out a method as claimed in any one of the above-mentioned methods of handling service requests.
To achieve the above object, according to a fourth aspect of the embodiments of the present invention, there is provided a computer readable medium having a computer program stored thereon, wherein the program is configured to, when executed by a processor, implement the method as any one of the above methods of processing a service request.
One embodiment of the above invention has the following advantages or benefits: receiving a service request, searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data; and when the operation result indicates that the storage is successful, processing the service request, analyzing corresponding response information to obtain a service processing instruction, and judging whether to allow the service request to be processed again according to the service processing instruction. The implementation method can solve the problem that operation and maintenance personnel are relied to perform manual operation when the business needs to be allowed to be processed for multiple times in a specific scene, thereby improving the efficiency of processing the business and reducing the operation and maintenance cost of a business system.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a flowchart illustrating a method for processing a service request according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of processing a service request according to an embodiment of the present invention;
FIG. 3 is a flow diagram illustrating a process for handling a service request multiple times according to an embodiment of the invention;
fig. 4 is a schematic structural diagram of an apparatus for processing a service request according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As shown in fig. 1, an embodiment of the present invention provides a method for processing a service request, where the method may include the following steps:
step S101: receiving a service request, wherein the service request at least comprises a request unique identifier; searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data;
specifically, a service request is received, where the service request may be from any client or server; generating different service requests according to different service requirements and scenes, for example, sending order payment requests, bank transfer requests, commodity query requests and the like; the service request at least comprises a request unique identifier, wherein the unique identifier is used for uniquely identifying the service request, the unique identifier can be a character string which is generated according to a predefined naming rule and consists of letters and numbers, and can also be formed by combining the service request unique identifier and information contained in the service request, for example, for an order payment request, the service request identifier and the order identifier are combined to form the unique identifier of the service request; it is understood that the service request at least includes the request unique identifier, and the service request also includes other service-related information, for example, the order service request includes an order number, a payment amount, and the like in addition to the request unique identifier.
The invention does not limit the content of the service request, the content and the form of the unique identifier of the request.
Further, the request unique identifier is searched in request historical data, and when the request unique identifier is not searched, the operation of storing the request unique identifier in the request historical data is executed;
in order to prevent the influence caused by sending the same service request for multiple times, the information of the processed service request is recorded by utilizing a mode of forming request historical data, when a service request is received, the request unique identifier is searched in the request historical data, and when the request unique identifier is not searched, the operation of storing the request unique identifier in the request historical data is executed; when the request unique identifier is searched in the request historical data, the request unique identifier is not searched, and the operation of storing the request unique identifier in the request historical data is further executed; when the storage is successful, the service request is considered to be received for the first time; it can be understood that when concurrent requests occur, repeated processing of services cannot be completely intercepted only by the result of the request unique identifier found in the request history data, so that, in combination with querying the request unique identifier and performing the operation of saving the request unique identifier into the request history data, non-repeatability of service processing is further maintained by determining the uniqueness of the request unique identifier;
specifically, if the storage is successful, the service request is considered to be received, the service request is processed, and when the same service request is sent again, the request unique identifier can be found in the request historical data, or the operation of storing the request unique identifier in the request historical data is performed, which may prompt failure, indicating that the request unique identifier already exists;
further, when the request unique identifier is found in the request history data or when the operation result indicates that the request unique identifier already exists, the service request is not processed, and response information of the service request stored in the request history data is sent.
Further, when the result of the operation of storing the request unique identifier indicates that the request unique identifier exists, and indicates that the service request has been processed, the service request is not processed, and the response information of the service request stored in the request history data is sent.
The mode indicating "successful saving" or "unique request identifier already exists" is related to the storage mode of the history data of the storage request, for example, a relational database, a non-relational database, other storage modes indicate "successful saving" by different methods; the invention does not limit the storage mode of the historical data and the specific content indicating that the 'storage is successful' or the 'request unique identifier exists';
it can be understood that, according to the needs of the service scenario, the request history data may include other information related to the service in addition to the unique identifier of the service request, and the present invention does not limit the other information except the unique identifier;
the request historical data can be stored in a data table of a database or stored in a mode of a file or a linked list, and the storage mode of the request historical data is not limited by the invention.
Preferably, the request history data is stored in a data table of a database, and the operation of storing the request unique identifier in the request history data is executed in two ways according to the type of the database used by the application:
in a first mode, the request history data is stored in a relational database: namely, the operation of saving the request unique identifier in the request history data is executed, including:
when the request history data is stored in a relational database, the request unique identification is saved by using a rule of a unique index.
Specifically, for an application system, a database providing service support may be included, and when the database is a relational database, the unique request identifier and the response information corresponding to the service request are stored by using a rule of a unique index of the relational database, and in the case of the MySQL database, the service information may be stored by using the following example;
insert into table1(key_id)values(“a1b2c3d4e5”)
wherein, table1 is a created request history data table, which at least contains the request unique identifier and the entry of the service response information; in the above example statement, the key _ id is an entry for storing a unique identifier of the service, and the key _ id is set as a unique index to ensure the uniqueness of the piece of data;
in a second mode, the request history data is stored in a relational database: namely, the operation of saving the request unique identifier in the request history data is executed, including:
when the request historical data is stored in the non-relational database, the request unique identification is saved by using the rule of the distributed lock.
Specifically, for an application, a database supported by a server may be included, and when the background database is a non-relational database, the request unique identifier may be stored by using a rule of a distribution lock of the non-relational database, and taking Redis as an example, at least the request unique identifier may be stored by using a setNx method.
The present invention does not limit the types of relational and non-relational databases and the specific contents of the data table in which the request history data is located.
Step S102: when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
specifically, when the operation result indicates that the storage is successful, it indicates that the request history data does not include the request unique identifier, and the service request is considered to be a first occurrence, and the manner indicating successful storage is related to the storage manner of the storage request history data, for example, the relational database, the non-relational database, and other storage manners indicate successful storage by different methods;
further, when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
The following describes, by way of example, a process of parsing the response information to obtain a service processing instruction, where the process includes obtaining, by parsing, response information corresponding to the service request, searching for a predefined service keyword in the response information, parsing predefined service information indicated by the service keyword, and determining the service processing instruction;
for example: the response information fed back according to the service request is as follows,
{ "success": true, "code":0, "msg": execution success "}
Searching for a predefined service keyword in the response information, taking the response information as an example, in the above example response information, assuming that the predefined service keyword is "code", and obtaining that "code" is "0" by searching for "code" in the response information; and according to a predefined rule, when the code is '0', the service completion is indicated, wherein '0' is the predefined service information indicated by the service keyword, further, the predefined service information is analyzed, and a service processing instruction is determined, in the present example, according to the predefined service information, namely '0', the service instruction corresponding to '0' is analyzed as the service completion, so that the service processing instruction is further determined as the service completion; it is understood that the predefined service keyword and the predefined service information indicated by the service keyword are defined according to the scenario, for example, in the above example, the predefined service keyword may also be "msg", and "execution success" is the predefined service information indicated by the service keyword and represents that the service request is completed;
further, it is assumed that the response information obtained by the service request is:
{ "success": false ": code": 1), "msg": internal error of system, please retry "}
Searching predefined service keywords in the response information, and still using "code" in the response information as the predefined service keywords, where "code" is indicated as-1 and "-1" is predefined service information, and analyzing a predefined rule to enable "-1" to indicate that the service is not completed, and further determining the service processing instruction according to the predefined service information indicated by the service keywords, where in this example, the service processing instruction is service not completed;
it is understood that the predefined service keyword and the predefined service information indicated by the service keyword are defined according to the scenario, for example, in the above example, the predefined service keyword may also be "msg", and "system internal error, please retry" is set as the predefined service information, indicating that the service is not completed;
further, when the service request is not completed and is accepted again, the service request is allowed to be processed again; it can be understood that, if the response information obtained by processing the service request again is still { "success": false "," code ": 1", "msg": internal error of the system, please retry "}, according to the predefined service keyword searched in the response information, the service processing instruction is determined according to the predefined service information indicated by the service keyword;
the description of processing the service of the service request according to the service processing instruction is as described in step S103.
The invention does not limit the specific content and format of the predefined service key words and the predefined service information;
namely, the operation of saving the request unique identification in the request history data is executed;
when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information; processing the service request according to the service processing instruction;
acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information, wherein the method comprises the following steps: and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
Step S103: and processing the service of the service request according to the service processing instruction.
Specifically, as described in step S102, the response information is parsed according to the predefined service processing rule to obtain a service processing instruction, where the service processing instruction is "service complete" or "service incomplete";
processing the service request according to the service processing instruction, including: when the service processing instruction indicates that the service is completed, storing response information of the service request corresponding to the unique request identifier into the request historical data, and sending the response information containing the service completion information;
specifically, when the service processing instruction indicates that the service is completed, the service request is considered to have been successfully executed and processed, and it can be known from step S101 that the unique identifier of the service already exists in the request history data, and in order to maintain idempotency, when the service request is received multiple times, the service is not processed, and then the response information of the service request corresponding to the unique identifier of the request is stored in the request history data;
it is understood that the response information about the service request is stored in the request history data together with the request unique identifier corresponding thereto, and the response information including the service completion information is transmitted. When the service request is sent again, as described in step S101, the operation of saving the request unique identifier in the request history data is performed, and when the result of the operation indicates that the request unique identifier already exists, further, the response information of the service request saved in the request history data is directly sent.
That is, when the request unique identifier is found in the request history data or when the operation result indicates that the request unique identifier already exists, the service request is not processed, and the response information of the service request stored in the request history data is transmitted.
Further, processing the service request according to the service processing instruction includes: when the service processing instruction indicates that the service is not completed, sending response information containing the service incomplete information aiming at the service request, and deleting the request unique identifier from the request historical data;
specifically, when the service processing instruction indicates that the service is not completed, the response information is analyzed according to the predefined keyword and the predefined service information indicated by the keyword, so as to obtain that the service processing instruction is "service not completed", and the service request can be allowed to be processed again according to the predefined rule under the service processing instruction of "service not completed", specifically, the response information including the service not completed information is sent to the sender, the response result of the service request is notified to the sender, and further, the request unique identifier is deleted from the request history data, it can be understood that the service is re-processed when the service request is allowed to be accepted again by deleting the unique identifier of the service request;
according to different storage modes of the request historical data, a mode of deleting the unique identifier of the service request from the request historical data is adopted correspondingly, for example, when the request historical data is stored in a relational database, the sentence of the relational database is used for deleting, when the request historical data is stored in a non-relational database, the sentence of the non-relational database is used for deleting, and when the request historical data is stored in other storage formats such as files, the corresponding method is used for deleting.
By the method, whether the service request is allowed to be processed for multiple times can be judged, and the operation and maintenance personnel do not need to delete the unique request identifier from the anti-heavy database (namely request historical data) manually, so that the service processing efficiency is improved, and the operation and maintenance cost of a service system is reduced.
As shown in fig. 2, an embodiment of the present invention provides a flow diagram of multiple service processing, where the flow of the method may include the following steps:
step S201: receiving a service request, and searching in request historical data according to a request unique identifier of the service;
the specific description about receiving the service request, the unique request identifier included in the service request, and searching for the unique request identifier in the request history data is consistent with step S101, and is not described herein again;
further, if the unique identifier of the request is found, step S206 is executed; if the request unique identifier is not found, step S202 is executed.
Step S202: executing the operation of saving the request unique identifier into request historical data; if the saving is successful, executing step S205; if the unique identification of the request is indicated to already exist; step S206 is executed;
when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
when the request unique identifier is found in the request historical data or when the operation result indicates that the request unique identifier exists, the service request is not processed, and response information of the service request stored in the request historical data is sent.
Further, different storage modes can be adopted according to the request history data, and if the request history data is stored by using a relational database, the step S203 is executed; if the non-relational database is used for storage, executing the step S204;
namely, the operation of saving the request unique identifier in the request history data is executed, including: when the request history data is stored in a relational database, the request unique identification is saved by using a rule of a unique index.
Performing operations of saving the request unique identifier into request history data, including: when the request historical data is stored in the non-relational database, the request unique identification is saved by using the rule of the distributed lock.
Step S203: storing the unique identifier and the response information of the request by using the rule of the unique index;
specifically, the storing the request unique identifier into the request history data includes: when the request history data is stored in a relational database, at least the request unique identifier is saved using a uniquely indexed rule.
The description of storing the request unique identifier by using the rule of the unique index is consistent with the step S102, and is not described herein again;
step S204: storing the unique identifier of the request by using the rule of the distributed lock;
specifically, the storing the request unique identifier into the request history data includes: when the request history data is stored in a non-relational database, at least the request unique identifier is saved by using the rule of the distributed lock.
The description of storing the request unique identifier by using the rule of the distributed lock is consistent with the step S102, and is not described herein again;
step S205: processing the service request, analyzing the response information, and determining a corresponding service processing instruction according to the obtained key words; when the service processing instruction is that the service is not completed, executing step S207; when the service processing instruction is that the service is completed, executing step S208;
specifically, when the operation result indicates that the storage is successful, analyzing the service request response information by using a predefined service processing rule, and judging whether the service request can be processed again according to the result obtained by analysis;
that is, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information, includes: and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
The service processing instruction comprises: service completion and service incompletion;
the description of parsing the response information according to the predefined service processing rule is consistent with step S102, and is not described herein again.
Step S206: and when the result of the operation of saving the request unique identifier in the request historical data indicates that the request unique identifier exists, the service request is not processed, and response information of the service request saved in the request historical data is sent.
That is, when the request unique identifier is found in the request history data or when the operation result indicates that the request unique identifier already exists, the service request is not processed, and the response information of the service request stored in the request history data is transmitted.
Step S207: sending response information containing the business uncompleted information, and deleting the request unique identifier from the request historical data;
namely, according to the service processing instruction, processing the service request includes: and when the service processing instruction indicates that the service is not completed, sending response information containing the service incomplete information aiming at the service request, and deleting the request unique identifier from the request historical data.
The processing description when the service processing instruction indicates that the service is not completed is consistent with step S103, and is not described herein again;
step S208: storing the response information of the service request into request historical data, and sending the completion response information;
specifically, processing the service requested by the service according to the service processing instruction includes: when the service processing instruction indicates that the service is completed, storing response information of the service request into request historical data, and sending the completed response information;
the processing description when the service processing instruction indicates that the service is completed is consistent with step S103, and is not described herein again;
when the service request is accepted again, repeating the step S201 to the step S208; by using the method from step S201 to step S208, not only the idempotent processing of the service request can be ensured, but also the service request can be allowed to be processed for a plurality of times under the predefined service processing rule. The efficiency of the service request is improved, and the operation and maintenance cost is reduced.
As shown in fig. 3, an embodiment of the present invention provides a flow diagram for processing a service request multiple times, where the flow of the method may include the following steps:
steps S301-S307 describe a schematic flow diagram of interaction between a sender and a server, where a service request can be processed for multiple times;
step S301: a sender sends a service request;
specifically, the sender may be a client, a server, or another module that sends a service request; the invention does not limit the concrete form of the sender;
step S302: the server receives a service request;
step S303: searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data; judging that the result of the operation indicates that the storage is successful;
steps S301-S303 describe receiving a service request, the service request comprising at least a request unique identifier; searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data; when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
the specific description about receiving the service request is consistent with step S101, and is not described herein again;
step S304: processing the service request, analyzing the response information corresponding to the service, and determining a corresponding service processing instruction according to the obtained key word; specifically, the operation of saving the request unique identifier into request historical data is executed; when the operation result indicates that the storage is successful, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
further, response information corresponding to the service request is obtained, the response information corresponding to the service request is obtained, predefined service keywords are searched in the response information, and the service processing instruction is determined according to the predefined service information indicated by the service keywords.
The description of the analysis response information is consistent with that of step S102, and is not repeated herein;
step S305: sending response information containing the business uncompleted information, and deleting the request unique identifier from the request historical data;
specifically, when the service processing instruction indicates that the service is not completed, response information including the service incomplete information is sent for the service request, and the request unique identifier is deleted from the request history data.
The processing description when the service processing instruction indicates that the service is not completed is consistent with step S103, and is not described herein again;
step S306: a sender sends a service request;
specifically, the sending party sends the service request again, for example, sends the service request again based on a payment error returned by order payment; or when the performance test of interface access is needed, allowing to receive multiple service requests;
step S307: the server processes the service request according to the service request processing flow;
the description of the service end receiving and processing the service request is consistent with the steps S201 to S208, and is not described herein again.
As shown in fig. 4, an embodiment of the present invention provides an apparatus 400 for processing a service request, including: a service identification storage module 401, a response information analysis module 402 and a service request processing module 403; wherein the content of the first and second substances,
the service identifier saving module 401 is configured to receive a service request, where the service request at least includes a request unique identifier; searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data;
the analysis response information module 402 is configured to, when the operation result indicates that the storage is successful, process the service request, obtain response information corresponding to the service request, and obtain a service processing instruction by analyzing the response information;
the service request processing module 403 is configured to process the service request according to the service processing instruction.
Optionally, the parsing response information module 402 is configured to, when the request unique identifier is found in the request history data or when the operation result indicates that the request unique identifier already exists, not process the service request, and send the response information of the service request stored in the request history data.
Optionally, the module 402 for parsing response information is configured to obtain response information corresponding to the service request, and obtain a service processing instruction by parsing the response information, where the module includes:
and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
Optionally, the module 403 for processing the service request is configured to process the service request according to the service processing instruction, and includes:
and when the service processing instruction indicates that the service is not completed, sending response information containing the service incomplete information aiming at the service request, and deleting the request unique identifier from the request historical data.
Optionally, the module 403 for processing the service request is configured to process the service request according to the service processing instruction, and includes:
and when the service processing instruction indicates that the service is completed, storing response information of the service request corresponding to the unique request identifier into the request historical data, and sending the response information containing the service completion information.
Optionally, the service identifier saving module 401 is configured to perform an operation of saving the request unique identifier into request history data, including:
when the request history data is stored in a relational database, the request unique identification is saved by using a rule of a unique index.
Optionally, the service identifier saving module 401 is configured to perform an operation of saving the request unique identifier into request history data, including:
when the request historical data is stored in the non-relational database, the request unique identification is saved by using the rule of the distributed lock.
An embodiment of the present invention further provides an electronic device for processing a service request, including: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the method provided by any one of the above embodiments.
Embodiments of the present invention further provide a computer-readable medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method provided in any of the above embodiments.
Fig. 5 illustrates an exemplary system architecture 500 of a method of processing a service request or an apparatus for processing a service request to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have various client applications installed thereon, such as an e-mall application, a web browser application, a search-type application, an instant messaging tool, a mailbox client, and the like.
The terminal devices 501, 502, 503 may be various electronic devices having display screens and supporting client applications such as electronic mall applications, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server providing support for service requests sent by users using the terminal devices 501, 502, 503. The background management server can process the received service request and the like and feed back the response information to the terminal equipment.
It should be noted that the method for processing the service request provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, the apparatus for processing the service request is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules and/or units described in the embodiments of the present invention may be implemented by software, and may also be implemented by hardware. The described modules and/or units may also be provided in a processor, and may be described as: a processor comprises a service identification storage module, a response information analysis module and a service request processing module. The names of these modules do not form a limitation on the module itself in some cases, for example, a module for processing a service request may also be described as a "module for determining whether to allow the service request to be processed again according to a service processing instruction".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: receiving a service request, wherein the service request at least comprises a request unique identifier; searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data; when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information; and processing the service request according to the service processing instruction.
According to the technical scheme of the embodiment of the invention, the implementation mode can partially solve the problem that the operation and maintenance personnel are relied to execute manual operation when the business needs to be allowed to be processed for multiple times in a specific scene, thereby improving the efficiency of processing the business and reducing the operation and maintenance cost of a business system.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method for processing a service request, comprising:
receiving a service request, wherein the service request at least comprises a request unique identifier;
searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data;
when the operation result indicates that the storage is successful, processing the service request, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
and processing the service request according to the service processing instruction.
2. The method of claim 1,
when the request unique identifier is found in the request historical data or when the operation result indicates that the request unique identifier exists, the service request is not processed, and response information of the service request stored in the request historical data is sent.
3. The method of claim 1,
acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information, wherein the method comprises the following steps:
and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
4. The method of claim 1,
processing the service request according to the service processing instruction, including:
and when the service processing instruction indicates that the service is not completed, sending response information containing the service incomplete information aiming at the service request, and deleting the request unique identifier from the request historical data.
5. The method of claim 1,
processing the service request according to the service processing instruction, including:
and when the service processing instruction indicates that the service is completed, storing response information of the service request corresponding to the unique request identifier into the request historical data, and sending the response information containing the service completion information.
6. The method of claim 1,
performing operations of saving the request unique identifier into request history data, including:
when the request history data is stored in a relational database, the request unique identification is saved by using a rule of a unique index.
7. The method of claim 1,
performing operations of saving the request unique identifier into request history data, including:
when the request historical data is stored in the non-relational database, the request unique identification is saved by using the rule of the distributed lock.
8. An apparatus for processing a service request, comprising: a service identification storage module, a response information analysis module and a service request processing module; wherein the content of the first and second substances,
the service identification storage module is used for receiving a service request, and the service request at least comprises a request unique identification; searching the request unique identifier in request historical data, and when the request unique identifier is not searched, executing the operation of storing the request unique identifier in the request historical data;
the analysis response information module is used for processing the service request when the operation result indicates that the storage is successful, acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information;
and the service request processing module is used for processing the service request according to the service processing instruction.
9. The apparatus of claim 8,
when the request unique identifier is found in the request historical data or when the operation result indicates that the request unique identifier exists, the service request is not processed, and response information of the service request stored in the request historical data is sent.
10. The apparatus of claim 8,
acquiring response information corresponding to the service request, and acquiring a service processing instruction by analyzing the response information, wherein the method comprises the following steps:
and acquiring response information corresponding to the service request, searching predefined service keywords in the response information, and determining the service processing instruction according to the predefined service information indicated by the service keywords.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202010436981.XA 2020-05-21 2020-05-21 Method and device for processing service request Pending CN113704222A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010436981.XA CN113704222A (en) 2020-05-21 2020-05-21 Method and device for processing service request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010436981.XA CN113704222A (en) 2020-05-21 2020-05-21 Method and device for processing service request

Publications (1)

Publication Number Publication Date
CN113704222A true CN113704222A (en) 2021-11-26

Family

ID=78646224

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010436981.XA Pending CN113704222A (en) 2020-05-21 2020-05-21 Method and device for processing service request

Country Status (1)

Country Link
CN (1) CN113704222A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114666319A (en) * 2022-03-02 2022-06-24 北京百度网讯科技有限公司 Data downloading method and device, electronic equipment and readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114666319A (en) * 2022-03-02 2022-06-24 北京百度网讯科技有限公司 Data downloading method and device, electronic equipment and readable storage medium
CN114666319B (en) * 2022-03-02 2024-03-22 北京百度网讯科技有限公司 Data downloading method, device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN110706093A (en) Accounting processing method and device
CN111460129A (en) Method and device for generating identification, electronic equipment and storage medium
CN112835904A (en) Data processing method and data processing device
CN110648216A (en) Wind control method and device
CN113076153A (en) Interface calling method and device
CN111401684A (en) Task processing method and device
CN113704222A (en) Method and device for processing service request
CN112559024A (en) Method and device for generating transaction code change list
CN113761565A (en) Data desensitization method and apparatus
CN116775167A (en) Service processing method, device, electronic equipment and computer readable medium
CN112100168A (en) Method and device for determining data association relationship
CN111753675B (en) Picture type junk mail identification method and device
CN113704242A (en) Data processing method and device
CN112131287A (en) Method and device for reading data
CN111291038B (en) Data query method and device
WO2021169553A1 (en) Method and apparatus for processing order
CN109934692B (en) Method and device for automatically generating hedge certificates
CN115619550A (en) Service data processing method and device
CN109656519B (en) Method and device for automatically accessing service data
CN116955727A (en) Method, apparatus, device and computer readable medium for configuring parameters
CN116302405A (en) Data desensitization method and device
CN117312452A (en) Data synchronization method, device, electronic equipment and computer readable medium
CN113378516A (en) System for processing document coded data and method for storing and searching document coded data
CN116303566A (en) Data query method and device
CN116703629A (en) Service processing method, device, electronic equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination