Task processing method and device
By implementing a queue system on the database to receive and store task processing requests, generate task identifiers, and process them at the head of the queue, the applicability of offline task processing in systems with poor infrastructure is solved. It also supports document file uploads and improves cross-language support, achieving more efficient task processing.
Patent Information
- Application Number
- CN202111255693.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2041-10-27
AI Technical Summary
Existing offline task processing technologies lack applicability in systems with poor infrastructure, do not support document file uploads, have strong client-server binding, and lack cross-language support.
The queue system is implemented using a database. It receives task processing requests, stores the objects to be processed and task processing parameters in a preset storage space, generates a task identifier and stores it in the queue, and processes the task when the task identifier is at the head of the queue. It supports uploading document files and reduces format requirements through JSON serialization.
It improves the applicability of offline task processing systems in systems with poor infrastructure, supports document file processing, reduces interface format requirements, and enhances cross-language friendliness.
Smart Images

Figure CN113986580B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of big data in the field of data processing, and more particularly to a task processing method and apparatus. Background Technology
[0002] Offline task processing technology is generally used to solve the problem of mismatch between the production task speed on the production side and the consumption task processing speed on the consumption side.
[0003] Offline task processing systems are generally designed following a producer-consumer architecture. Producers receive task messages and send them to a queue system, which in turn consumes these messages to process the tasks. Current queue systems are typically Kafka and RabbitMQ; however, these systems usually have high infrastructure requirements.
[0004] Therefore, current offline task processing technologies are not applicable to some systems with poor infrastructure. Summary of the Invention
[0005] This disclosure provides a task processing method and apparatus.
[0006] According to a first aspect of this disclosure, a task processing method is provided, applied to a first device, the first device including a database, the database including a first queue, the method comprising:
[0007] Receive a task processing request sent by the client, the task processing request including the object to be processed and task processing parameters;
[0008] Store the object to be processed and the task processing parameters in a preset storage space;
[0009] Based on the object to be processed and the task processing parameters, a task identifier is generated and stored in the first queue;
[0010] When the task identifier is at the head of the first queue, the object to be processed and the task processing parameters are obtained from the preset storage space according to the task identifier, and the object to be processed is processed according to the task processing parameters.
[0011] According to a second aspect of this disclosure, a task processing apparatus is provided, applied to a first device, the first device including a database, the database including a first queue, the apparatus comprising:
[0012] The receiving module is used to receive task processing requests sent by the client, wherein the task processing request includes the object to be processed and the task processing parameters;
[0013] The storage module is used to store the object to be processed and the task processing parameters into a preset storage space;
[0014] The processing module is used to generate a task identifier based on the object to be processed and the task processing parameters, and store the task identifier in the first queue;
[0015] The processing module is further configured to, when the task identifier is located at the head of the first queue, obtain the object to be processed and the task processing parameters from the preset storage space according to the task identifier, and process the object to be processed according to the task processing parameters.
[0016] According to a third aspect of this disclosure, an electronic device is provided, comprising:
[0017] At least one processor; and
[0018] A memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.
[0020] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method described in the first aspect.
[0021] According to a fifth aspect of this disclosure, a computer program product is provided, the computer program product comprising: a computer program stored in a readable storage medium, wherein at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to cause the electronic device to perform the method described in the first aspect.
[0022] The technology disclosed herein solves the problem of the lack of applicability of offline task processing technology.
[0023] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0024] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0025] Figure 1 A schematic diagram illustrating the implementation of the producer-consumer architecture pattern provided in this embodiment of the disclosure;
[0026] Figure 2 Flowchart of the task processing method provided in the embodiments of this disclosure Figure 1 ;
[0027] Figure 3 Flowchart of the task processing method provided in the embodiments of this disclosure Figure 2 ;
[0028] Figure 4 A schematic diagram illustrating the implementation of the client's operation results provided in this embodiment of the disclosure;
[0029] Figure 5 A schematic diagram of serialization transmission provided for embodiments of this disclosure;
[0030] Figure 6 This is a schematic diagram of queuing task messages provided in an embodiment of the present disclosure;
[0031] Figure 7 This is a schematic diagram illustrating the dequeueing of task messages provided in an embodiment of the present disclosure;
[0032] Figure 8 This is a schematic diagram of the processing flow provided in the embodiments of this disclosure;
[0033] Figure 9 This is a schematic diagram of the structure of a task processing device according to an embodiment of the present disclosure;
[0034] Figure 10 This is a block diagram of an electronic device used to implement the task processing method of the embodiments of this disclosure. Detailed Implementation
[0035] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0036] To better understand the technical solutions disclosed herein, the relevant technologies involved in this disclosure will be further described in detail below.
[0037] Offline task processing technology is generally used to solve the problem of mismatch between the speed of production tasks on the production side and the speed of consumption processing tasks on the consumption side, so as to achieve decoupling between the production side and the consumption side and improve system availability.
[0038] The design of offline task processing systems generally follows the producer-consumer architecture pattern, for example, it can combine... Figure 1Understanding the producer-consumer architecture pattern Figure 1 This is a schematic diagram illustrating the implementation of the producer-consumer architecture pattern provided in an embodiment of this disclosure.
[0039] like Figure 1 As shown, the producer-consumer architecture pattern includes producers, consumers, and a queue system. Producers receive task messages and send them to the queue system. Consumers consume task messages from the queue system and execute specific task logic. The queue system middleware is responsible for: (1) message reception, (2) message storage, and (3) message publishing.
[0040] Therefore, based on the above introduction, it can be determined that the core of the producer-consumer pattern is the queue system. Currently, Kafka and RabbitMQ are two representative open-source queue systems. Kafka is a high-throughput distributed publish-subscribe messaging system, excelling in high concurrency and streaming message processing and consumption. Rabbit Message Queue (RabbitMQ) is an open-source message broker software (also known as message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP), excelling in complex message routing.
[0041] In addition, there is currently the TextMind offline task processing system. TextMind is an intelligent document analysis platform. The TextMind offline task processing system mainly supports computationally intensive, low-volume offline document analysis tasks such as document parsing, document extraction, and document comparison in private scenarios.
[0042] Based on the above introduction, it's understandable that current offline task processing systems generally adopt a producer-consumer architecture. The producer exposes an interface to the outside world. After receiving a request, the producer packages the request content into a task message and sends it to the queue system. The consumer then listens to the task queue, and upon receiving a new task message, executes different operation logic based on the task name in the message.
[0043] However, existing queuing systems are typically Kafka and RabbitMQ, which generally have high infrastructure requirements. Therefore, current offline task processing technologies are not suitable for systems with poor infrastructure.
[0044] For example, the delivery scenario for private bank customers has the following characteristics: (1) the system is required to have high stability; (2) the product delivery and subsequent operation and maintenance costs are low; and (3) the software infrastructure of traditional industry customers is relatively conservative. It is understandable that any scenario that meets the above characteristics is a system with poor infrastructure, not limited to the private bank customer delivery scenario described above. This embodiment does not limit the specific implementation of specific systems with poor infrastructure.
[0045] Meanwhile, existing technologies also have limitations, such as the production side not supporting document file uploads, strong client-server binding, and poor cross-language support.
[0046] To address the problems in the prior art, this disclosure proposes the following technical concept: relying on a database to implement a queue system. Since databases typically exist in various systems, implementing a queue system based on a database can effectively improve the applicability of offline task processing.
[0047] Based on the above description, the task processing method provided by this disclosure will be described below with reference to specific embodiments. It is worth noting that all embodiments in this disclosure can be applied to a first device, which may include a database, and the database may include a first queue. In one possible implementation, the first device in this embodiment may be, for example, a server, or it may be a processor, microprocessor, or other device with data processing capabilities. This embodiment does not limit the specific implementation of the first device, as long as the first device includes a database and the database includes a first queue.
[0048] The following is a combination of... Figure 2 This disclosure introduces the task processing methods provided. Figure 2 Flowchart of the task processing method provided in the embodiments of this disclosure Figure 1 .
[0049] like Figure 2 As shown, the method includes:
[0050] S201. Receive a task processing request sent by the client. The task processing request includes the object to be processed and the task processing parameters.
[0051] In this embodiment, the client may, for example, display an operation page for generating task processing requests to the user. In one possible implementation, the client's operation interface may, for example, respond to the user's operation, thereby receiving the object to be processed uploaded by the user and the task processing parameters input by the user.
[0052] In one possible implementation, the object to be processed can be, for example, a document file, or a command field, or data to be processed, etc. This embodiment does not limit the specific implementation of the object to be processed. Any object that needs to be processed can be used as the object to be processed in this embodiment.
[0053] After the client receives the object to be processed and the task processing parameters input by the user in the operation interface, it can generate a task processing request based on the user's submission operation, and then send the task processing request to the first device. Therefore, the first device in this embodiment can receive the task processing request sent by the client.
[0054] In one possible implementation, the task processing request includes a task object to be processed and task processing parameters. The task processing parameters may include a task type and / or a task execution field. In the specific implementation process, the contents included in the task processing parameters can also be selected and set according to actual needs. All parameters related to task processing can be used as task processing parameters in this embodiment.
[0055] In this embodiment, the task processing request can be used to request the first device to perform the task operation corresponding to the task processing parameters of the object to be processed. In addition to the object to be processed and the task processing parameters described above, the contents included in the task processing request can also be selected and expanded according to actual needs. This embodiment does not limit this.
[0056] In one possible implementation of this embodiment, when the first device receives a task processing request from the client, for example, the producer in the first device may receive the task processing request sent by the client. The producer may be a logical unit in the first device, which generates a task identifier and stores the task identifier in a first queue.
[0057] S202. Store the object to be processed and the task processing parameters to the preset storage space.
[0058] After receiving a task processing request, the first device can, for example, store the object to be processed and the task processing parameters in a preset storage space within the first device. This preset storage space can be, for example, a disk, or any storage unit within the first device.
[0059] It is worth noting that in this embodiment, the objects to be processed and the task processing parameters are stored in a preset storage unit instead of in the queue system. This is because the amount of data that a queue system can typically store is very limited, while the data size of the objects to be processed is generally quite large. If the objects to be processed were directly stored in the queue system, the data size of the task messages might exceed the upper limit supported by the queue system. Therefore, in this embodiment, the objects to be processed and the task processing parameters are stored in a preset storage unit, thereby saving storage space in the first queue.
[0060] S203. Generate a task identifier based on the object to be processed and the task processing parameters, and store the task identifier in the first queue.
[0061] In this embodiment, a task identifier can be generated based on the object to be processed and the task processing parameters. The task identifier in this embodiment can be a number, a letter, or a string, etc. This embodiment does not impose any special restrictions on the specific implementation of the task identifier, as long as the task identifier can uniquely distinguish each object to be processed and the task processing parameters. It can be understood that each task identifier corresponds to its own object to be processed and task processing parameters.
[0062] After generating the task identifier, the task identifier can be stored in the first queue. It is understood that the queue system in this embodiment is based on a database. Therefore, when storing the task identifier in the first queue, it can be done, for example, through the operation of creating a record in the database.
[0063] S204. When the task identifier is at the head of the first queue, retrieve the object to be processed and the task processing parameters from the preset storage space according to the task identifier, and process the object to be processed according to the task processing parameters.
[0064] In this embodiment, after the production end generates a task identifier and stores it in the first queue, multiple task identifiers can be stored in the first queue. It is understood that the queue has a first-in-first-out characteristic. Therefore, when the generated task identifier is at the head of the first queue, the task corresponding to that task identifier can be processed.
[0065] Based on the above introduction, it can be determined that the objects to be processed and the task processing parameters are stored in the preset storage space, and the task identifier corresponds to the objects to be processed and the task processing parameters. Therefore, when the task identifier is at the head of the first queue, the objects to be processed and the task processing parameters corresponding to the task identifier can be obtained from the preset storage space according to the task identifier.
[0066] Then, the consumer in the first device can process the object to be processed according to the task processing parameters. In one possible implementation, for example, if the object to be processed is a text document, it can perform document parsing, document extraction, document comparison, etc. In this embodiment, the consumer in the first device can be a logic unit in the first device, used to obtain the task identifier from the first queue and execute the task corresponding to the task identifier.
[0067] The task processing method provided in this disclosure includes: receiving a task processing request sent by a client, the task processing request including a task object to be processed and task processing parameters; storing the task object to be processed and task processing parameters in a preset storage space; generating a task identifier based on the task object to be processed and task processing parameters, and storing the task identifier in a first queue; when the task identifier is at the head of the first queue, retrieving the task object to be processed and task processing parameters from the preset storage space based on the task identifier, and processing the task object to be processed according to the task processing parameters. By implementing a queue system based on a database, since databases are widely available in various systems, the applicability of the offline task processing system can be effectively improved.
[0068] Based on the above embodiments, the following is combined with Figures 3 to 8 The task processing method provided in this disclosure will be further described in detail. Figure 3 Flowchart of the task processing method provided in the embodiments of this disclosure Figure 2 , Figure 4 This is a schematic diagram illustrating the implementation of the client's operation results provided in this embodiment of the disclosure. Figure 5 This is a schematic diagram of serialization transmission provided in an embodiment of the present disclosure. Figure 6 This is a schematic diagram illustrating the queuing of task messages provided in an embodiment of this disclosure. Figure 7 This is a schematic diagram illustrating the dequeueing of task messages provided in an embodiment of this disclosure. Figure 8 This is a schematic diagram of the processing flow provided in the embodiments of this disclosure.
[0069] like Figure 3 As shown, the method includes:
[0070] S301. Receive a task processing request sent by the client. The task processing request includes the object to be processed and the task processing parameters.
[0071] The implementation of S301 is similar to that described in S201 above. In this embodiment, the object to be processed is a document file as an example, and the object to be processed and the task processing parameters are further described in detail.
[0072] In one possible implementation, the task processing parameters may include a task type and / or a task execution field. The task type may include, but is not limited to, different methods for processing the object to be processed, such as information extraction, information comparison, and information parsing.
[0073] Taking a document file as an example, the task types in this embodiment may include document extraction, document comparison, document parsing, etc. In actual implementation, the specific implementation of the task type can be selected according to actual needs. The task execution field in this embodiment can be the field required to execute the corresponding task type. For example, for a task of document extraction, the task execution field may include the field to be extracted, or for a task of document parsing, the task execution field may include the content to be parsed, etc. This embodiment does not limit the specific implementation of the task type and the task execution field, and it can be selected and designed according to different task execution implementations.
[0074] Taking a document file as an example, for instance, it can be combined with... Figure 4 The user interface provided by the client will be described in further detail, such as... Figure 4 As shown, the client's user interface may include, for example, an operation control 401 for uploading document files, which the user can use. Figure 4 At the operation control indicated by 401, select a document file to upload. The uploaded document file can be any format, such as Word, PDF, Excel, etc. This embodiment does not impose any restrictions on this.
[0075] The user interface may also include a selection control 402 for selecting the task type. In one possible implementation, such as... Figure 4 As shown, for example, users can select preset task types, where the task type can include... Figure 4 The document extraction, document comparison, document parsing, etc. shown in this embodiment do not limit the implementation method of specific task types; they can be selected and set according to actual needs.
[0076] and reference Figure 4 The operation interface may also include a control 403 for inputting task execution fields, where the user can input task execution fields at the location indicated by the control 403. The task execution fields may be, for example, fields to be extracted in document extraction, or targets to be parsed in document parsing, etc. This embodiment does not limit the specific implementation of the task execution fields.
[0077] After the user completes the input of the document file and task processing parameters, for example, they can click... Figure 4 The client can then obtain the submission instruction generated by the user clicking the 404 submission button, respond to the submission instruction, generate a task processing request based on the document file and task request parameters described above, and send the task processing request to the first device.
[0078] The above Figure 4 This document describes the implementation method when the object to be processed is a text document. When the object to be processed is another type of document, the implementation method is similar to that described above. For example, the user can input commands or data on the client's operation interface, and then the client can obtain the object to be processed. The user can also perform selection operations similar to those described above. Therefore, the client can obtain task execution parameters. Other possible implementation methods for the object to be processed will not be described in detail in this embodiment.
[0079] It should be noted that offline task processing systems in related technologies do not support uploading document files; therefore, existing implementations cannot handle document file processing tasks. However, in this embodiment, the upload interface can be designed using a RESTful API approach, employing the Hypertext Transfer Protocol (HTTP) Multipart-Form format to support the upload of one or more documents.
[0080] This section provides a brief explanation of RESTful APIs. REST stands for Representational State Transfer. If an architecture conforms to the constraints and principles of REST, we call it a RESTful architecture. API stands for Application Programming Interface. In short, RESTful APIs are a set of API design theories for internet applications.
[0081] Furthermore, in designing the upload interface, this embodiment also considers the universality of the interface. In order to make the interface easy to access, for example, after receiving the uploaded task processing parameters, the task processing parameters can be serialized into JSON, and then the serialized data stream can be transmitted to the production end of the first device as a field of Multipart-Form along with the document file.
[0082] JSON stands for JavaScript Object Notation. JSON serialization can serialize the object to be transmitted into a binary data stream, which is highly efficient. Furthermore, by serializing the task processing parameters before transmission, the relevant format requirements during transmission can be reduced. Therefore, in this embodiment, there are no excessive format restrictions on the task processing parameters, which makes the interface easy to integrate.
[0083] For example, you can refer to Figure 5 To understand, such as Figure 5 As shown, after receiving the task processing parameters and the object to be processed, the client can serialize the task processing parameters into JSON and then send the serialized task processing parameters and the object to be processed to the production end of the first device.
[0084] Then, the production end in the first device can deserialize the serialized task processing parameters to obtain the task processing parameters and the object to be processed, thereby enabling the correct transmission of the task processing request.
[0085] Understandably, the JSON serialization described above is primarily for ease of transmission and to reduce the format requirements of task processing parameters, thus making the interface easier to integrate. The first device then deserializes the received data into an object, achieving the desired transmission. Simply put, serialization converts an object into a JSON string, and deserialization is the reverse process, converting the JSON string back into an object.
[0086] S302. Verify the task processing parameters according to preset conditions. If the task processing parameters meet the preset conditions, store the object to be processed and the task processing parameters in the preset storage space.
[0087] In this embodiment, after the production end in the first device obtains the task processing parameters and the object to be processed, it can, for example, first verify the task processing parameters according to preset conditions. When it is determined that the task processing parameters meet the preset conditions, the object to be processed and the task processing parameters are then stored in the preset storage space.
[0088] Understandably, if a certain task type is to be executed successfully, the task processing parameters need to meet the corresponding preset conditions.
[0089] For example, if the task processing parameters include a task execution field, and the task type is information extraction, the preset condition includes: the task execution field includes the field to be extracted. Alternatively, if the task type is information comparison, the preset condition includes: the number of objects to be processed is greater than or equal to 2. In actual implementation, the specific implementation method of the preset conditions can be selected and set according to actual needs. This embodiment does not limit this, as long as the preset conditions are set so that the corresponding task type can be executed.
[0090] The implementation method for storing the objects to be processed and the task processing parameters to the preset storage space is similar to that described above, and will not be repeated here.
[0091] S303. Generate a task identifier based on the object to be processed and the task processing parameters.
[0092] In this embodiment, the production end of the first device can generate a task identifier based on the object to be processed and the task processing parameters. As long as the task identifier can uniquely indicate the object to be processed and the task processing parameters, the implementation method is similar to that described in the above embodiments, and will not be repeated here.
[0093] In one possible implementation, when storing the object to be processed and the task processing parameters to a preset storage space, for example, the object to be processed and the task processing parameters can be stored in a folder named after the task identifier to achieve the binding of the object to be processed and the task processing parameters. The folder is located in the preset storage space.
[0094] S304. Generate the timestamp corresponding to the time when the task identifier is stored in the first queue.
[0095] After generating the task identifier, it can be stored in the first queue, whereby it awaits processing by the consumer.
[0096] In one possible implementation, when storing the task identifier, it is also necessary to store, for example, the timestamp of the current task's creation, as well as at least one of the task status and task type, so that the timestamp corresponding to storing the task identifier in the first queue can be generated.
[0097] S305. Set the task status corresponding to the task identifier to the first status.
[0098] Based on the above introduction, when storing task identifiers, it is also necessary to store task status synchronously. Currently, task identifiers need to be stored in the first queue for queuing. Therefore, the task status corresponding to the task identifier can be set to the first status, where the first status is used to indicate that the current task identifier is waiting to be processed in the queue.
[0099] In one possible implementation, the task state in this embodiment may include three states: queueing, running, and finished. The current first state may be, for example, the queueing state described above.
[0100] S306. Encapsulate the task identifier and at least one of the following into a task message: timestamp, task status, and task type corresponding to the task identifier.
[0101] After confirming the content described above, refer to Figure 6 For example, the task identifier can be encapsulated with at least one of the following to obtain the task message, which can then be stored in the queue system. The encapsulated items may include at least one of the following: timestamp, task status, and task type corresponding to the task identifier.
[0102] S307. Call the enqueue interface of the first queue to write the task message into the first queue.
[0103] In one possible implementation, the first queue in this embodiment may support three actions: enqueue, dequeue, and commit.
[0104] When it is necessary to store the task message in the first queue, the producer in the first device can, for example, call the enqueue method to write the encapsulated task message into the first queue. It is understood that the first queue in this embodiment is a database-based queue system; therefore, for example, the task message can be written into a queue system with a relational database as the backend. The timestamp, task identifier, task status, and task type encapsulated in the task message each correspond to a field in the database.
[0105] The enqueueing method described above can, for example, correspond to the operation of creating records in a relational database.
[0106] For example, it can be combined Figure 6 To understand, such as Figure 6 As shown, for example, in this embodiment, the encapsulated task message is task message n, which can be written to the tail of the first queue. (Refer to...) Figure 6 The first queue may include multiple task messages, and the way they are stored in the first queue is the same as described above, so it will not be repeated here.
[0107] In an alternative implementation, after storing the task identifier in the first queue, the first device may, for example, return the task identifier to the client. The client can then query the corresponding task status based on the task identifier, or, for example, display the queried task status to the user, so that the user can quickly and effectively determine the execution status of the current task.
[0108] S308. When the task identifier is at the head of the first queue, obtain the task type from the task message and determine the first task processing unit corresponding to the task type.
[0109] Based on the above description, it can be determined that the first queue can include multiple task messages, all of which are queued for processing. Given the first-in-first-out characteristic of the queue, only the task corresponding to the task identifier at the head of the queue can be processed.
[0110] Therefore, in this embodiment, when the task identifier is located at the head of the first queue, the task can be processed. Based on the above description, it can be determined that the first queue stores task messages. Therefore, the task identifier being located at the head of the first queue actually means that the task message corresponding to the task identifier is located at the head of the first queue.
[0111] In one possible implementation, the first device may include at least one task processing unit, which can be understood as a consumer, for example. Each task processing unit corresponds to a different task type. That is, the first device may include multiple consumers, and each consumer can process the corresponding task type.
[0112] Then it is necessary to determine what type of task the current task message at the head of the queue is. For example, when the task message generated above is at the head of the first queue, the task type can be obtained from the task message, and the first task processing unit corresponding to the task type can be determined.
[0113] Here's an example, taking a text document as the object to be processed. In one possible implementation, the first device could include three task processing units, each corresponding to one of the three consumers. These three task processing units are Task Processing Unit 1, Task Processing Unit 2, and Task Processing Unit 3. Task Processing Unit 1 handles tasks involving document comparison, Task Processing Unit 2 handles tasks involving document extraction, and Task Processing Unit 3 handles tasks involving document parsing.
[0114] For example, if the task type of task message n at the head of the queue is document extraction, then task processing unit 2 can be identified as the first task processing unit, and task message n can be processed by the first task processing unit. In actual implementation, the number of task processing units included in the first device can be selected according to actual needs. This embodiment does not limit this; for example, it can also include 6 task processing units, and each task type can correspond to one or more task processing units.
[0115] Furthermore, the above describes the implementation method of including multiple task processing units in the first device. In another possible implementation method, for example, a cluster can be used for offline task processing. Then, the consumer end can correspond to multiple instances, one of which can be understood as a server. That is to say, multiple servers can exist at the same time to process tasks. Each instance can include multiple consumers. In one possible implementation method, different types of tasks can correspond to different consumers.
[0116] By setting up multiple task processing units in the first device as described above, or by setting up multiple instances of the consumer, the throughput of the system can be effectively improved. At the same time, different types of tasks correspond to different consumers, which allows each consumer to acquire and process tasks corresponding to each task type separately, so as to avoid the problem of low task processing efficiency caused by uneven consumption speed of different task types.
[0117] S309. The first task processing unit calls the dequeue interface of the first queue to obtain task messages from the first queue.
[0118] Reference Figure 7 Suppose that the task message currently at the head of the first queue is task message n, and the first task processing unit corresponding to task message n has been determined above, then in one possible implementation, after determining the first task processing unit, the first task processing unit may, for example, call the dequeue interface of the first queue to perform a dequeue operation on task message n, thereby obtaining task message n from the first queue.
[0119] S310, the first task processing unit stores the task message in the buffer queue in the first task processing unit, and sets the task status in the task message to the second status.
[0120] In one possible implementation, to improve task processing speed and efficiency, a buffer queue can be set up in each task processing unit. After dequeuing the task messages in the first queue, each task processing unit can store the task messages in its own buffer queue, and then process the task messages in the buffer queue sequentially. While storing the task messages in the buffer queue, the task status of the task messages can also be set to a second status, which indicates that the task message is currently being processed; therefore, the second status could be, for example, "running".
[0121] By setting up a buffer queue, we can decouple task loading from actual task processing. Furthermore, the buffer queue can temporarily store batch-loaded tasks, reducing the number of queries. It's understandable that, since only the task message at the head of the first queue can be dequeued, if the task message at the head of the queue is processed in real-time and dequeued only after completion, all other task messages in the first queue would have to wait for the head message to finish, leading to slow task message processing efficiency.
[0122] However, in this embodiment, each task message in the first queue can be dequeued sequentially and stored in the buffer queue of its corresponding task processing unit. Then, different task processing units can process the tasks in their respective buffer queues in parallel, thereby effectively improving task processing efficiency. It is understood that when the consumer accesses the first queue to dequeue each task message into the buffer queue of a different task processing unit, the consumer can continuously dequeue task messages from the first queue sequentially, or it can periodically dequeue a preset number of task messages from the first queue. This embodiment does not impose any restrictions on this.
[0123] Meanwhile, when processing tasks, the task processing unit will process the task as long as there is a task message in the buffer queue. Furthermore, after storing the task message in the task processing unit's buffer queue, the task status in the task message can be set to "running" to indicate that the task message is currently being processed.
[0124] For example, it can be combined Figure 7 To understand this, for example, if the head of the first queue is task message n, and assuming the task type in task message n is document extraction, then we can determine that the task processing unit corresponding to task message n is task processing unit 2. Therefore, task processing unit 2 can dequeue task message n and then store task message n in the buffer queue of task processing unit 2 for processing.
[0125] After task message n is dequeued, task message n+1 will be at the head of the first queue. Assuming task message n+1 corresponds to task processing unit 1, task processing unit 1 can dequeue task message n+1 and then store it in the buffer queue of task processing unit 1 for processing.
[0126] Furthermore, after task message n+1 is dequeued, task message n+2 will be at the head of the first queue. Assuming task message n+2 corresponds to task processing unit 3, task processing unit 3 can dequeue task message n+2 and then store it in the buffer queue of task processing unit 3 for processing.
[0127] Based on the above examples, it can be determined that, for both task message n+1 and task message n+2, it is not necessary to wait for the previous task message to be processed before it can be processed. Instead, it is dequeued into different buffer queues according to its respective task type, thus enabling parallel processing of multiple task messages.
[0128] In one possible implementation, since the same task type may correspond to multiple task processing units, in order to avoid task consumption conflicts, a mutex lock mechanism can be added to the task message. For example, after the task message is loaded, the status of the task message in the database can be set to the locked state, and the time to live (TTL) value of the locked state can be set.
[0129] Understandably, in a locked state, no processing unit can process the task message except for the task processing unit that acquired the message. The purpose of setting the TTL is to ensure that if a task processing unit crashes for some reason, the task lock can be automatically released after a period of time, thus avoiding deadlock. Therefore, setting a mutex lock mechanism can ensure that the task will not be consumed repeatedly, and setting the TTL can effectively prevent the task from being unable to be processed due to deadlock.
[0130] It should also be noted that the above describes the implementation methods of each task processing unit. Alternatively, the consumption instance described above can also be used for task consumption and processing. In other words, different servers can be implemented in a similar way to the individual task processing units, as long as the task processing unit is regarded as a consumption instance.
[0131] S311. When the task message is at the head of the buffer queue, the first task processing unit obtains the object to be processed and the task processing parameters from the preset storage space according to the task identifier.
[0132] It is understandable that the buffer queue in the first task processing unit can include at least one task message, and the task messages in the buffer queue are also first-in-first-out, so the task processing is done on the head of the buffer queue.
[0133] Therefore, when the aforementioned determined task message is at the head of the buffer queue, the first task processing unit can obtain the object to be processed and the task processing parameters from the preset storage space based on the task identifier in the task message, and then perform corresponding processing on the object to be processed.
[0134] S312. The first task processing unit determines at least one processing node corresponding to the task type, wherein the processing nodes are connected in sequence and each processing node corresponds to a task processing step of the task type.
[0135] In one possible implementation, each task type in this embodiment can correspond to at least one processing result, wherein each processing node is connected sequentially, and each processing node corresponds to each task processing stage of the task type.
[0136] For example, in the task type of document extraction, the task processing steps may include document recognition, document analysis, querying the fields to be extracted, content extraction, and result output. Each of these steps can be abstracted as a processing result, thus resulting in a series of interconnected processing nodes. The same applies to other task types, as each task type involves many different processing flows, each of which can be abstracted as a node. A node can include, for example, the actions performed in the flow and its context. Linking different nodes together constitutes the task flow for that task type.
[0137] For example, you can refer to Figure 8 To understand the task nodes, refer to... Figure 8 The client can send task processing requests to the consumer. For example, the client could be... Figure 8 The HTTP client shown is illustrated. The consumer side can include multiple producers, each of which can generate task messages based on task processing requests and store these messages in a queue system, as described above.
[0138] and reference Figure 8 On the consumer side, there can be multiple consumers, each of whom can have their own task type. For each task type, there can be [missing information - likely related to consumer behavior]. Figure 8 As shown, multiple nodes are connected in sequence. Then, each consumer can obtain the task type of the task to be processed, thereby determining the processing nodes corresponding to the task type of the current task.
[0139] S313. Process the object to be processed according to the sequentially connected processing nodes.
[0140] After determining each processing node, the objects to be processed can be processed according to the sequentially connected processing nodes. It can be understood that the nodes are linked to each other, and the input of the previous node is given to the next node as the input of the next node, thus forming a complete production processing chain to realize the processing of the objects to be processed.
[0141] In one possible implementation, the consumer can also limit the number of threads on the execution node based on the maximum number of parallelisms configured for each node, thereby protecting the consumer itself and the external systems it depends on.
[0142] It is understood that in this embodiment, by abstracting the task processing flow of each task type, sequentially linked nodes are obtained. Then, when processing tasks, the corresponding nodes are obtained directly according to the task type of the current task, and the task is processed according to the nodes. This can effectively reduce the complexity of task processing and improve the operational efficiency of task processing.
[0143] S314. Set the task status of the task identifier corresponding to the object to be processed to the third status, and send the processing result of the object to be processed to the client.
[0144] After a task is completed, for example, the task status of the task identifier corresponding to the currently processed pending object can be set to the third state, where the third state indicates that the current task processing is complete, for example, the third state can be "Ended". In one possible implementation, after the task processing is completed, for example, the commit method of the first queue can be called to set the task status to the third state.
[0145] It is understood that the dequeue, enqueue, and merge operations of the first queue in this embodiment are all implemented on the basis of the database. Therefore, they correspond to the corresponding operations in the database, such as creating records, deleting, and updating fields.
[0146] After the task is completed, the processing result of the object to be processed can be sent to the client. In this embodiment, the processing result depends on the current task type. For example, when the task type is document comparison, the processing result may be the differences between the two documents. Or, when the task type is document extraction, the processing result may be the field content corresponding to the fields to be extracted in the document. For example, if the document file is a contract, the result could be extracting information such as "Who is Party A?", "Who is Party B?", etc., where "Party A" and "Party B" are the fields to be extracted, and their specific content is the field content. Or, when the task type is document parsing, the processing result may be the parsing result, etc. This embodiment does not limit the specific implementation of the processing result; it can be selected and set according to actual needs.
[0147] After receiving the processing result, the client can display the result on its interface, or it can respond to a user's query and then display the result. This embodiment does not limit this. It is also worth noting that the client in this embodiment runs on a terminal device, which can be, for example, a mobile phone, computer, tablet computer, etc. This embodiment does not limit this.
[0148] The task processing method provided in this disclosure verifies the task processing parameters according to preset conditions after receiving them, and only proceeds with subsequent processing when the verification passes, thereby ensuring the correctness and executability of subsequent task processing. Simultaneously, by storing the objects to be processed and the task processing parameters in a preset storage space, the situation where the first queue cannot store the data due to the large amount of data of the objects to be processed can be effectively avoided, effectively saving storage space in the first queue. Furthermore, by setting buffer queues in each task processing unit, the loading and processing of task messages can be decoupled, ensuring that each task message does not have to wait for the task at the head of the queue to complete processing, thereby effectively improving the speed and efficiency of task processing. Moreover, by implementing the queue system based on a database, such as implementing enqueue, dequeue, and merge operations in the first queue based on the database, the applicability of the offline task processing system can be effectively improved. Finally, by using the HTTP protocol's Multipart-Form format in the upload interface in this embodiment, the offline task processing system can support the upload of one or more documents.
[0149] Figure 9 This is a schematic diagram of the structure of a task processing device according to an embodiment of this disclosure. Figure 9 As shown, the task processing device 900 of this embodiment may include: a receiving module 901, a storage module 902, and a processing module 903.
[0150] The receiving module 901 is used to receive a task processing request sent by the client, wherein the task processing request includes an object to be processed and task processing parameters;
[0151] Storage module 902 is used to store the object to be processed and the task processing parameters into a preset storage space;
[0152] The processing module 903 is used to generate a task identifier based on the object to be processed and the task processing parameters, and store the task identifier in the first queue;
[0153] The processing module 903 is further configured to, when the task identifier is located at the head of the first queue, obtain the object to be processed and the task processing parameters from the preset storage space according to the task identifier, and process the object to be processed according to the task processing parameters.
[0154] In one possible implementation, the task processing parameters include the task type, and the storage module 902 is further used for:
[0155] Generate a timestamp corresponding to the time when the task identifier is stored in the first queue;
[0156] Set the task status corresponding to the task identifier to the first status;
[0157] The task identifier and at least one of the following are associated and stored in the first queue: the timestamp, the task status, and the task type corresponding to the task identifier.
[0158] In one possible implementation, the storage module 902 is further configured to:
[0159] The task identifier and at least one of the following are encapsulated into a task message: the timestamp, the task status, and the task type corresponding to the task identifier;
[0160] Call the enqueue interface of the first queue to write the task message into the first queue.
[0161] In one possible implementation, the processing module 903 is further configured to:
[0162] Before storing the object to be processed and the task processing parameters into the preset storage space, the task processing parameters are verified according to preset conditions. If the task processing parameters meet the preset conditions, the object to be processed and the task processing parameters are stored into the preset storage space.
[0163] In one possible implementation, if the task processing parameters include a task execution field, and the task type is information extraction, then the preset condition includes: the task execution field includes a field to be extracted.
[0164] If the task type is information comparison, the preset conditions include: the number of objects to be processed is greater than or equal to 2.
[0165] In one possible implementation, the first device further includes at least one task processing unit, wherein each task processing unit corresponds to a different task type;
[0166] The processing module 903 is also used for:
[0167] Before obtaining the object to be processed and the task processing parameters from the preset storage space according to the task identifier, the task type is obtained from the task message, and the first task processing unit corresponding to the task type is determined, wherein the task message is located at the head of the first queue;
[0168] The first task processing unit calls the dequeue interface of the first queue to obtain the task message from the first queue;
[0169] The first task processing unit stores the task message in a buffer queue within the first task processing unit and sets the task status in the task message to a second status.
[0170] In one possible implementation, the processing module 903 is further configured to:
[0171] When the task message is at the head of the buffer queue, the first task processing unit retrieves the object to be processed and the task processing parameters from the preset storage space according to the task identifier.
[0172] In one possible implementation, the processing module 903 is further configured to:
[0173] The first task processing unit determines at least one processing node corresponding to the task type, and the processing nodes are connected in sequence, with each processing node corresponding to a task processing step of the task type.
[0174] The object to be processed is processed according to each of the sequentially connected processing nodes.
[0175] In one possible implementation, the processing module 903 is further configured to:
[0176] After processing the object to be processed according to the task processing parameters, the task status of the task identifier corresponding to the object to be processed is set to the third status, and the processing result of the object to be processed is sent to the client.
[0177] This disclosure provides a task processing method and apparatus, which are applied to the big data field in the data processing field, in order to improve the applicability of offline task processing technology.
[0178] It should be noted that the head model in this embodiment is not a head model specific to any particular user and does not reflect the personal information of any particular user. It should also be noted that the two-dimensional face image in this embodiment comes from a publicly available dataset.
[0179] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0180] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0181] According to embodiments of this disclosure, this disclosure also provides a computer program product comprising: a computer program stored in a readable storage medium, at least one processor of an electronic device being able to read the computer program from the readable storage medium, and the at least one processor executing the computer program causing the electronic device to perform the scheme provided in any of the above embodiments.
[0182] Figure 10 A schematic block diagram of an example electronic device 1000 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0183] like Figure 10As shown, device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in read-only memory (ROM) 1002 or a computer program loaded from storage unit 1008 into random access memory (RAM) 1003. The RAM 1003 may also store various programs and data required for the operation of device 1000. The computing unit 1001, ROM 1002, and RAM 1003 are interconnected via bus 1004. Input / output (I / O) interface 1005 is also connected to bus 1004.
[0184] Multiple components in device 1000 are connected to I / O interface 1005, including: input unit 1006, such as keyboard, mouse, etc.; output unit 1007, such as various types of monitors, speakers, etc.; storage unit 1008, such as disk, optical disk, etc.; and communication unit 1009, such as network card, modem, wireless transceiver, etc. Communication unit 1009 allows device 1000 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0185] The computing unit 1001 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 performs the various methods and processes described above, such as task processing methods. For example, in some embodiments, the task processing method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on device 1000 via ROM 1002 and / or communication unit 1009. When the computer program is loaded into RAM 1003 and executed by the computing unit 1001, one or more steps of the task processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to perform task processing methods by any other suitable means (e.g., by means of firmware).
[0186] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0187] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0188] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0189] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0190] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0191] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or simply "VPS") services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0192] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0193] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A task processing method applied to a first device, the first device including a database, the database including a first queue, the method comprising: Receive a task processing request sent by the client, the task processing request including the object to be processed and the task processing parameters after JSON serialization; The serialized task processing parameters are deserialized to obtain the task processing parameters. Store the object to be processed and the task processing parameters in a preset storage space; Based on the object to be processed and the task processing parameters, a task identifier is generated and stored in the first queue; When the task identifier is at the head of the first queue, the object to be processed and the task processing parameters are obtained from the preset storage space according to the task identifier, and the object to be processed is processed according to the task processing parameters. Storing the object to be processed and the task processing parameters into a preset storage space includes: The task processing parameters are verified according to preset conditions. If the task processing parameters meet the preset conditions, the object to be processed and the task processing parameters are stored in a preset storage space.
2. The method according to claim 1, wherein, The task processing parameters include the task type, and storing the task identifier in the first queue includes: Generate a timestamp corresponding to when the task identifier is stored in the first queue; Set the task status corresponding to the task identifier to the first status; The task identifier and at least one of the following are associated and stored in the first queue: the timestamp, the task status, and the task type corresponding to the task identifier.
3. The method according to claim 2, wherein, The step of storing the task identifier and at least one of the following associated with the first queue includes: the timestamp, the task status, and the task type corresponding to the task identifier. The task identifier and at least one of the following are encapsulated into a task message: the timestamp, the task status, and the task type corresponding to the task identifier; Call the enqueue interface of the first queue to write the task message into the first queue.
4. The method according to any one of claims 1-3, wherein, If the task processing parameters include a task execution field, and the task type is information extraction, then the preset condition includes: the task execution field includes a field to be extracted. If the task type is information comparison, the preset conditions include: the number of objects to be processed is greater than or equal to 2.
5. The method according to claim 3, wherein the first device further comprises at least one task processing unit, wherein, Each of the aforementioned task processing units corresponds to a different task type; Before retrieving the object to be processed and the task processing parameters from the preset storage space based on the task identifier, the method further includes: The task type is obtained from the task message, and the first task processing unit corresponding to the task type is determined, wherein the task message is located at the head of the first queue; The first task processing unit calls the dequeue interface of the first queue to obtain the task message from the first queue; The first task processing unit stores the task message in a buffer queue within the first task processing unit and sets the task status in the task message to a second status.
6. The method according to claim 5, wherein, The step of retrieving the object to be processed and the task processing parameters from the preset storage space based on the task identifier includes: When the task message is at the head of the buffer queue, the first task processing unit retrieves the object to be processed and the task processing parameters from the preset storage space according to the task identifier.
7. The method according to claim 5 or 6, wherein, The step of processing the object to be processed according to the task processing parameters includes: The first task processing unit determines at least one processing node corresponding to the task type, wherein each processing node is connected in sequence and each processing node corresponds to a task processing step of the task type. The object to be processed is processed according to each of the sequentially connected processing nodes.
8. The method according to any one of claims 1-3 and 5-6, wherein after processing the object to be processed according to the task processing parameters, the method further comprises: Set the task status of the task identifier corresponding to the object to be processed to the third status, and send the processing result of the object to be processed to the client.
9. A task processing apparatus applied to a first device, the first device including a database, the database including a first queue, the apparatus comprising: The receiving module is used to receive task processing requests sent by the client. The task processing request includes an object to be processed and task processing parameters after JSON serialization. The serialized task processing parameters are deserialized to obtain the task processing parameters. The storage module is used to store the object to be processed and the task processing parameters into a preset storage space; The processing module is used to generate a task identifier based on the object to be processed and the task processing parameters, and store the task identifier in the first queue; The processing module is further configured to, when the task identifier is located at the head of the first queue, obtain the object to be processed and the task processing parameters from the preset storage space according to the task identifier, and process the object to be processed according to the task processing parameters; The processing module is also used for: Before storing the object to be processed and the task processing parameters into the preset storage space, the task processing parameters are verified according to preset conditions. If the task processing parameters meet the preset conditions, the object to be processed and the task processing parameters are stored into the preset storage space.
10. The apparatus according to claim 9, wherein, The task processing parameters include the task type, and the storage module is further used for: Generate a timestamp corresponding to when the task identifier is stored in the first queue; Set the task status corresponding to the task identifier to the first status; The task identifier and at least one of the following are associated and stored in the first queue: the timestamp, the task status, and the task type corresponding to the task identifier.
11. The apparatus according to claim 10, wherein, The storage module is also used for: The task identifier and at least one of the following are encapsulated into a task message: the timestamp, the task status, and the task type corresponding to the task identifier; Call the enqueue interface of the first queue to write the task message into the first queue.
12. The apparatus according to any one of claims 9-11, wherein, If the task processing parameters include a task execution field, and the task type is information extraction, then the preset condition includes: the task execution field includes a field to be extracted. If the task type is information comparison, the preset conditions include: the number of objects to be processed is greater than or equal to 2.
13. The apparatus of claim 11, wherein the first device further comprises at least one task processing unit, wherein, Each of the aforementioned task processing units corresponds to a different task type; The processing module is also used for: Before obtaining the object to be processed and the task processing parameters from the preset storage space according to the task identifier, the task type is obtained from the task message, and the first task processing unit corresponding to the task type is determined, wherein the task message is located at the head of the first queue; The first task processing unit calls the dequeue interface of the first queue to obtain the task message from the first queue; The first task processing unit stores the task message in a buffer queue within the first task processing unit and sets the task status in the task message to a second status.
14. The apparatus according to claim 13, wherein, The processing module is also used for: When the task message is at the head of the buffer queue, the first task processing unit retrieves the object to be processed and the task processing parameters from the preset storage space according to the task identifier.
15. The apparatus according to claim 13 or 14, wherein, The processing module is also used for: The first task processing unit determines at least one processing node corresponding to the task type, wherein each processing node is connected in sequence and each processing node corresponds to a task processing step of the task type. The object to be processed is processed according to each of the sequentially connected processing nodes.
16. The apparatus according to any one of claims 9-11, 13-14, wherein the processing module is further configured to: After processing the object to be processed according to the task processing parameters, the task status of the task identifier corresponding to the object to be processed is set to the third status, and the processing result of the object to be processed is sent to the client.
17. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
18. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-8.
19. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1-8.
Citation Information
Patent Citations
Information processing method and device
CN105574037A
Task processing method and related product
CN113220435A