CN112540856A - Service processing method and electronic equipment - Google Patents

Service processing method and electronic equipment Download PDF

Info

Publication number
CN112540856A
CN112540856A CN201910899289.8A CN201910899289A CN112540856A CN 112540856 A CN112540856 A CN 112540856A CN 201910899289 A CN201910899289 A CN 201910899289A CN 112540856 A CN112540856 A CN 112540856A
Authority
CN
China
Prior art keywords
sub
message
processing
service
processed
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
CN201910899289.8A
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 Qingxiang Technology Co ltd
Original Assignee
Beijing Qingxiang 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 Qingxiang Technology Co ltd filed Critical Beijing Qingxiang Technology Co ltd
Priority to CN201910899289.8A priority Critical patent/CN112540856A/en
Publication of CN112540856A publication Critical patent/CN112540856A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/549Remote execution

Abstract

The invention provides a service processing method and electronic equipment, wherein the method comprises the following steps: receiving at least one service processing request input by a user through a client; dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request; processing a preset number of sub-processes corresponding to the service to be processed according to a preset strategy; and after the first sub-process is completed, feeding back a service request response to the client. The embodiment of the invention decomposes the flow by introducing the intermediate state and drives the sectional service process processing based on the message, thereby shortening the request response time and improving the service quality.

Description

Service processing method and electronic equipment
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a service processing method and an electronic device.
Background
In the prior art, a plurality of processing links of most business processes are sequentially executed, as shown in fig. 1, at this time, N steps corresponding to the business process may include one or more remote calls and other processing, and a plurality of business calls may consume a long time, so that a response time is increased.
Therefore, the existing processing mode does not distinguish the critical flow from the non-critical flow, and the processing mode can lead to long time consumption of the request.
Disclosure of Invention
The embodiment of the invention provides a service processing method and electronic equipment, and aims to solve the problem that a service processing strategy in the prior art is long in time consumption.
The embodiment of the invention provides a service processing method, which is applied to electronic equipment and comprises the following steps:
receiving at least one service processing request input by a user through a client;
dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request;
processing a preset number of sub-processes corresponding to the service to be processed according to a preset strategy;
and after the first sub-process is completed, feeding back a service request response to the client.
Preferably, the step of dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request includes:
determining the service type to which the corresponding service to be processed belongs according to the service processing request;
searching a first partition strategy corresponding to the current service type according to the corresponding relation between the service type and the partition strategy;
and dividing the corresponding service to be processed into a preset number of sub-processes according to the first division strategy.
Preferably, the step of processing the preset number of sub-processes corresponding to the service to be processed according to a preset policy includes:
determining a corresponding processing strategy according to the service type to which the service to be processed belongs;
processing a first sub-process by adopting a first sub-strategy in corresponding processing strategies to generate a first message, wherein the first message at least comprises a first message content, a first identity identification number and a first identification, the first identification comprises a service type identification and a first sub-process identification, and the first message content is used for representing the processing result of the first sub-process;
sending the first message to a message queue;
and according to the feedback information of the message queue, sequentially processing the remaining sub-processes by adopting corresponding processing strategies.
Preferably, the step of sequentially processing the remaining sub-processes by using corresponding processing strategies according to the feedback information of the message queue includes:
when a message listener listens to the first message in the message queue, receiving the first message acquired from the message queue by the message listener;
calling a second sub-strategy in the corresponding processing strategy according to the first identifier;
processing a second sub-process according to the second sub-strategy and the first message content;
and detecting whether the next sub-process exists or not, and processing according to the detection result.
Preferably, the step of processing according to the detection result includes:
if the next sub-process does not exist, ending the service to be processed;
if the next sub-process exists, generating a second message and sending the second message to the message queue, and continuing to sequentially process the rest sub-processes by adopting corresponding processing strategies according to the feedback information of the message queue until the service process is finished;
the second message at least comprises a second message content, a second identity identification number and a second identifier, the second identifier comprises a service type identifier and a second sub-process identifier, and the processing strategy is adopted to process the rest sub-processes in sequence according to the processing result of the previous sub-process.
Preferably, when the number of the to-be-processed services is at least two, the step of determining the corresponding processing policy according to the service type to which the to-be-processed service belongs includes:
judging whether at least two services to be processed belong to the same service type;
if at least two services to be processed belong to the same service type, determining a corresponding processing strategy according to the same service type to which each service to be processed belongs;
if at least two services to be processed do not belong to the same service type, respectively determining corresponding processing strategies according to the service types;
the case that at least two of the services to be processed do not belong to the same service type includes: each service to be processed corresponds to different service types respectively, and part of the services to be processed in at least two services to be processed belong to the same service type.
Preferably, the step of processing the first sub-flow by using the first sub-policy in the corresponding processing policies to generate the first message includes:
if at least two services to be processed belong to the same service type, processing each first sub-process according to a first sub-strategy in the determined processing strategies to generate the first message;
if at least two services to be processed do not belong to the same service type, processing a corresponding first sub-process according to a first sub-strategy in a processing strategy corresponding to each service type to generate the first message;
and performing batch processing on each first sub-flow belonging to the same service type by adopting a multithreading mode.
Preferably, the step of receiving the first message acquired by the message listener from the message queue when the message listener listens to the first message in the message queue includes:
when at least one message listener listens to the first message in the message queue, receiving at least one first message acquired from the message queue by the message listener;
and the same type of service corresponds to one message listener, and the first messages monitored by the same message listener can be received in batches.
Preferably, the step of invoking a second sub-policy in the corresponding processing policy according to the first identifier includes:
under the condition that at least two services to be processed belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategy according to the first sub-process identifier;
and under the condition that at least two services to be processed do not belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategy according to the service type identifier and the first sub-process identifier.
Preferably, the step of processing the second sub-flow according to the second sub-policy and the first message content includes:
under the condition that at least two services to be processed belong to the same service type, carrying out batch processing on the second sub-process by adopting multiple threads according to the second sub-strategy and the first message content;
and under the condition that at least two services to be processed do not belong to the same service type, processing the corresponding second sub-process according to the second sub-strategies and the corresponding first message content, wherein the second sub-processes belonging to the same service type are processed in batch in a multithreading mode.
An embodiment of the present invention further provides an electronic device, including:
the receiving module is used for receiving at least one service processing request input by a user through a client;
the dividing module is used for dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request;
the processing module is used for processing the sub-processes with the preset number corresponding to the service to be processed according to a preset strategy;
and the feedback module is used for feeding back a service request response to the client after the first sub-process is completed.
The embodiment of the invention at least comprises the following beneficial effects:
according to the technical scheme, the method and the device for processing the business service are used for receiving at least one business processing request input by a user through the client, dividing the corresponding business to be processed into the sub-flows according to the business processing request, processing the divided sub-flows according to the preset strategy, and feeding back the business request response to the client after the first sub-flow is completed, so that the flow decomposition can be realized, the request response time can be shortened, and the business service quality can be improved.
Drawings
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
FIG. 1 is a schematic representation of a prior art business process;
fig. 2 is a schematic diagram illustrating a service processing method according to an embodiment of the present invention;
fig. 3 is a schematic flow chart of an implementation of a service processing method according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an electronic device according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
An embodiment of the present invention provides a service processing method, which is applied to an electronic device, and as shown in fig. 2, the method includes:
step 201, at least one service processing request input by a user through a client is received.
The service processing method of the embodiment of the invention is applied to the electronic equipment, wherein the electronic equipment can be a terminal or a server, and the electronic equipment firstly receives at least one service processing request input by a user through a client. The electronic device may receive a service processing request sent by at least one user, and the service processing request input by each user may be one or more than one.
Step 202, dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request.
After receiving at least one service processing request, at least one service to be processed may be divided according to the received service processing request, and the service to be processed is divided into a preset number of sub-processes. Wherein each service processing request corresponds to a pending service. After the sub-flow division is performed for at least one pending traffic, step 203 may be performed.
Step 203, processing the sub-processes with the preset number corresponding to the service to be processed according to the preset strategy.
And aiming at least one service to be processed, processing the sub-processes with the preset number corresponding to the service to be processed according to a preset strategy. After the sub-process division is performed, the sub-processes are sequentially arranged, that is, a complete service to be processed can be formed after the sub-processes are spliced, that is, the service process sequence is not damaged in the sub-process division process. When each sub-flow is processed, sequential processing is required.
And step 204, after the first sub-process is completed, feeding back a service request response to the client.
And for each service to be processed, after the first sub-process is completed, a service request response can be fed back to the client, so that a user can quickly acquire a response, wherein the service request response is not a result response and is only a response in service processing.
According to the embodiment of the invention, by receiving at least one service processing request input by a user through a client, dividing the corresponding service to be processed into the sub-flows according to the service processing request, processing the divided sub-flows according to the preset strategy, and feeding back a service request response to the client after the first sub-flow is completed, the flow decomposition can be realized, the request response time can be shortened, and the service quality can be improved.
In the embodiment of the present invention, the step of dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request includes: determining the service type to which the corresponding service to be processed belongs according to the service processing request; searching a first partition strategy corresponding to the current service type according to the corresponding relation between the service type and the partition strategy; and dividing the corresponding service to be processed into a preset number of sub-processes according to the first division strategy.
When a sub-process is divided for a service to be processed, firstly, a service type to which the corresponding service to be processed belongs is determined according to a received service processing request. After the service type is determined, a first partition strategy corresponding to the current service type is searched according to a pre-established corresponding relation between the service type and the partition strategy, then the current service to be processed is subjected to flow partition according to the searched first partition strategy, and a preset number of sub-flows are obtained, wherein the preset number is required to be greater than or equal to 2, and corresponding values of different types of services to be processed are different.
By dividing the sub-processes of each service to be processed, the corresponding sub-processes with the preset number can be respectively determined for each service to be processed.
In the embodiment of the present invention, the step of processing a preset number of sub-processes corresponding to a service to be processed according to a preset policy includes: determining a corresponding processing strategy according to the service type of the service to be processed; processing the first sub-process by adopting a first sub-strategy in the corresponding processing strategies to generate a first message, wherein the first message at least comprises a first message content, a first identity identification number and a first identification, the first identification comprises a service type identification and a first sub-process identification, and the first message content is used for representing the processing result of the first sub-process; sending the first message to a message queue; and according to the feedback information of the message queue, sequentially processing the remaining sub-processes by adopting corresponding processing strategies.
After the sub-process division is performed on the service to be processed, the corresponding processing strategy can be searched according to the service type to which the service to be processed belongs, wherein the processing strategy comprises a preset number of sub-strategies which respectively correspond to each sub-process of the service to be processed. After the processing strategy is determined, the first sub-process is processed according to a first sub-strategy in the processing strategy to generate a first message, and then the first message is sent to a message queue for storage.
The first message includes at least: the processing result of the first sub-process is represented by a first message content, a first identity identification number and a first identification, wherein the first message content can be represented by a json format character string, the first identity identification number is unique identity identification information corresponding to the message, and the first identification comprises a service type identification and a first sub-process identification. The service type identifier (Topic) is used to identify the current service type and the first sub-process identifier (Tag1) is used to identify the first processing step.
It should be noted that different service types correspond to different service type identifiers, for example, service type 1 corresponds to Topic 1, service type 2 corresponds to Topic 2, and Tag is an identifier of each processing step in a specific service, such as Tag1, Tag 2. Before each message is sent to the message queue, a Topic identifier, a Tag identifier and message content are set, and then the message is sent to the message queue.
After the first message is sent to the message queue for storage, the feedback information of the message queue can be received, and then the remaining sub-processes are sequentially processed by adopting corresponding processing strategies according to the feedback information of the message queue.
In the embodiment of the present invention, the step of sequentially processing the remaining sub-processes by using corresponding processing strategies according to the feedback information of the message queue includes:
when the message listener monitors a first message in the message queue, receiving the first message acquired from the message queue by the message listener; calling a second sub-strategy in the corresponding processing strategy according to the first identifier; processing the second sub-process according to the second sub-strategy and the first message content; and detecting whether the next sub-process exists or not, and processing according to the detection result.
The message listener arranged at the message queue can monitor the message queue, when the first message is sent to the message queue and the message listener monitors the first message in the message queue, the first message acquired from the message queue by the message listener can be received, after the first message is acquired, a first identifier and first message content in the first message can be extracted, the service type and specific flow steps are determined according to the first identifier, then a second sub-strategy in the corresponding processing strategy is called, and the second sub-flow is processed according to the second sub-strategy and the first message content.
Because the number of the sub-processes is greater than or equal to 2, after the second sub-process is processed, whether the next sub-process exists can be detected, and different processing modes are adopted according to the detection result.
Wherein, the step of processing according to the detection result comprises:
if the next sub-process does not exist, ending the service to be processed; if the next sub-process exists, generating a second message and sending the second message to a message queue, and continuing to sequentially process the rest sub-processes by adopting corresponding processing strategies according to the feedback information of the message queue until the service process is finished; the second message at least comprises a second message content, a second identity identification number and a second identification, the second identification comprises a service type identification and a second sub-process identification, and a processing strategy is adopted to process the rest sub-processes in sequence according to the processing result of the previous sub-process.
If the service to be processed only comprises two sub-processes, and the next sub-process does not exist at the moment, the service to be processed is directly ended, if the service to be processed comprises more than two sub-processes, a second message needs to be generated and sent to a message queue, then the second message fed back by the message queue is continuously received, a corresponding processing strategy is adopted to process the third sub-process, then the detection process is repeated, the service to be processed is ended when the next sub-process does not exist, and the third message is continuously generated when the next sub-process exists. And repeatedly executing the processes of generating the message, sending the message to the message queue and sequentially processing the rest sub-processes according to the feedback information until the service process is finished.
A service processing method is described below by using a specific example, as shown in fig. 3, a current service to be processed is divided into N sub-processes, a service processing request is sent by a client, an electronic device receives the service processing request, a first sub-process is executed first, after the first sub-process is completed, a service request response is fed back to the client, and a first message is sent to a message queue to store data. Wherein, the state corresponding to the first sub-process is in processing, the result fed back to the client is also in processing, and the first message is identified by Topic + Tag 1.
By splitting the service flow, the processing state is increased, when the processing of the first sub-flow is completed, the first message is sent to the message queue, then the data is stored, and the response is returned to the client, so that only the first sub-flow initiates a real-time response to the caller after the whole service flow is split into a plurality of sub-flows, and the waiting time of the caller is greatly shortened.
For the remaining sub-processes, the operation is asynchronously executed in sequence, after the execution of the previous sub-process is completed, a new message (including the execution result of the sub-process and information required by the processing of the next sub-process) is generated and sent to the message queue, the message listener acquires the message generated by the previous sub-process from the message queue, and calls a corresponding operation method according to the Tag identifier in the message to process (the processing of the next sub-process), and the execution mode is defined as a message driving mode. Based on the message-driven segmented service process processing, the request response time can be greatly shortened, so that the concurrent processing of the service is improved.
If the message listener acquires the first message produced by the first sub-process from the message queue, the electronic device calls a corresponding operation method according to the Tag1 identifier in the first message to process the second sub-process, a second message is generated and fed back to the message queue, and the second message is identified through Topic + Tag 2.
And the message listener acquires a second message produced by the second sub-process from the message queue, the electronic equipment calls a corresponding operation method according to the Tag2 identifier in the second message to process the third sub-process, a third message is generated and fed back to the message queue, and the third message is identified through Topic + Tag 3.
And repeating the processes until the last sub-process (Nth sub-process) of the service to be processed is executed, acquiring the (N-1) th message produced by the (N-1) th sub-process from the message queue by the message monitor, calling a corresponding operation method by the electronic equipment according to the Tag N-1 identifier in the (N-1) th message to process the Nth sub-process, and ending the service.
In summary, in the embodiment of the present invention, the first sub-process is a message producer, the second sub-process is a message consumer, and if the third sub-process exists, the second sub-process is also a message producer. The message consumer adopts a monitoring mechanism to realize, obtains the messages to be processed of a certain business process according to the Topic (a plurality of messages can be obtained at one time aiming at the same step in the same business type), and then judges which business operation process processing method is called according to the Tag identification in each message. After each business operation flow is processed, the message queue is informed that the message is processed; and then judging whether to produce a new message to be sent to the message queue according to the business process requirement. Thus, it is possible that the message handling process may have the message consumer be the message producer as well.
In the embodiment of the present invention, when there are at least two pending services, the step of determining a corresponding processing policy according to the service type to which the pending service belongs includes:
judging whether at least two services to be processed belong to the same service type; if at least two to-be-processed services belong to the same service type, determining a corresponding processing strategy according to the same service type to which each to-be-processed service belongs; if at least two services to be processed do not belong to the same service type, respectively determining corresponding processing strategies according to the service types; the case that at least two services to be processed do not belong to the same service type includes: each service to be processed corresponds to different service types respectively, and part of the services to be processed in at least two services to be processed belong to the same service type.
Under the condition that at least two services to be processed exist, whether the at least two services to be processed belong to the same service type needs to be judged, and if the at least two services to be processed belong to the same service type, a corresponding processing strategy can be determined according to the service type. If the at least two services to be processed do not belong to the same service type, determining various service types contained in the at least two services to be processed, and then respectively determining corresponding processing strategies according to the service types.
It should be noted that, for a case that at least two to-be-processed services do not belong to the same service type, each to-be-processed service may correspond to one service type, and at this time, a processing policy needs to be determined for each to-be-processed service. Or, part of the at least two services to be processed may belong to the same service type, and at this time, part of the services to be processed form a service group. There may be two or more service groups in at least two services to be processed, for example, in 6 services to be processed, 2 services to be processed belong to service type 1, 3 services to be processed belong to service type 2, and the remaining 1 service to be processed belongs to service type 3.
For the case that part of the services to be processed in the at least two services to be processed belong to the same service type, a processing policy may be determined for the part of the services to be processed. And establishing a corresponding relation between the service to be processed and the processing strategy while determining the processing strategy.
In this embodiment of the present invention, the step of processing the first sub-flow by using the first sub-policy in the corresponding processing policies to generate the first message includes:
if at least two services to be processed belong to the same service type, processing each first sub-process according to a first sub-strategy in the determined processing strategies to generate a first message; if at least two services to be processed do not belong to the same service type, processing a corresponding first sub-process according to a first sub-strategy in a processing strategy corresponding to each service type to generate a first message; and performing batch processing on each first sub-flow belonging to the same service type by adopting a multithreading mode.
For the situation that at least two services to be processed belong to the same service type, when the first sub-process is processed, each first sub-process needs to be processed according to a first sub-strategy in the determined processing strategies, and when the first sub-process is processed, batch processing can be performed in a multi-thread mode to obtain a first message corresponding to each first sub-process.
When the first sub-process is processed, it needs to be further determined whether each to-be-processed service corresponds to a service type, if so, the corresponding first sub-process is processed according to a first sub-policy in the processing policy corresponding to each service type, and a first message corresponding to each first sub-process is generated. If part of the services to be processed in the at least two services to be processed belong to the same service type, a first sub-strategy in the processing strategies corresponding to the service type can be adopted to perform batch processing on part of the first sub-processes, and for the rest of the services to be processed, the corresponding first sub-processes are processed according to the first sub-strategy in the processing strategies corresponding to each service type. Wherein each first sub-flow corresponds to a first message.
In this embodiment of the present invention, when the message listener listens to the first message in the message queue, the step of receiving the first message that is obtained from the message queue by the message listener includes:
when at least one message listener hears first messages in a message queue, receiving at least one first message acquired from the message queue by the message listener; wherein, the same type of service corresponds to one message listener, and the first messages monitored by the same message listener can be received in batch.
The same type of service corresponds to one message listener, the number of message listeners is the same as the number of service types, and the message listeners only listen to the corresponding type of service. The electronic device can receive the first message sent by the message listener while the at least one message listener is listening to the at least one first message in the message queue. The message monitor acquires the first message from the message queue, one message monitor can monitor a plurality of first messages during monitoring, and correspondingly, the electronic equipment can receive the first messages monitored by the same message monitor in batch when receiving the first messages.
In this embodiment of the present invention, the step of invoking the second sub-policy in the corresponding processing policy according to the first identifier includes:
under the condition that at least two services to be processed belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategies according to the first sub-process identification; and under the condition that at least two services to be processed do not belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategies according to the service type identifier and the first sub-process identifier.
If at least two services to be processed belong to the same service type, the processing strategy is determined due to the fact that the service type is determined, and when at least one first message is received, a second sub-strategy in the corresponding processing strategy can be directly called according to the first sub-process identification.
For the condition that at least two services to be processed do not belong to the same service type, if each service to be processed corresponds to one service type, a second sub-policy in the corresponding processing policy can be called according to the service type identifier and the first sub-process identifier when at least one first message is received.
If part of the services to be processed in the at least two services to be processed belong to the same service type, the processing strategy is determined due to the fact that the service type is determined, and for the part of the services to be processed, when at least one first message is received, a second sub-strategy in the corresponding processing strategy can be directly called according to the first sub-process identification. And when the rest of the services to be processed receive at least one first message, directly calling a second sub-strategy in the corresponding processing strategies according to the service type identifier and the first sub-process identifier.
In this embodiment of the present invention, the step of processing the second sub-flow according to the second sub-policy and the first message content includes:
under the condition that at least two services to be processed belong to the same service type, carrying out batch processing on the second sub-process by adopting multiple threads according to a second sub-strategy and the first message content; and under the condition that at least two services to be processed do not belong to the same service type, processing the corresponding second sub-processes according to the second sub-strategies and the corresponding first message contents, wherein the second sub-processes belonging to the same service type are processed in batches in a multithreading mode.
If at least two services to be processed belong to the same service type, the second sub-process can be processed in batch by adopting a multithreading processing mode directly according to the second sub-strategy and the first message content. And the second sub-strategies are the same, and each service to be processed corresponds to a first message content, so that the first message contents are different.
Under the condition that at least two services to be processed do not belong to the same service type, if each service to be processed corresponds to one service type, the second sub-process can be processed by adopting a second sub-strategy in the determined processing strategy and the corresponding first message content aiming at each service to be processed.
If part of the services to be processed in the at least two services to be processed belong to the same service type, the processing strategy is determined due to the determination of the service type, and aiming at the part of the services to be processed, the second sub-processes can be processed in batches by adopting a multithreading mode directly according to the second sub-strategies and the contents of the first messages. And if the remaining services to be processed are different in service type, the second sub-process can be processed by respectively adopting a second sub-strategy in the determined processing strategy and the corresponding first message content.
The implementation process of the service processing method in the embodiment of the invention is to decompose the process by introducing the intermediate state, decouple the process by adopting the message queue mechanism, ensure the processing sequence and carry out asynchronous processing, and shorten the request response time, thereby improving the service quality of the service.
Compared with the prior art that non-critical services are processed through a new thread but a unified exception handling mechanism is not provided, the problem of processing confusion is easily caused, and the method provided by the embodiment of the invention can ensure the processing orderliness.
An embodiment of the present invention further provides an electronic device, as shown in fig. 4, including:
a receiving module 10, configured to receive at least one service processing request input by a user through a client;
a dividing module 20, configured to divide the corresponding service to be processed into a preset number of sub-processes according to the service processing request;
the processing module 30 is configured to process a preset number of sub-processes corresponding to the to-be-processed service according to a preset policy;
and the feedback module 40 is configured to feed back a service request response to the client after the first sub-process is completed.
Wherein the partitioning module is further configured to:
determining the service type to which the corresponding service to be processed belongs according to the service processing request;
searching a first partition strategy corresponding to the current service type according to the corresponding relation between the service type and the partition strategy;
and dividing the corresponding service to be processed into a preset number of sub-processes according to the first division strategy.
Wherein, processing module includes:
the determining submodule is used for determining a corresponding processing strategy according to the service type to which the service to be processed belongs;
the generating submodule is used for processing the first sub-process by adopting a first sub-strategy in the corresponding processing strategies to generate a first message, wherein the first message at least comprises a first message content, a first identity identification number and a first identification, the first identification comprises a service type identification and a first sub-process identification, and the first message content is used for representing the processing result of the first sub-process;
the sending submodule is used for sending the first message to a message queue;
and the processing sub-module is used for sequentially processing the remaining sub-processes by adopting corresponding processing strategies according to the feedback information of the message queue.
Wherein, the processing submodule includes:
the receiving unit is used for receiving the first message acquired by the message listener from the message queue when the message listener monitors the first message in the message queue;
the calling unit is used for calling a second sub-strategy in the corresponding processing strategy according to the first identifier;
the first processing unit is used for processing the second sub-process according to the second sub-strategy and the first message content;
and the second processing unit is used for detecting whether the next sub-process exists or not and processing according to the detection result.
Wherein the second processing unit is further configured to:
if the next sub-process does not exist, ending the service to be processed;
if the next sub-process exists, generating a second message and sending the second message to a message queue, and continuing to sequentially process the rest sub-processes by adopting corresponding processing strategies according to the feedback information of the message queue until the service process is finished;
the second message at least comprises a second message content, a second identity identification number and a second identification, the second identification comprises a service type identification and a second sub-process identification, and a processing strategy is adopted to process the rest sub-processes in sequence according to the processing result of the previous sub-process.
Wherein, under the condition that the number of the services to be processed is at least two, the determining submodule comprises:
the judging unit is used for judging whether the at least two services to be processed belong to the same service type;
the first determining unit is used for determining a corresponding processing strategy according to the same service type to which each service to be processed belongs if at least two services to be processed belong to the same service type;
a second determining unit, configured to determine, if at least two services to be processed do not belong to the same service type, corresponding processing strategies according to the service types, respectively;
the case that at least two services to be processed do not belong to the same service type includes: each service to be processed corresponds to different service types respectively, and part of the services to be processed in at least two services to be processed belong to the same service type.
Wherein, the generation submodule comprises:
a first generating unit, configured to process each first sub-flow according to a first sub-policy in the determined processing policies to generate a first message, if at least two services to be processed belong to the same service type;
the second generating unit is used for processing the corresponding first sub-process according to the first sub-strategy in the processing strategy corresponding to each service type to generate a first message if at least two services to be processed do not belong to the same service type;
and performing batch processing on each first sub-flow belonging to the same service type by adopting a multithreading mode.
Wherein the receiving unit is further configured to:
when at least one message listener hears first messages in a message queue, receiving at least one first message acquired from the message queue by the message listener;
wherein, the same type of service corresponds to one message listener, and the first messages monitored by the same message listener can be received in batch.
Wherein the calling unit is further configured to:
under the condition that at least two services to be processed belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategies according to the first sub-process identification;
and under the condition that at least two services to be processed do not belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategies according to the service type identifier and the first sub-process identifier.
Wherein the first processing unit is further configured to:
under the condition that at least two services to be processed belong to the same service type, carrying out batch processing on the second sub-process by adopting multiple threads according to a second sub-strategy and the first message content;
and under the condition that at least two services to be processed do not belong to the same service type, processing the corresponding second sub-processes according to the second sub-strategies and the corresponding first message contents, wherein the second sub-processes belonging to the same service type are processed in batches in a multithreading mode.
The embodiment of the electronic device of the present invention is a product embodiment corresponding to the embodiment of the service processing method, and all implementation means in the embodiment of the method are applicable to the embodiment, and the same technical effect can be achieved.
According to the electronic equipment, at least one service processing request input by a user through a client is received, the corresponding service to be processed is divided into the sub-flows according to the service processing request, the divided sub-flows are processed according to the preset strategy, and after the first sub-flow is completed, the service request response is fed back to the client, so that flow decomposition can be realized, the request response time is shortened, and the service quality is improved.
The foregoing is a preferred embodiment of the present invention, and it should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and those improvements and modifications are also within the scope of the present invention.

Claims (11)

1. A service processing method is applied to electronic equipment, and is characterized in that the method comprises the following steps:
receiving at least one service processing request input by a user through a client;
dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request;
processing a preset number of sub-processes corresponding to the service to be processed according to a preset strategy;
and after the first sub-process is completed, feeding back a service request response to the client.
2. The method according to claim 1, wherein the step of dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request comprises:
determining the service type to which the corresponding service to be processed belongs according to the service processing request;
searching a first partition strategy corresponding to the current service type according to the corresponding relation between the service type and the partition strategy;
and dividing the corresponding service to be processed into a preset number of sub-processes according to the first division strategy.
3. The method according to claim 1, wherein the step of processing a preset number of sub-processes corresponding to the service to be processed according to a preset policy comprises:
determining a corresponding processing strategy according to the service type to which the service to be processed belongs;
processing a first sub-process by adopting a first sub-strategy in corresponding processing strategies to generate a first message, wherein the first message at least comprises a first message content, a first identity identification number and a first identification, the first identification comprises a service type identification and a first sub-process identification, and the first message content is used for representing the processing result of the first sub-process;
sending the first message to a message queue;
and according to the feedback information of the message queue, sequentially processing the remaining sub-processes by adopting corresponding processing strategies.
4. The method according to claim 3, wherein the step of sequentially processing the remaining sub-processes by using the corresponding processing strategies according to the feedback information of the message queue comprises:
when a message listener listens to the first message in the message queue, receiving the first message acquired from the message queue by the message listener;
calling a second sub-strategy in the corresponding processing strategy according to the first identifier;
processing a second sub-process according to the second sub-strategy and the first message content;
and detecting whether the next sub-process exists or not, and processing according to the detection result.
5. The method of claim 4, wherein the step of processing according to the detection result comprises:
if the next sub-process does not exist, ending the service to be processed;
if the next sub-process exists, generating a second message and sending the second message to the message queue, and continuing to sequentially process the rest sub-processes by adopting corresponding processing strategies according to the feedback information of the message queue until the service process is finished;
the second message at least comprises a second message content, a second identity identification number and a second identifier, the second identifier comprises a service type identifier and a second sub-process identifier, and the processing strategy is adopted to process the rest sub-processes in sequence according to the processing result of the previous sub-process.
6. The method according to claim 4, wherein, when the number of the to-be-processed services is at least two, the step of determining the corresponding processing policy according to the service type to which the to-be-processed service belongs includes:
judging whether at least two services to be processed belong to the same service type;
if at least two services to be processed belong to the same service type, determining a corresponding processing strategy according to the same service type to which each service to be processed belongs;
if at least two services to be processed do not belong to the same service type, respectively determining corresponding processing strategies according to the service types;
the case that at least two of the services to be processed do not belong to the same service type includes: each service to be processed corresponds to different service types respectively, and part of the services to be processed in at least two services to be processed belong to the same service type.
7. The method according to claim 6, wherein the step of processing the first sub-process by using the first sub-policy in the corresponding processing policy to generate the first message comprises:
if at least two services to be processed belong to the same service type, processing each first sub-process according to a first sub-strategy in the determined processing strategies to generate the first message;
if at least two services to be processed do not belong to the same service type, processing a corresponding first sub-process according to a first sub-strategy in a processing strategy corresponding to each service type to generate the first message;
and performing batch processing on each first sub-flow belonging to the same service type by adopting a multithreading mode.
8. The method of claim 7, wherein the step of receiving the first message retrieved from the message queue by the message listener when the message listener listens to the first message in the message queue comprises:
when at least one message listener listens to the first message in the message queue, receiving at least one first message acquired from the message queue by the message listener;
and the same type of service corresponds to one message listener, and the first messages monitored by the same message listener can be received in batches.
9. The method according to claim 8, wherein the step of invoking a second sub-policy of the corresponding processing policy according to the first identifier comprises:
under the condition that at least two services to be processed belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategy according to the first sub-process identifier;
and under the condition that at least two services to be processed do not belong to the same service type, when at least one first message is received, calling a second sub-strategy in the corresponding processing strategy according to the service type identifier and the first sub-process identifier.
10. The method of claim 9, wherein the step of processing the second sub-flow according to the second sub-policy and the first message content comprises:
under the condition that at least two services to be processed belong to the same service type, carrying out batch processing on the second sub-process by adopting multiple threads according to the second sub-strategy and the first message content;
and under the condition that at least two services to be processed do not belong to the same service type, processing the corresponding second sub-process according to the second sub-strategies and the corresponding first message content, wherein the second sub-processes belonging to the same service type are processed in batch in a multithreading mode.
11. An electronic device, comprising:
the receiving module is used for receiving at least one service processing request input by a user through a client;
the dividing module is used for dividing the corresponding service to be processed into a preset number of sub-processes according to the service processing request;
the processing module is used for processing the sub-processes with the preset number corresponding to the service to be processed according to a preset strategy;
and the feedback module is used for feeding back a service request response to the client after the first sub-process is completed.
CN201910899289.8A 2019-09-23 2019-09-23 Service processing method and electronic equipment Pending CN112540856A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910899289.8A CN112540856A (en) 2019-09-23 2019-09-23 Service processing method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910899289.8A CN112540856A (en) 2019-09-23 2019-09-23 Service processing method and electronic equipment

Publications (1)

Publication Number Publication Date
CN112540856A true CN112540856A (en) 2021-03-23

Family

ID=75013031

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910899289.8A Pending CN112540856A (en) 2019-09-23 2019-09-23 Service processing method and electronic equipment

Country Status (1)

Country Link
CN (1) CN112540856A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979051A (en) * 2022-04-18 2022-08-30 中移互联网有限公司 Message processing method and device, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104834506A (en) * 2015-05-15 2015-08-12 北京北信源软件股份有限公司 Method for processing business application through multiple threads
CN106341280A (en) * 2016-11-04 2017-01-18 金蝶软件(中国)有限公司 Service processing method and device
CN106603598A (en) * 2015-10-15 2017-04-26 阿里巴巴集团控股有限公司 Method for processing service request and apparatus thereof
CN107944662A (en) * 2017-10-30 2018-04-20 链家网(北京)科技有限公司 A kind of Business Process Control processing method and processing device
CN108470273A (en) * 2018-03-28 2018-08-31 凌云光技术集团有限责任公司 project development method and device
CN109325366A (en) * 2018-08-22 2019-02-12 深圳前海微众银行股份有限公司 Method for processing business, equipment and computer readable storage medium based on alliance's chain
CN109492019A (en) * 2018-10-16 2019-03-19 平安科技(深圳)有限公司 Service request response method, device, computer equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104834506A (en) * 2015-05-15 2015-08-12 北京北信源软件股份有限公司 Method for processing business application through multiple threads
CN106603598A (en) * 2015-10-15 2017-04-26 阿里巴巴集团控股有限公司 Method for processing service request and apparatus thereof
CN106341280A (en) * 2016-11-04 2017-01-18 金蝶软件(中国)有限公司 Service processing method and device
CN107944662A (en) * 2017-10-30 2018-04-20 链家网(北京)科技有限公司 A kind of Business Process Control processing method and processing device
CN108470273A (en) * 2018-03-28 2018-08-31 凌云光技术集团有限责任公司 project development method and device
CN109325366A (en) * 2018-08-22 2019-02-12 深圳前海微众银行股份有限公司 Method for processing business, equipment and computer readable storage medium based on alliance's chain
CN109492019A (en) * 2018-10-16 2019-03-19 平安科技(深圳)有限公司 Service request response method, device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979051A (en) * 2022-04-18 2022-08-30 中移互联网有限公司 Message processing method and device, electronic equipment and storage medium
CN114979051B (en) * 2022-04-18 2023-08-15 中移互联网有限公司 Message processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111459659A (en) Data processing method, device, scheduling server and medium
CN109040178B (en) Configuration information sending method and device
WO2019019652A1 (en) Push-information processing method, apparatus, computer device, and storage medium
CN106603689B (en) Data processing method and device based on distributed publish-subscribe message system
CN111651365B (en) Automatic interface testing method and device
CN111190753A (en) Distributed task processing method and device, storage medium and computer equipment
CN111694640B (en) Data processing method, device, electronic equipment and storage medium
CN112540856A (en) Service processing method and electronic equipment
CN112860401B (en) Task scheduling method, device, electronic equipment and storage medium
CN109446272B (en) Data processing method and device for server
CN110750362A (en) Method and apparatus for analyzing biological information, and storage medium
CN112580092B (en) Sensitive file identification method and device
CN114518917B (en) Algorithm module scheduling method, algorithm module scheduling device and readable storage medium
CN115509714A (en) Task processing method and device, electronic equipment and storage medium
CN115081413A (en) Report generation method, device, system, equipment and medium
CN115410580A (en) Voice recognition method, device, equipment and medium for command scheduling system
CN115640101A (en) Process information storage method and device, electronic equipment and storage medium
CN113256174A (en) Abnormal order processing method and device, storage medium and equipment
CN113742099A (en) Message consumption method, production method, system and storage medium based on set
CN110569673A (en) Data file processing method, device, equipment and storage medium
CN112965844A (en) CPU surge accident processing method and device
CN105653552B (en) Structured document processing method, device and equipment
CN112737812B (en) Data transmission method and device
CN115866017B (en) Message processing method, device, communication equipment and storage medium
CN116185664A (en) Message processing method, device, storage medium and computer equipment

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