Order creation method, device, server and storage medium

文档序号:9111 发布日期:2021-09-17 浏览:26次 中文

1. An order creation method, comprising:

responding to an order creation request of an account, and verifying the order creation request; the order creation request comprises at least one task to be executed;

transmitting the task to be executed of the order creation request passing the verification to a synchronous thread and an asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creation request;

if the synchronous thread is detected to have an abnormal task to be executed, acquiring transmission state information of the abnormal task to be executed in the asynchronous thread; the asynchronous thread is used for executing the abnormal task to be executed;

and returning an order creating result corresponding to the order creating request to the account according to the transmission state information.

2. The order creating method according to claim 1, wherein the returning of the order creating result corresponding to the order creating request to the account according to the transmission status information includes:

if the transmission state information represents that the task to be executed is transmitted to the asynchronous thread, an order creation success result corresponding to the order creation request is returned to the account; the asynchronous thread is used for executing the abnormal task to be executed until the task to be executed is completed after the successful order creation result is returned to the account;

and if the transmission state information represents that the task to be executed is not transmitted to the asynchronous thread, returning an order creation failure result corresponding to the order creation request to the account.

3. The order creation method according to claim 1, wherein said verifying the order creation request in response to the order creation request of the account comprises:

acquiring commodity attribute information and order attribute information in the order creating request; the commodity attribute information comprises commodity identification and commodity quantity; the order attribute information comprises address information and account information;

after the address information and the account information are verified, acquiring the inventory quantity of the commodities corresponding to the commodity identification;

and if the inventory quantity of the commodities is larger than the quantity of the commodities, confirming that the order creation request passes the verification.

4. The order creating method according to claim 1, further comprising, after transmitting the task to be executed of the order creating request passing the check to the asynchronous thread:

and identifying the transmitted task to be executed in the asynchronous thread to obtain an identification result, and setting a transmission identifier corresponding to the transmitted task to be executed according to the identification result, wherein the transmission identifier is used as the transmission state information of the task to be executed.

5. The order creation method according to any one of claims 1 to 4, further comprising, before detecting that there is an abnormal task to be executed in the synchronous thread:

acquiring the execution duration of a task to be executed in the synchronous thread;

and if the execution time length of the task to be executed exceeds the preset time length, determining that the task to be executed is the abnormal task to be executed.

6. The order creating method according to any one of claims 1 to 4, further comprising, after acquiring the transmission state information of the abnormal to-be-executed task in the asynchronous thread:

identifying a first execution result of a task to be executed which is transmitted in the synchronous thread and a second execution result of the task to be executed which is transmitted in the asynchronous thread;

updating the execution progress information of the order creation request according to the first execution result and the second execution result; the execution progress information is used for recording the execution condition of the task to be executed in the order creation request.

7. An order creation apparatus, comprising:

a request verification unit configured to perform an order creation request in response to an account, and verify the order creation request; the order creation request comprises at least one task to be executed;

the task transmission unit is configured to transmit the to-be-executed task of the order creation request passing the verification to the synchronous thread and the asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creation request;

the exception detection unit is configured to execute transmission state information of the abnormal task to be executed in the asynchronous thread if the synchronous thread is detected to have the abnormal task to be executed; the asynchronous thread is used for executing the abnormal task to be executed;

and the result sending unit is configured to execute the order creating result corresponding to the order creating request returned to the account according to the transmission state information.

8. A server, comprising:

a processor;

a memory for storing the processor-executable instructions;

wherein the processor is configured to execute the instructions to implement the order creation method of any of claims 1 to 6.

9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of a server, enable the server to perform the order creation method of any of claims 1 to 6.

10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, carries out the order creation method of any one of claims 1-6.

Background

With the rapid development of internet technology, online shopping has become a main shopping mode; order creation is typically the first link in online shopping.

In some business activities, the order creation request has the characteristics of large flow and high concurrency, and if a certain processing node is abnormal due to busy servers, network fluctuation and the like, the result of order creation failure can be directly returned; based on the result, the user can repeat the order creating process, so that the load of the server is increased again, and the waste of server resources is caused.

Disclosure of Invention

The present disclosure provides an order creation method, apparatus, server, storage medium and computer program product, to at least solve the problem of server resource waste in the related art. The technical scheme of the disclosure is as follows:

according to a first aspect of the embodiments of the present disclosure, there is provided an order creating method, including:

responding to an order creation request of an account, and verifying the order creation request; the order creation request comprises at least one task to be executed;

transmitting the task to be executed of the order creation request passing the verification to a synchronous thread and an asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creation request;

if the synchronous thread is detected to have an abnormal task to be executed, acquiring transmission state information of the abnormal task to be executed in the asynchronous thread; the asynchronous thread is used for executing the abnormal task to be executed;

and returning an order creating result corresponding to the order creating request to the account according to the transmission state information.

In an exemplary embodiment, the returning an order creation result corresponding to the order creation request to the account according to the transmission status information includes:

if the transmission state information represents that the task to be executed is transmitted to the asynchronous thread, an order creation success result corresponding to the order creation request is returned to the account; the asynchronous thread is used for executing the abnormal task to be executed until the task to be executed is completed after the successful order creation result is returned to the account;

and if the transmission state information represents that the task to be executed is not transmitted to the asynchronous thread, returning an order creation failure result corresponding to the order creation request to the account.

In an exemplary embodiment, the verifying the order creation request in response to the order creation request of the account includes:

acquiring commodity attribute information and order attribute information in the order creating request; the commodity attribute information comprises commodity identification and commodity quantity; the order attribute information comprises address information and account information;

after the address information and the account information are verified, acquiring the inventory quantity of the commodities corresponding to the commodity identification;

and if the inventory quantity of the commodities is larger than the quantity of the commodities, confirming that the order creation request passes the verification.

In an exemplary embodiment, after transmitting the task to be executed of the verified order creation request to the asynchronous thread, the method further comprises:

and identifying the transmitted task to be executed in the asynchronous thread to obtain an identification result, and setting a transmission identifier corresponding to the transmitted task to be executed according to the identification result, wherein the transmission identifier is used as the transmission state information of the task to be executed.

In an exemplary embodiment, before detecting that there is an abnormal task to be executed in the synchronous thread, the method further includes:

acquiring the execution duration of a task to be executed in the synchronous thread;

and if the execution time length of the task to be executed exceeds the preset time length, determining that the task to be executed is the abnormal task to be executed.

In an exemplary embodiment, before detecting that there is an abnormal task to be executed in the synchronous thread, the method further includes:

acquiring the execution times of the tasks to be executed in the synchronous thread;

and if the execution times of the task to be executed exceed the preset times, determining that the task to be executed is the abnormal task to be executed.

In an exemplary embodiment, after obtaining the transmission state information of the abnormal task to be executed in the asynchronous thread, the method further includes:

identifying a first execution result of a task to be executed which is transmitted in the synchronous thread and a second execution result of the task to be executed which is transmitted in the asynchronous thread;

updating the execution progress information of the order creation request according to the first execution result and the second execution result; the execution progress information is used for recording the execution condition of the task to be executed in the order creation request.

According to a second aspect of the embodiments of the present disclosure, there is provided an order creation apparatus including:

a request verification unit configured to perform an order creation request in response to an account, and verify the order creation request; the order creation request comprises at least one task to be executed;

the task transportation unit is configured to transmit the to-be-executed task of the order creation request passing the verification to the synchronous thread and the asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creation request;

the exception detection unit is configured to execute transmission state information of the abnormal task to be executed in the asynchronous thread if the synchronous thread is detected to have the abnormal task to be executed; the asynchronous thread is used for executing the abnormal task to be executed;

and the result sending unit is configured to execute the order creating result corresponding to the order creating request returned to the account according to the transmission state information.

In an exemplary embodiment, the result sending unit is further configured to execute, if the transmission status information indicates that the task to be executed has been transmitted to the asynchronous thread, returning an order creation success result corresponding to the order creation request to the account; the asynchronous thread is used for executing the abnormal task to be executed until the task to be executed is completed after the successful order creation result is returned to the account; and if the transmission state information represents that the task to be executed is not transmitted to the asynchronous thread, returning an order creation failure result corresponding to the order creation request to the account.

In an exemplary embodiment, the request verification unit is further configured to perform obtaining the item attribute information and the order attribute information in the order creation request; the commodity attribute information comprises commodity identification and commodity quantity; the order attribute information comprises address information and account information; after the address information and the account information are verified, acquiring the inventory quantity of the commodities corresponding to the commodity identification; and if the inventory quantity of the commodities is larger than the quantity of the commodities, confirming that the order creation request passes the verification.

In an exemplary embodiment, the task transportation unit is further configured to perform recognition on the to-be-executed task transmitted in the asynchronous thread to obtain a recognition result, and set a transmission identifier corresponding to the transmitted to-be-executed task according to the recognition result, where the transmission identifier is used as transmission state information of the to-be-executed task.

In an exemplary embodiment, the order creating apparatus further includes an exception identifying unit configured to perform obtaining of an execution duration of a task to be executed in the synchronous thread; and if the execution time length of the task to be executed exceeds the preset time length, determining that the task to be executed is the abnormal task to be executed.

In an exemplary embodiment, the exception identifying unit is further configured to obtain the number of times of executing the task to be executed in the synchronous thread; and if the execution times of the task to be executed exceed the preset times, determining that the task to be executed is the abnormal task to be executed.

In an exemplary embodiment, the exception detecting unit is further configured to execute a first execution result identifying the task to be executed that is transmitted in the synchronous thread and a second execution result identifying the task to be executed that is transmitted in the asynchronous thread; updating the execution progress information of the order creation request according to the first execution result and the second execution result; the execution progress information is used for recording the execution condition of the task to be executed in the order creation request.

According to a third aspect of the embodiments of the present disclosure, there is provided a server, including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the order creation method as described in any embodiment of the first aspect.

According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions, when executed by a processor of a server, enable the server to perform the order creation method described in any one of the first aspect.

According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program stored in a computer-readable storage medium, from which the computer program is read and executed by at least one processor of an apparatus, such that the apparatus performs the order creation method described in any one of the first aspect.

The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:

verifying the order creation request by responding to the order creation request of the account; the order creation request comprises at least one task to be executed; then transmitting the task to be executed of the order creation request passing the verification to a synchronous thread and an asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creating request; then if the synchronous thread is detected to have an abnormal task to be executed, acquiring transmission state information of the abnormal task to be executed in the asynchronous thread; the asynchronous thread is used for executing an abnormal task to be executed; finally, an order creating result corresponding to the order creating request is returned to the account according to the transmission state information; the method and the device achieve the purposes that the abnormal thread can be triggered to retry the abnormal task to be executed when an abnormal condition occurs, and the order creating result is returned to the account in advance according to the transmission state of the asynchronous thread, are favorable for reducing the waste of server resources caused by the fact that the account repeatedly sends the order creating request, and reduce the load of the server.

It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.

FIG. 1 is a diagram of an application environment illustrating a method of order creation, according to an exemplary embodiment.

FIG. 2 is a flow chart illustrating a method of order creation according to an exemplary embodiment.

FIG. 3 is a flowchart illustrating steps for verifying an order creation request in accordance with an exemplary embodiment.

FIG. 4 is a flowchart illustrating steps for updating execution progress information of an order creation request based on a first execution result and a second execution result in accordance with an exemplary embodiment.

FIG. 5 is a flow chart illustrating another method of order creation according to an exemplary embodiment.

FIG. 6 is a block diagram illustrating an order creation device according to an exemplary embodiment.

FIG. 7 is a block diagram illustrating a server in accordance with an example embodiment.

Detailed Description

In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.

It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

The order creation method provided by the present disclosure can be applied to the application environment shown in fig. 1. Wherein, the terminal 110 interacts with the server 120 through the network; the server 120 responds to the order creation request triggered by the account on the terminal 110, and verifies the order creation request; the order creation request comprises at least one task to be executed; the server 120 transmits the to-be-executed tasks of the verified order creation requests to the synchronous thread and the asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creating request; if the server 120 detects that an abnormal task to be executed exists in the synchronous thread, acquiring transmission state information of the abnormal task to be executed in the asynchronous thread; the asynchronous thread is used for executing an abnormal task to be executed; the server 120 returns the order creating result corresponding to the order creating request to the terminal 110 corresponding to the account according to the transmission state information. The terminal 110 may be, but is not limited to, various smart phones, tablet computers, notebook computers, wearable devices, or the like, and the server 120 may be implemented by an independent server or a server cluster formed by a plurality of servers.

Fig. 2 is a flowchart illustrating an order creation method according to an exemplary embodiment, where the order creation method is used in the server 120 shown in fig. 1, as shown in fig. 2, and includes the following steps.

In step S210, in response to the order creation request of the account, the order creation request is verified; the order creation request includes at least one task to be performed.

The order creating request refers to an instruction or a command for confirming the commodity to be purchased by the account, and the order creating request can acquire an account identifier in the generating process, so that the server can conveniently identify an object triggering the order creating request; the order creation request also contains information to be verified of the account and information to be verified of the purchased goods. The commodity can be a physical commodity or a virtual commodity, etc. The virtual goods can be electronic certificates for acquiring physical goods (such as air conditioners, mobile phones, sound boxes and the like), or electronic certificates for providing services (such as home services, online education, video members and the like), or virtual goods (such as skins of virtual images, game props and the like).

The tasks to be executed are tasks corresponding to all steps in the order creation request execution process, and the tasks to be executed have a front-back sequence.

Specifically, the server receives an order creating request of an account, analyzes the order creating request, and obtains commodity attribute information and order attribute information containing account information; verifying the commodity attribute information and the order attribute information according to a preset verification rule, and judging whether the information requirements of the execution of each task to be executed can be supported or not; and generating a verification result of the order creation request after the verification is completed.

For example, the account a triggers an order creation request for the commodity B, where the order creation request includes account information of the account a, such as a mobile phone number, a receiving address, and real-name authentication information, and also includes commodity attribute information of the commodity B, such as an identifier of the commodity B and a purchase quantity; in the verification process, the server can be used as a verification result of the order attribute information by judging whether the mobile phone number, the receiving address, the real-name authentication information and the like really exist or not; judging whether the inventory quantity corresponding to the identification is larger than the purchase quantity to serve as a verification result of the commodity attribute information; and determining a verification result of the order creation request according to the two verification results.

In step S220, the to-be-executed task of the verified order creation request is transmitted to the synchronous thread and the asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creation request.

The synchronous thread is a processing thread which sequentially executes each task to be executed according to the sequence of the tasks to be executed after the task to be executed of the order creation request is obtained; the asynchronous thread is a thread which can retry the to-be-executed task which cannot be normally processed in the synchronous thread after the synchronous thread starts to execute the to-be-executed task; the asynchronous thread has a delayed time sequence compared with the synchronous thread, and the synchronous thread can be enabled to process the task to be executed preferentially by setting the delay time of the asynchronous thread.

Specifically, the server acquires a task to be executed included in the order creation request and respectively transmits the task to the synchronous thread and the asynchronous thread; the synchronous thread starts executing the task to be executed in the order creation request immediately, and the asynchronous thread starts after a preset delay time t 1. And processing the task to be executed by the synchronous thread, and taking the task to be executed which is not completed or exceeds the preset execution time length after repeated processing for many times as an abnormal task to be executed. It should be noted that, in the present disclosure, the order creation request passing the verification already has a condition capable of being completed, the abnormal task to be executed may be caused by insufficient computing power of the server, network delay, and the like, and is caused by the asynchronous thread or the asynchronous thread itself, so that the abnormal task to be executed can be normally executed after a plurality of retries.

In step S230, if it is detected that there is an abnormal task to be executed in the synchronous thread, acquiring transmission state information of the abnormal task to be executed in the asynchronous thread; the asynchronous thread is used for executing an abnormal task to be executed.

The transmission state information is information for judging whether the task to be executed of the order creation request is successfully transmitted to the asynchronous thread.

The abnormal task to be executed refers to a task to be executed which meets a preset abnormal condition in the synchronous thread; for example, the execution times of the to-be-executed task Q in the synchronous thread exceed the preset times in the preset abnormal condition and are not yet executed, or the execution time of the to-be-executed task Q exceeds the preset duration in the preset abnormal condition.

The asynchronous thread can be restarted at a delay time t1 after the synchronous thread executes the order creation request, and the delay of the asynchronous thread compared with the synchronous thread can be realized through the delay time t1, that is, for the same order creation request, the asynchronous thread can be started after the delay time t1 when the synchronous thread starts execution, so that the synchronous thread is guaranteed to preferentially execute the order creation request normally.

Specifically, after the synchronous thread starts the delay time t1 for executing the task to be executed, the asynchronous thread starts to run; the server acquires the processing state of each task to be executed in the processing process of executing the task to be executed in the order creation request by the synchronous thread, and judges whether an abnormal task to be executed exists or not; if the synchronous thread has an abnormal task to be executed, the asynchronous thread correspondingly executes the abnormal task to be executed in the synchronous thread after a certain interval time; when monitoring that an abnormal task to be executed exists in the synchronous thread, the server acquires transmission state information of the abnormal task to be executed in the asynchronous thread, and judges whether the abnormal task to be executed is identified to be transmitted to the asynchronous thread in advance or not, so that the server is used as a basis for judging whether the asynchronous thread can execute the abnormal task to be executed or not; the asynchronous thread will retry continuously in the process of processing the abnormal task to be executed until the abnormal task to be executed is processed and completed in the asynchronous thread.

In step S240, an order creation result corresponding to the order creation request is returned to the account according to the transmission status information.

The order creating result is result information corresponding to the order creating request and comprises an order creating success result and an order creating failure result; the account may determine whether the order was created successfully by the order creation result.

Specifically, the server judges whether the abnormal task to be executed is successfully transmitted to the asynchronous thread according to the transmission state information, and if the abnormal task to be executed is successfully transmitted to the asynchronous thread, an order establishment result of the order establishment success is returned to the account; and if the order is not successfully transmitted to the asynchronous thread, returning an order ending creation result of which the order creation is failed to the account.

In the order creating method, the order creating request is verified by responding to the order creating request of the account; the order creation request comprises at least one task to be executed; then transmitting the task to be executed of the order creation request passing the verification to a synchronous thread and an asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creating request; then if the synchronous thread is detected to have an abnormal task to be executed, acquiring transmission state information of the abnormal task to be executed in the asynchronous thread; the asynchronous thread is used for executing an abnormal task to be executed; finally, an order creating result corresponding to the order creating request is returned to the account according to the transmission state information; the asynchronous thread can retry the abnormal task to be executed when the abnormal condition occurs; and returning an order creation result to the account according to the transmission state information of the asynchronous thread, which is beneficial to reducing the waste of server resources caused by the repeated sending of order creation requests by the account and reducing the load of the server.

In an exemplary embodiment, in step S240, returning an order creating result corresponding to the order creating request to the account according to the transmission status information specifically includes: if the transmission state information represents that the task to be executed is transmitted to the asynchronous thread, an order creation success result corresponding to the order creation request is returned to the account; the asynchronous thread is used for executing an abnormal task to be executed until the task is completed after an order creation success result is returned to the account; and if the transmission state information indicates that the task to be executed is not transmitted to the asynchronous thread, returning an order creation failure result corresponding to the order creation request to the account.

Specifically, the order creation success result refers to result prompt information about order creation success returned to the account in advance, and is not a real result of order creation; because the synchronous thread has an exception, the order creation request cannot be executed at the first time and a real result is returned, but the asynchronous thread can retry the abnormal task to be executed until the task to be executed is successfully executed, so that the successful result of the order creation is equivalent to returning the result to the account in advance, and then retry processing is performed until the real result of the order creation request is consistent with the order creation result returned to the account. In addition, if the transmission state information indicates that the to-be-executed task is not transmitted to the asynchronous thread, it indicates that the abnormal to-be-executed task cannot be executed at the first moment, and meanwhile, the asynchronous thread does not successfully transmit the abnormal to-be-executed task, so that a failure result of order creation is returned to the account to avoid the subsequent order creation request from being blocked due to retry of the current abnormal to-be-executed task, and the overall processing efficiency of the order creation request is improved.

The technical scheme provided by the embodiment of the disclosure avoids the situations of increased server load and server resource waste caused by the fact that the account cannot receive the order creation result for a long time and resubmits the order creation request.

In an exemplary embodiment, as shown in fig. 3, in step S210, in response to the order creation request of the account, the order creation request is verified, which may specifically be implemented by the following steps:

in step S211, the product attribute information and the order attribute information in the order creation request are acquired; the commodity attribute information comprises commodity identification and commodity quantity; the order attribute information includes address information and account information.

The commodity identification refers to identification information capable of identifying, searching and recording commodities, such as a commodity bar code, a book code (ISBN) and the like; the address information refers to an object address sent by the commodity corresponding to the order, for example, the address corresponding to the physical commodity is a mailing address where a receiver can receive the commodity, and the address information corresponding to the virtual commodity can be in the form of an account number, a website address and the like; the account information may also include user portrait information, user operation habit information, and user-to-user association.

In step S212, after the address information and the account information are verified, the inventory quantity of the product corresponding to the product identifier is acquired.

Specifically, the server judges whether the address information really exists or not, and judges whether the account information is real or whether the account information has the right to purchase the commodity or not, and the like as the conditions for passing the verification; and if the verification is passed, acquiring the commodity stock quantity corresponding to the commodity identification, wherein the commodity stock quantity is changed in real time and can be correspondingly deducted according to the created quantity of the order.

In step S213, if the product stock quantity is larger than the product quantity, it is confirmed that the order creation request check is passed.

The commodity quantity refers to the quantity of commodities purchased by an account.

Specifically, after the server determines that the address information and the account information are verified, if it is determined that the inventory quantity of the commodity is greater than the quantity of the commodity, which indicates that the commodity is in a purchasable state, it is determined that the order creation request can pass.

According to the technical scheme provided by the embodiment of the disclosure, the commodity attribute information and the order attribute information in the order creating request are legally judged to obtain the verification result of the order creating request, and the verification result can be subsequently returned to an account as the order creating result corresponding to the order creating request; the information verification process is simple, and the processing speed of the server is improved; meanwhile, the order creating result of the order creating request is judged in advance through information verification, so that the account can receive the corresponding result as soon as possible, the order creating result returning efficiency is improved, repeated submission of order creating is avoided, and the waste of server resources is reduced.

In an exemplary embodiment, in step S220, after transmitting the task to be executed of the checked order creating request to the asynchronous thread, the method further includes: and identifying the transmitted task to be executed in the asynchronous thread to obtain an identification result, setting a transmission identifier corresponding to the transmitted task to be executed according to the identification result, and taking the transmission identifier as the transmission state information of the task to be executed.

The identification result refers to the judgment of the transmitted task to be executed in the asynchronous thread by the server, the task to be executed successfully transmitted to the asynchronous thread can be identified through the identification result, and otherwise, the task to be executed unsuccessfully transmitted to the asynchronous thread can also be identified.

The transmission identifier is a mark of a transmitted state of a task to be executed which is transmitted to the asynchronous thread; whether the task to be executed is transmitted to the corresponding asynchronous thread can be quickly identified through the transmission identifier.

According to the technical scheme provided by the embodiment of the disclosure, the transmission identifier is set as the transmission state information of the task to be executed, so that the server can quickly judge whether the abnormal task to be executed is transmitted to the asynchronous thread, the processing efficiency of the server is improved, and the utilization of server resources is reduced.

In an exemplary embodiment, as shown in fig. 4, after transmitting the task to be executed of the order creation request passing the check to the asynchronous thread in step S220, the method further includes:

in step S410, a first execution result of the task to be executed transmitted in the synchronous thread and a second execution result of the task to be executed transmitted in the asynchronous thread are identified.

The first execution result refers to the execution condition of the task to be executed in the synchronous thread; the second execution result refers to the execution condition of the task to be executed in the asynchronous thread.

In step S420, updating the execution progress information of the order creation request according to the first execution result and the second execution result; the execution progress information is used for recording the execution condition of the task to be executed in the order creation request.

Specifically, the server periodically or in real time acquires the execution result of each transmitted task to be executed from the synchronous thread and the asynchronous thread, and updates the execution progress information of the order establishment request; judging the execution progress condition of the order creation request, and recording which tasks are normally processed and which are abnormal tasks to be executed in the transmitted tasks to be executed; the server can avoid repeated execution of the same task to be executed according to the execution progress information.

According to the technical scheme provided by the embodiment of the disclosure, the processing conditions of the tasks to be executed in each thread are stored and updated, repeated execution of the tasks to be executed is avoided, and waste of server resources is reduced.

In an exemplary embodiment, in step S230, before detecting that there is an abnormal task to be executed in the synchronous thread, the method further includes: acquiring the execution duration of a task to be executed in a synchronous thread; and if the execution time of the task to be executed exceeds the preset time, determining that the task to be executed is an abnormal task to be executed.

Specifically, the execution duration refers to a time range from a time point when the task to be executed starts processing in the synchronous thread to a current time point, and the execution duration can reflect a processing condition of the task to be executed; the preset time length refers to the regulation of the upper limit of the time range and can be set according to the time length required by the normal processing of the task to be executed; for example, the execution time of the to-be-executed task Z in the synchronization thread reaches 5 seconds, and the preset time is 3 seconds, which indicates that the execution time of the to-be-executed task Z in the synchronization thread exceeds the time used for normal processing, and accordingly, it can be determined that an abnormal condition occurs. According to the technical scheme provided by the embodiment of the disclosure, the preset time length is used as a condition for identifying the task to be executed as abnormal, so that the abnormal judgment of the task to be executed from the time dimension is realized, and the accuracy of identifying the abnormal task to be executed is improved.

In an exemplary embodiment, in step S230, before detecting that there is an abnormal task to be executed in the synchronous thread, the method further includes: obtaining the retry execution times of the tasks to be executed in the synchronous thread; and if the retry execution times of the task to be executed exceed the preset times, determining that the task to be executed is an abnormal task to be executed.

Specifically, the preset number of times may be set as needed. When the synchronous thread processes the task to be executed, if the synchronous thread fails, the synchronous thread will retry for a certain number of times, and the value of the execution number of times can be set according to the number of times of normally processing the task to be executed; and if the execution times exceed the preset times, the exception occurs when the task to be executed is processed. According to the technical scheme provided by the embodiment of the disclosure, the execution times are used as conditions for identifying the task to be executed as abnormal, so that the judgment of the abnormality of the task to be executed from the execution level is realized, and the accuracy of identifying the abnormal task to be executed is improved.

FIG. 5 is a flow chart illustrating another order creation method, as shown in FIG. 5, for use in the server shown in FIG. 1, including the steps of:

in step S510, commodity attribute information and order attribute information in the order creation request are acquired; the commodity attribute information comprises commodity identification and commodity quantity; the order attribute information comprises address information and account information; after the address information and the account information are verified, acquiring the inventory quantity of the commodities corresponding to the commodity identification; and if the inventory quantity of the commodities is larger than the quantity of the commodities, confirming that the order creation request passes the verification.

In step S520, the task to be executed of the verified order creation request is transmitted to the synchronous thread and the asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creation request.

In step S530, identifying the transmitted to-be-executed task in the asynchronous thread to obtain an identification result, setting a transmission identifier corresponding to the transmitted to-be-executed task according to the identification result, where the transmission identifier is used as transmission state information of the to-be-executed task; identifying a first execution result of a task to be executed which is transmitted in the synchronous thread and a second execution result of the task to be executed which is transmitted in the asynchronous thread; updating the execution progress information of the order creation request according to the first execution result and the second execution result; the execution progress information is used for recording the execution condition of the task to be executed in the order creation request.

In step S540, an execution duration of the task to be executed in the synchronous thread is obtained; and if the execution time of the task to be executed exceeds the preset time, determining that the task to be executed is an abnormal task to be executed.

In step S550, if the transmission status information indicates that the task to be executed has been transmitted to the asynchronous thread, an order creation success result corresponding to the order creation request is returned to the account; and the asynchronous thread is used for executing the abnormal task to be executed until the task to be executed is completed after an order creation success result is returned to the account.

The technical scheme provided by the embodiment of the disclosure can achieve the following technical effects: (1) the task to be executed of the order creation request is processed through the synchronous thread and the asynchronous thread simultaneously, so that the processing efficiency of the order creation request is improved; asynchronous threads also enhance the chances of successful order creation request processing. (2) In case of a fault, the complexity of the processing flow is not increased by the method; meanwhile, the order creation result is returned to the account in advance, so that the user experience is improved, and the repeated submission of the order creation request by the account is avoided. The method and the device are beneficial to reducing the waste of server resources caused by the repeated sending of the order creating request by the account and reducing the load of the server.

It should be understood that although the various steps in the flow charts of fig. 2-5 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-5 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.

FIG. 6 is a block diagram illustrating an order creation apparatus according to an exemplary embodiment. Referring to fig. 6, the apparatus includes a request checking unit 602, a task transporting unit 604, an abnormality detecting unit 606, and a result transmitting unit 608.

The request verification unit 602 is configured as a request verification unit configured to perform verification of an order creation request in response to the order creation request of the account; the order creation request comprises at least one task to be executed;

the task transportation unit 604 is configured to transmit the to-be-executed task of the checked order creation request to the synchronous thread and the asynchronous thread; the synchronous thread is used for executing the task to be executed in the order creating request;

an exception detection unit 606 configured to execute, if it is detected that an exception to-be-executed task exists in the synchronous thread, transmission state information of the exception to-be-executed task in the asynchronous thread is acquired; the asynchronous thread is used for executing an abnormal task to be executed;

and a result sending unit 608 configured to execute returning of an order creation result corresponding to the order creation request to the account according to the transmission status information.

In an exemplary embodiment, the result sending unit 608 is further configured to execute, if the transmission status information indicates that the task to be executed has been transmitted to the asynchronous thread, returning an order creation success result corresponding to the order creation request to the account; the asynchronous thread is used for executing an abnormal task to be executed until the task is completed after an order creation success result is returned to the account; and if the transmission state information indicates that the task to be executed is not transmitted to the asynchronous thread, returning an order creation failure result corresponding to the order creation request to the account.

In an exemplary embodiment, the request checking unit 602 is further configured to obtain the item attribute information and the order attribute information in the order creation request; the commodity attribute information comprises commodity identification and commodity quantity; the order attribute information comprises address information and account information; after the address information and the account information are verified, acquiring the inventory quantity of the commodities corresponding to the commodity identification; and if the inventory quantity of the commodities is larger than the quantity of the commodities, confirming that the order creation request passes the verification.

In an exemplary embodiment, the task transportation unit 604 is further configured to perform recognition on the to-be-executed task transmitted in the asynchronous thread to obtain a recognition result, set a transmission identifier corresponding to the transmitted to-be-executed task according to the recognition result, and use the transmission identifier as the transmission state information of the to-be-executed task.

In an exemplary embodiment, the order creating apparatus further includes an exception identifying unit configured to execute to acquire an execution duration of a task to be executed in the synchronous thread; and if the execution time of the task to be executed exceeds the preset time, determining that the task to be executed is an abnormal task to be executed.

In an exemplary embodiment, the exception identifying unit is further configured to perform acquiring the execution times of the tasks to be executed in the synchronous thread; and if the execution times of the tasks to be executed exceed the preset times, determining that the tasks to be executed are abnormal tasks to be executed.

In an exemplary embodiment, the exception detecting unit 604 is further configured to execute a first execution result identifying the task to be executed that has been transmitted in the synchronous thread and a second execution result identifying the task to be executed that has been transmitted in the asynchronous thread; updating the execution progress information of the order creation request according to the first execution result and the second execution result; the execution progress information is used for recording the execution condition of the task to be executed in the order creation request.

With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

FIG. 7 is a block diagram illustrating an apparatus 700 for performing the above-described order creation, according to an example embodiment. For example, device 700 may be a server. Referring to fig. 7, device 700 includes a processing component 720 that further includes one or more processors, and memory resources, represented by memory 722, for storing instructions, such as applications, that are executable by processing component 720. The application programs stored in memory 722 may include one or more modules that each correspond to a set of instructions. Further, the processing component 720 is configured to execute instructions to perform the order creation method described above.

The device 700 may also include a power component 724 configured to perform power management for the device 700, a wired or wireless network interface 726 configured to connect the device 700 to a network, and an input/output (I/O) interface 728. The device 700 may operate based on an operating system stored in memory 722, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.

In an exemplary embodiment, a computer-readable storage medium comprising instructions, such as memory 722 comprising instructions, executable by a processor of device 700 to perform the above-described method is also provided. The storage medium may be a computer-readable storage medium, for example, a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

In an exemplary embodiment, there is also provided a computer program product comprising a computer program stored in a readable storage medium, from which the at least one processor of the apparatus reads and executes the computer program, causing the apparatus to perform the order creation method in any one of the embodiments of the present disclosure.

Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种二手车上门检测下单抢单系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!