Message distribution method and device, terminal equipment and storage medium

By determining the tasks to be executed at a certain interval in the task database and storing them into a preset queue, real-time message distribution is achieved using the task distribution thread, the database pressure and real-time problems are solved, and personalized timestamp configuration is supported, which improves task execution accuracy and scalability.

CN119088584APending Publication Date: 2024-12-06BEIJING JINGDONG QIANSHITECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310667041.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-06
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

In the prior art, frequent operation of task databases leads to high pressure, timing trigger intervals cannot be too short, message distribution is poor in real-time, cannot meet high real-time requirements, and is difficult to expand, resulting in task query timeout and inability to distribute, and cannot support a single Personalized execution timestamp configuration for tasks.

Method used

Every first preset time, it is determined from the task database that the difference between the execution timestamp and the current timestamp is less than or equal to the set time, and store it in the preset queue. Each queue has a corresponding task distribution thread. , based on these thread loops, obtain the target task with execution timestamps less than or equal to the current time for distribution.

Benefits of technology

It realizes the real-time and dynamic expansion capabilities of message distribution, can effectively deal with a large number of task message distribution, supports personalized configuration of execution timestamps of a single task, and improves the accuracy of task execution time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088584A_ABST
    Figure CN119088584A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a message distribution method and device, terminal equipment and a storage medium, and the method comprises the steps: determining each to-be-executed task from a task database every first preset time, wherein the difference between the execution timestamp of each to-be-executed task and the current timestamp of each to-be-executed task is smaller than or equal to the first preset time; each task to be executed is stored in each preset queue; wherein each preset queue is provided with a corresponding task distribution thread; based on each task distribution thread, circularly obtaining a target task with an execution timestamp smaller than or equal to a current timestamp in a corresponding preset queue; and distributing the task message corresponding to the target task. According to the method, the real-time performance of message distribution can be met, dynamic expansion can be achieved to deal with distribution of a large number of task messages, configuration of a single task execution timestamp can be supported, and task execution time precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a message distribution method, apparatus, terminal equipment and storage medium. Background Art

[0002] The warehouse management system (WMS) controls the equipment to execute tasks such as warehousing, sorting, and outbound delivery by distributing task messages to related equipment. In the prior art, the task database is often scanned and aggregated based on a timed trigger mechanism to match similar task messages for distribution.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following technical problems in the prior art:

[0004] Frequent operation of the task database will cause great database pressure, the interval of the scheduled trigger cannot be too short, and the real-time performance of message distribution is poor, which cannot meet the task operations with high real-time requirements. In scenarios where a large number of tasks are to be processed due to equipment abnormalities, network outages, massive orders, etc., due to limited database operation performance and difficulty in expansion, task query timeouts and a large number of task messages cannot be distributed, thus affecting task operations. In addition, due to the large number of tasks in the database, the existing scheduled trigger mechanism only supports scheduled configuration based on categories, which cannot meet the personalized execution timestamp configuration of a single task, and the execution time accuracy of a single task cannot be guaranteed. Summary of the invention

[0005] The embodiments of the present invention provide a message distribution method, apparatus, terminal device and storage medium, which can not only meet the real-time nature of message distribution, but also can be dynamically expanded to cope with the distribution of a large number of task messages, and can support the configuration of a single task execution timestamp to improve the accuracy of task execution time.

[0006] In a first aspect, an embodiment of the present invention provides a message distribution method, including:

[0007] At every first preset time, determine from the task database each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time;

[0008] Storing each of the tasks to be executed into each preset queue; wherein each of the preset queues has a corresponding task distribution thread;

[0009] Based on each of the task distribution threads, cyclically obtain target tasks in the corresponding preset queue with execution timestamps less than or equal to the current timestamp;

[0010] The task message corresponding to the target task is distributed.

[0011] In a second aspect, an embodiment of the present invention provides a message distribution device, including:

[0012] A to-be-executed task determination module, used to determine, from a task database, at every first preset time, each to-be-executed task whose difference between an execution timestamp and a current timestamp is less than or equal to the first preset time;

[0013] A to-be-executed task storage module, used to store the to-be-executed tasks into the preset queues; wherein each of the preset queues has a corresponding task distribution thread;

[0014] A target task acquisition module, used for cyclically acquiring target tasks with execution timestamps less than or equal to the current timestamp in the corresponding preset queue based on each of the task distribution threads;

[0015] The task message distribution module is used to distribute the task message corresponding to the target task.

[0016] In a third aspect, an embodiment of the present invention provides a terminal device, including:

[0017] one or more processors;

[0018] A memory for storing one or more programs;

[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the message distribution method as described in any embodiment of the present invention.

[0020] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the message distribution method as described in any embodiment of the present invention.

[0021] A message distribution method, apparatus, terminal device and storage medium provided by an embodiment of the present invention determine, from a task database at intervals of a first preset time, each task to be executed whose difference between an execution timestamp and a current timestamp is less than or equal to a first preset time; store each task to be executed in each preset queue; wherein each preset queue has a corresponding task distribution thread; based on each task distribution thread, cyclically obtain target tasks in the corresponding preset queue whose execution timestamp is less than or equal to the current timestamp; and distribute task messages corresponding to the target tasks.

[0022] By storing the pending tasks that need to be executed within the first preset time from the current moment in the task database into each preset queue, it is possible to implement the cyclic acquisition of target tasks that need to be executed immediately at short intervals based on the task distribution threads corresponding to each preset queue, thereby meeting the real-time nature of message distribution. Moreover, compared with traditional databases, preset queues and task distribution threads are easier to dynamically expand, which is conducive to coping with a large number of task message distributions. In addition, the method provided by the embodiment of the present invention can support the personalized setting of the execution timestamp of each task, thereby improving the execution time accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0024] Figure 1 A flow chart of a message distribution method provided by an embodiment of the present invention is shown;

[0025] Figure 2 A flow chart of a message distribution method provided by an embodiment of the present invention is shown;

[0026] Figure 3 A framework diagram showing a message distribution method provided by an embodiment of the present invention when applied to a warehouse management system;

[0027] Figure 4 A schematic diagram of the structure of a message distribution device provided by an embodiment of the present invention is shown;

[0028] Figure 5 A schematic diagram of the hardware structure of a terminal device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described through the implementation method with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In the following embodiments, optional features and examples are provided in each embodiment at the same time. The various features recorded in the embodiments can be combined to form multiple optional schemes, and each numbered embodiment should not be regarded as only one technical scheme. The acquisition, storage, use, processing, etc. of data in the technical scheme of this application comply with the relevant provisions of national laws and regulations.

[0030] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, storage and other aspects of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain the security of user personal information, network security and national security.

[0031] Figure 1 A flow chart of a message distribution method provided by an embodiment of the present invention is shown. The message distribution method provided by an embodiment of the present invention can be applied to the case of distributing task messages, for example, it is applicable to the case of a warehouse management system (WMS) distributing task messages to related devices. The method can be executed by a message distribution device, which is implemented in software and / or hardware and can be configured in a terminal device, for example, a terminal device deployed by a WMS system, a server corresponding to the WMS system, and other terminal devices.

[0032] like Figure 1 As shown, the message distribution method provided in the embodiment of the present invention may include the following steps:

[0033] S110 . At every first preset time, determine from a task database each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time.

[0034] The first preset time can be preset in combination with factors such as the number of task messages to be distributed within different time periods in a specific application scenario, the available resources of the terminal to which the message distribution device belongs, etc., so as to achieve a balance between the available resources and the number of distributed task messages. For example, in the scenario of a WMS system, the first preset time can be preset to 20 minutes, 30 minutes, or 1 hour, etc.

[0035] The task database may be an existing database that can store task-related information, such as a MySQL database. In addition, the task-related information stored in the task database may be dynamically updated according to the business scenario. For example, in the scenario of a WMS system, when items are shipped out of the warehouse, the relevant information of the sorting tasks for each item in the outbound order may be added to the task database.

[0036] The task-related information may include an execution timestamp, which may represent the time when the task is expected to be executed. The message distribution device may scan the task database at intervals of a first preset time. If the difference between the task execution timestamp and the current timestamp (i.e., the timestamp corresponding to the moment when the database is scanned) is less than or equal to the first preset time, the task may be considered to belong to the tasks that need to be executed within the next first preset time, and the task may be used as a task to be executed. Since the interval of the first preset time is usually not too short, performance pressure on the task database may be avoided.

[0037] S120, storing each to-be-executed task into each preset queue; wherein each preset queue has a corresponding task distribution thread.

[0038] The preset queue may be an existing queue that can at least store tasks and their execution timestamps, such as a Redis Zset queue, etc., which are not exhaustive. Exemplarily, the data structure in the Redis Zset queue may include value data (value) and score data (score) corresponding to each value. When Redis Zset is used as the preset queue, the value may be the main data of the task (which may be data in json string format), and the score may be the execution timestamp corresponding to the task. When the score is set to a certain timestamp in the future, it can lay the foundation for realizing the delayed distribution of messages corresponding to the task.

[0039] In the embodiment of the present invention, the number of queues of the preset queue can be adjusted dynamically, for example, the preset queue can be dynamically created and eliminated during the message distribution process. At the same time, the maintenance thread corresponding to the preset queue (which can be called the task distribution thread in the embodiment of the present invention) can also be dynamically created and eliminated. Among them, the maintenance thread can be used to implement maintenance operations such as adding, deleting, changing, and querying data in the preset queue.

[0040] After determining the tasks to be executed within the next first preset time, the message distribution device can call the add function of the task distribution thread to store the tasks to be executed and their execution timestamps in the preset queues. In addition, the delete function of the task distribution thread can also be called to delete the tasks that have been executed within the previous first preset time from the preset queues.

[0041] Among them, each task to be executed can be randomly stored in each preset queue; or each task to be executed can be stored in each preset queue according to the principle of task balance in the queue, so as to ensure the distribution efficiency of task messages and the full utilization of queue resources. In addition, other ways of randomly storing tasks to be executed in each preset queue can also be applied here, which are not exhaustive here.

[0042] S130 . Based on each task distribution thread, cyclically obtain target tasks in the corresponding preset queue whose execution timestamps are less than or equal to the current timestamp.

[0043] The message distribution device can call the query function of the task distribution thread to cyclically query the tasks to be executed in the corresponding preset queue at short intervals, where the interval time period can be set according to the specific application scenario. In addition, when the execution timestamp of the queried task to be executed is less than or equal to the current timestamp (that is, the timestamp corresponding to the time when the task to be executed is queried), the task to be executed can be used as the target task. Referring to the example above, when Redis Zset is used as the preset queue, the task distribution thread can use the zrangebyscore key start end statement to obtain the target task whose score is less than or equal to the current timestamp. The target task can be considered as a task that needs to be executed immediately when the task to be executed is queried.

[0044] Compared with the traditional scanning database, the message distribution method provided by the embodiment of the present invention can realize the query operation of each preset queue at a short interval by distributing the task thread corresponding to each preset queue to obtain the target task that needs to be executed immediately, thereby meeting the message distribution in the scenario with high real-time requirements. In addition, since the preset queue can store the execution timestamp corresponding to each task, it can support the personalized setting of the execution timestamp of each task, thereby improving the execution time accuracy.

[0045] In some optional implementations, each preset queue includes an ordered set; wherein each to-be-executed task in each preset queue is stored according to the time sequence of the corresponding execution timestamp.

[0046] In these optional implementations, when storing each to-be-executed task in each preset queue, each to-be-executed task in the preset queue can be sorted and stored in chronological order from the execution timestamp in order of first to last, so that a preset queue belonging to an ordered set can be obtained. Referring to the example above, when Redis Zset is used as a preset queue, it can be stored in order from small to large by score, so that an ordered set can be obtained. By making the preset queue an ordered set with a time sequence for the tasks to be executed inside it, the tasks to be executed can be obtained in order when the target task is acquired in a loop, without traversing all the tasks to be executed in the preset queue, which can save the acquisition time of the target task and improve the distribution efficiency of the task corresponding message to a certain extent.

[0047] S140: Distribute the task message corresponding to the target task.

[0048] After obtaining the target task that needs to be executed immediately, the message distribution device can generate a corresponding task message according to the task content, communication object, communication protocol and other information corresponding to the target task, and can distribute the task message to the corresponding communication object. For example, the message distribution device can randomly obtain an idle worker thread from a pre-created thread pool as a task execution thread, and can generate and distribute the task message corresponding to the target task based on the task execution thread.

[0049] In some optional implementations, the number of queues in each preset queue may be set according to the number of tasks in the task database.

[0050] In these optional implementations, the number of queues may have a positive correlation with the number of tasks, that is, to a certain extent, the more tasks there are, the larger the number of queues may be. The correlation may be, for example, that the number of tasks within a predetermined range corresponds to the predetermined number of queues, and if the minimum number of tasks between different predetermined ranges is larger, the corresponding predetermined number of queues is larger.

[0051] For example, when the WMS system notifies the automatic picking device to pick up the goods or notifies the automatic picking device to review the goods after picking, the corresponding number of queues can be set according to the number of tasks in the task database to store the picking / reviewing tasks, so as to achieve delayed distribution of notification messages corresponding to the tasks. In this way, when the automatic picking device is abnormal, the network is unavailable, or a large number of orders are issued in a short period of time during a big promotion, resulting in a large backlog of tasks in the task database, the number of queues can be dynamically increased to handle the distribution of messages corresponding to a large number of tasks.

[0052] Among these optional implementations, the preset queue and task distribution thread are easier to dynamically expand than traditional databases. Therefore, compared with the traditional method of constantly retrying the task database in abnormal situations, by dynamically adjusting the preset queue and the corresponding task distribution thread according to the number of tasks in the task database, not only can the pressure on the database be greatly reduced, but also a large number of task messages can be distributed, thereby ensuring warehouse operation efficiency.

[0053] In some optional embodiments, after distributing the task message corresponding to the target task, it also includes: updating the task execution status of the target task in the task database; accordingly, determining from the task database each task to be executed whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time, including: determining from the tasks in the task database whose task execution status is not executed, each task to be executed whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time.

[0054] In these optional implementations, the task database may store all tasks and their task execution status, and the task execution status may include but is not limited to unexecuted, executing, successfully executed, failed to execute, etc. After the task message is distributed, the task execution status of the corresponding task may be updated from the unexecuted state to other states (for example, updated to the executing, successfully executed, or failed to execute state). Therefore, when obtaining tasks to be executed, each task to be executed may be obtained from unexecuted tasks, which may speed up the acquisition of tasks to be executed to a certain extent, thereby improving the efficiency of message distribution.

[0055] In addition, for failed tasks, the execution timestamp, task execution status, etc. can be reset according to specific business needs. Compared with the traditional retry mechanism under abnormal circumstances, more flexible, reasonable, safe and reliable message distribution retry can be achieved.

[0056] A message distribution method provided by an embodiment of the present invention determines, from a task database at intervals of a first preset time, each task to be executed whose difference between an execution timestamp and a current timestamp is less than or equal to a first preset time; stores each task to be executed in each preset queue; wherein each preset queue has a corresponding task distribution thread; based on each task distribution thread, cyclically obtains a target task whose execution timestamp is less than or equal to the current timestamp in the corresponding preset queue; and distributes the task message corresponding to the target task.

[0057] By storing the pending tasks that need to be executed within the first preset time from the current moment in the task database into each preset queue, it is possible to implement the cyclic acquisition of target tasks that need to be executed immediately at short intervals based on the task distribution threads corresponding to each preset queue, thereby meeting the real-time nature of message distribution. Moreover, compared with traditional databases, preset queues and task distribution threads are easier to dynamically expand, which is conducive to coping with a large number of task message distributions. In addition, the method provided by the embodiment of the present invention can support the personalized setting of the execution timestamp of each task, thereby improving the execution time accuracy.

[0058] Based on the above embodiments, this embodiment describes in detail the steps of storing each task to be executed into a preset queue. In the disclosed embodiment, storing each task to be executed into each preset queue may include: storing each task to be executed into each preset queue according to the execution timestamp of each task to be executed; correspondingly, the method also includes: configuring the second preset time of the corresponding task distribution thread according to the execution timestamp of each task to be executed stored in each preset queue, so as to obtain the target task based on each task distribution thread at every corresponding second preset time cycle. By storing each task to be executed into a preset different queue based on the execution timestamp, it is convenient for the task distribution thread corresponding to each preset queue to set the time interval for cyclic acquisition, so that the task distribution thread can obtain all the tasks in the corresponding queue with the least number of cycles, saving resource consumption.

[0059] Figure 2 A flow chart of a message distribution method provided by an embodiment of the present invention is shown. Figure 2 , the message distribution method may include the following steps:

[0060] S210. At every first preset time, determine from a task database each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time.

[0061] S220 . According to the execution timestamp of each task to be executed, store each task to be executed into each preset queue; wherein each preset queue has a corresponding task distribution thread.

[0062] Among them, storing each to-be-executed task into each preset queue according to the execution timestamp of each to-be-executed task may include: storing the to-be-executed tasks with adjacent execution timestamps into different preset queues. Thus, a certain time interval can be provided between two adjacent to-be-executed tasks stored in the same preset queue, and the time period of the task distribution thread corresponding to the preset queue can be extended to a certain extent, which can reduce the number of task distribution thread cycles, save resources, and avoid the situation where the task corresponding message is not distributed in time.

[0063] S230: According to the execution timestamps of the tasks to be executed stored in the preset queues, configure the second preset time of the corresponding task distribution thread.

[0064] Among them, according to the execution timestamps of each task to be executed stored in each preset queue, the second preset time of the corresponding task distribution thread is configured, which may include: for each preset queue, the interval value between adjacent execution timestamps of each task to be executed stored can be determined; any common divisor (for example, the greatest common divisor) of each interval value can be used as the second preset time of the corresponding preset queue.

[0065] In some optional implementations, storing each task to be executed in each preset queue according to the execution timestamp of each task to be executed may include: taking the remainder of the execution timestamp of each task to be executed based on the queue number of each preset queue to obtain each remainder; and storing each task to be executed in the corresponding preset queue according to each remainder.

[0066] Among them, the correspondence between each remainder and each preset queue can be preset. Exemplarily, when the number of queues is n (n is a positive integer), the set of remainders can be {0, 1, ..., n-1}, the preset queues can be numbered as {queue 0, queue 1, ..., queue n-1}, and a one-to-one correspondence between each remainder in {0, 1, ..., n-1} and each queue number in {queue 0, queue 1, ..., queue n-1} can be set.

[0067] In these optional implementations, the execution timestamp of each task to be executed can be divided by the number of queues to obtain each remainder. According to the preset correspondence between the remainder and the queue number, each task to be executed can be stored in the corresponding preset queue. In this way, the second preset time of the task distribution thread corresponding to each preset queue can be set to the time interval value corresponding to the unit timestamp of the number of queues. Thus, each task distribution thread can obtain all the tasks to be executed in the corresponding queue with the least number of cycles, which can further save resources and ensure that no tasks to be executed are missed.

[0068] S240 . Based on each task distribution thread, obtain the target task whose execution timestamp is less than or equal to the current timestamp in the corresponding preset queue every corresponding second preset time cycle.

[0069] Each task distribution thread can cyclically obtain the target task in the corresponding preset queue according to the corresponding second preset time, thereby reducing the number of task distribution thread cycles and saving resources, and avoiding the situation where the task corresponding message is not distributed in time.

[0070] S250: Distribute the task message corresponding to the target task.

[0071] Based on the above-mentioned embodiment, the embodiment of the present invention describes in detail the step of storing each task to be executed into a preset queue. Each task to be executed can be stored into each preset queue according to the execution timestamp of each task to be executed; accordingly, the method also includes: configuring the second preset time of the corresponding task distribution thread according to the execution timestamp of each task to be executed stored in each preset queue, so as to obtain the target task based on each task distribution thread at every corresponding second preset time cycle. By storing each task to be executed into different preset queues based on the execution timestamp, it is convenient for the task distribution thread corresponding to each preset queue to set the time interval for cyclic acquisition, so that the task distribution thread can obtain all the tasks in the corresponding queue with the least number of cycles, saving resource consumption.

[0072] In addition, the message distribution method proposed in the embodiment of the present invention and the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0073] Based on the above embodiments, this embodiment describes in detail the application scenarios of the message distribution method. In the embodiment of the present invention, the message distribution method can be applied to a warehouse management system (WMS), which can meet the distribution requirements of high-real-time messages such as order cancellation messages and order interception messages; it can also dynamically expand performance to cope with the distribution of a large number of task messages in scenarios such as equipment abnormalities, network failures, and massive order issuance; and it can support the configuration of a single task execution timestamp, thereby improving the accuracy of task execution time. In summary, warehouse production efficiency, reliability, and accuracy can be guaranteed to a large extent.

[0074] For example, Figure 3 The following is a framework diagram showing a message distribution method provided by an embodiment of the present invention when applied to a warehouse management system. Figure 3 , when applied to warehouse management systems, message distribution methods may include:

[0075] First, the business function modules of the WMS system, such as outbound service, inbound service or picking / checking service, can generate various tasks and send them to the receiving module in the message distribution device ( Figure 3 The WMS system may include a configuration center, which can be used to configure the notification method (i.e., interaction protocol and protocol details), notification address, notification message, notification time (i.e., task execution timestamp), and failure retry rules of third-party devices (e.g., communication devices such as sorting devices). The notification method may include, but is not limited to, Hyper Text Transfer Protocol (HTTP) request, Message Queue (MQ) notification, and Java Server Faces message handle (JSF) protocol. Each business function module in the WMS system can generate relevant information of each task by querying the configuration center, and send each task and its relevant information to the acceptor.

[0076] Then, the acceptor can forward the task to the scheduling module in the message distribution device ( Figure 3 The dispatcher in the forwarding process does not need any logical processing.

[0077] Second, the dispatcher can save each task and its related messages to the task database ( Figure 3 MySQL database in the MySQL database); and tasks with execution timestamps less than or equal to the current timestamp (i.e., the timestamp of the task moment) can be sent as target tasks to the task execution thread for processing, so that the task execution thread distributes the task message corresponding to the target task to the third-party device (e.g. Figure 3Notify the third-party device in the form of http request, MQ notification or JSF protocol); store each to-be-executed task whose execution timestamp and current timestamp have a difference less than or equal to the first preset time in each preset queue (for example Figure 3 In addition, the dispatcher can also obtain each task to be executed from the MySQL database every first preset time (for example, 30 minutes), and store each task to be executed in each preset queue.

[0078] Again, the task distribution thread corresponding to each preset queue in the message distribution device can be in its internal cycle timer ( Figure 3 When the timer in the running state is in the running state, the zrangebyscore key start end statement is used to obtain the target task whose execution timestamp is less than or equal to the current timestamp in the corresponding preset queue. Among them, each timer can cycle through the sleep state and the running state to enable the task distribution thread to cycle to obtain the target task.

[0079] Finally, the message distribution device can distribute the task message corresponding to the target task based on the task execution thread (for example Figure 3 In addition, after the task message corresponding to the target task is distributed, the task execution status of the target task in the MySQL database can also be updated; accordingly, dispatch can determine the tasks to be executed at the next first preset time from the tasks in the MySQL database whose task execution status is not executed.

[0080] Among them, the task message includes at least one of the following: an order cancellation message and an order interception message. When the task message is an order cancellation message or an order interception message, the sorting equipment needs to be notified immediately to stop sorting. At this time, when the WMS system generates the tasks corresponding to these messages, it can set the timestamp to the timestamp of generating the task; accordingly, the dispatcher can determine that the execution timestamp of the tasks corresponding to these messages is less than or equal to the current timestamp (that is, the timestamp of the task moment), and can immediately hand it over to the task execution thread for message distribution. Thereby, the distribution requirements of high real-time messages can be guaranteed, and the repeated operation of returning items to the shelves after sorting due to untimely message distribution can be avoided, which can improve work efficiency.

[0081] In addition, when a large number of tasks are backlogged in the MySQL database due to abnormal third-party equipment, network failure, or short-term massive orders during a big promotion, the number of Zset queues can be dynamically increased to handle the distribution of messages corresponding to a large number of tasks. By dynamically adjusting the preset queues and corresponding task distribution threads according to the number of tasks in the task database, not only can the pressure on the database be greatly reduced, but also the distribution of a large number of task messages can be guaranteed, thereby ensuring warehouse operation efficiency.

[0082] In addition, for tasks that fail to execute, the execution timestamp, task execution status and other task execution information can be reset according to specific business needs. Compared with the traditional retry mechanism under abnormal conditions, more flexible, reasonable, safe and reliable message distribution retry can be achieved. For target tasks that fail to be obtained, the task distribution thread can re-pull the task based on the failure rules to ensure that the target task is obtained normally.

[0083] Based on the above embodiments, the embodiment of the present invention describes in detail the application scenarios of the message distribution method. The message distribution method can be applied to the WMS system, which can meet the distribution requirements of high-real-time messages such as order cancellation messages and order interception messages; it can also dynamically expand performance to cope with the distribution of a large number of task messages in scenarios such as equipment abnormalities, network failures, and massive order issuance; and it can support the configuration of a single task execution timestamp, thereby improving the accuracy of task execution time. In summary, the warehouse production efficiency, reliability, and accuracy can be guaranteed to a large extent.

[0084] In addition, the message distribution method proposed in the embodiment of the present invention and the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0085] Figure 4 The schematic diagram of the structure of a message distribution device provided by an embodiment of the present invention is shown. The embodiment of the present invention can be applied to the case of distributing messages, for example, it is applicable to the case of WMS distributing task messages to related devices. Through the message distribution device provided by the present invention, the message distribution method applied to the server provided by the above embodiment can be implemented.

[0086] like Figure 4 As shown, the message distribution device in the embodiment of the present invention may include:

[0087] The to-be-executed task determination module 410 is used to determine, from the task database at every first preset time, each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time;

[0088] The to-be-executed task storage module 420 is used to store each to-be-executed task into each preset queue; wherein each preset queue has a corresponding task distribution thread;

[0089] The target task acquisition module 430 is used to cyclically acquire the target tasks whose execution timestamps are less than or equal to the current timestamp in the corresponding preset queue based on each task distribution thread;

[0090] The task message distribution module 440 is used to distribute the task message corresponding to the target task.

[0091] In some optional implementations, the to-be-executed task storage module may be used to:

[0092] According to the execution timestamp of each task to be executed, each task to be executed is stored in each preset queue;

[0093] Correspondingly, the message distribution device may further include:

[0094] The second preset time configuration module is used to configure the second preset time of the corresponding task distribution thread according to the execution timestamp of each to-be-executed task stored in each preset queue, so that the target task acquisition module can acquire the target task based on each task distribution thread every corresponding second preset time cycle.

[0095] In some optional implementations, the to-be-executed task storage module may be used to:

[0096] Based on the queue quantity of each preset queue, the execution timestamp of each task to be executed is modulo to obtain each remainder;

[0097] According to each remainder, each task to be executed is stored in a corresponding preset queue.

[0098] In some optional implementations, each preset queue includes an ordered set; wherein each to-be-executed task in each preset queue is stored according to the time sequence of the corresponding execution timestamp.

[0099] In some optional implementations, the message distribution device may further include:

[0100] An execution status update module, used to update the task execution status of the target task in the task database after the task message corresponding to the target task is distributed;

[0101] Accordingly, the task to be executed determination module is used to:

[0102] From the tasks in the task database whose task execution status is unexecuted, each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time is determined.

[0103] In some optional implementations, the number of queues in each preset queue is set according to the number of tasks in the task database.

[0104] In some optional implementations, applied to a warehouse management system, the task message includes at least one of the following: an order cancellation message and an order interception message.

[0105] The message distribution device provided in the embodiment of the present invention belongs to the same inventive concept as the message distribution method applied to the server provided in the above embodiment. The technical details not fully described in the embodiment of the present invention can be referred to the above embodiment, and the embodiment of the present invention has the same beneficial effects as the above embodiment.

[0106] Figure 5 The hardware structure diagram of a terminal device provided by an embodiment of the present invention is shown. The terminal device in the embodiment of the present invention may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, servers, etc. Figure 5 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0107] like Figure 5 As shown, the terminal device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 to a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the terminal device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0108] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the terminal device 500 to communicate with other devices wirelessly or by wire to exchange data. Figure 5The terminal device 500 is shown as having various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0109] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the message distribution method provided in the embodiment of the present invention are executed.

[0110] The terminal provided in the embodiment of the present invention and the message distribution method provided in the above embodiment belong to the same inventive concept. The technical details not fully described in the embodiment of the present invention can be referred to the above embodiment, and the embodiment of the present invention has the same beneficial effects as the above embodiment.

[0111] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the message distribution method provided by the above embodiment is implemented.

[0112] It should be noted that the computer-readable storage medium in the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or a flash memory (FLASH), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In an embodiment of the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0113] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0114] The computer-readable storage medium may be included in the terminal device, or may exist independently without being installed in the terminal device.

[0115] The terminal device stores and carries one or more programs. When the one or more programs are executed by the terminal device, the terminal device:

[0116] At every first preset time, determine from the task database each task to be executed whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time; store each task to be executed in each preset queue; wherein each preset queue has a corresponding task distribution thread; based on each task distribution thread, cyclically obtain the target task whose execution timestamp is less than or equal to the current timestamp in the corresponding preset queue; and distribute the task message corresponding to the target task.

[0117] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0118] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the function pages marked in the square box can occur in a different order from the order marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0119] The units involved in the embodiments of the present invention may be implemented by software or hardware, wherein the name of a unit does not limit the unit itself in some cases.

[0120] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0121] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A message distribution method, characterized in that: include: At every first preset time, determine from the task database each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time; Storing each of the tasks to be executed into each preset queue; wherein each of the preset queues has a corresponding task distribution thread; Based on each of the task distribution threads, cyclically obtain target tasks in the corresponding preset queue with execution timestamps less than or equal to the current timestamp; The task message corresponding to the target task is distributed.

2. The method according to claim 1, characterized in that The step of storing the tasks to be executed into the preset queues includes: According to the execution timestamps of the tasks to be executed, the tasks to be executed are stored in the preset queues; Accordingly, the method further includes: According to the execution timestamps of the tasks to be executed stored in the preset queues, the second preset time of the corresponding task distribution thread is configured, so as to obtain the target task based on the corresponding second preset time cycle of each task distribution thread.

3. The method according to claim 2, characterized in that The step of storing each of the tasks to be executed into each preset queue according to the execution timestamp of each of the tasks to be executed comprises: Based on the queue quantity of each preset queue, taking the remainder of the execution timestamp of each task to be executed; According to the remainders, the tasks to be executed are stored in corresponding preset queues.

4. The method according to claim 1, characterized in that Each preset queue includes an ordered set; wherein each to-be-executed task in each preset queue is stored according to the time sequence of the corresponding execution timestamp.

5. The method according to claim 1, characterized in that After distributing the task message corresponding to the target task, the method further includes: Updating the task execution status of the target task in the task database; Correspondingly, determining from the task database each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time includes: From the tasks in the task database whose task execution status is "not executed", each to-be-executed task whose difference between the execution timestamp and the current timestamp is less than or equal to the first preset time is determined.

6. The method according to any one of claims 1 to 5, characterized in that: The number of queues of each preset queue is set according to the number of tasks in the task database.

7. The method according to any one of claims 1 to 5, characterized in that: Applied to a warehouse management system, the task message includes at least one of the following: an order cancellation message and an order interception message.

8. A message distribution device, characterized in that: include: A to-be-executed task determination module, used to determine, from a task database, at every first preset time, each to-be-executed task whose difference between an execution timestamp and a current timestamp is less than or equal to the first preset time; A to-be-executed task storage module, used to store the to-be-executed tasks into the preset queues; wherein each of the preset queues has a corresponding task distribution thread; A target task acquisition module, used for cyclically acquiring target tasks with execution timestamps less than or equal to the current timestamp in the corresponding preset queue based on each of the task distribution threads; The task message distribution module is used to distribute the task message corresponding to the target task.

9. A terminal device, characterized in that: The terminal comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the message distribution method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the message distribution method as described in any one of claims 1 to 7 is implemented.