Message scheduling method

By employing partitioned coding and custom orchestration strategies in the 5G message queue middleware, the problems of low resource utilization and insufficient orchestration control capabilities are solved, achieving efficient message queue management and flexible service orchestration.

CN119584062BActive Publication Date: 2026-06-02CHINA MOBILE INTERNET CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA MOBILE INTERNET CO LTD
Filing Date
2024-10-29
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing 5G message queue middleware has shortcomings in resource utilization, message priority control, and orchestration capabilities, resulting in underutilization of system resources and an inability to meet the refined needs of complex business scenarios.

Method used

By determining the namespace based on the partition code of the message channel, adopting a two-level distributed storage scheme, and combining custom orchestration strategies and distributed lock mechanisms, the namespace management and index maintenance of the message queue are realized, scheduling notification events are triggered, and business-defined orchestration strategies are supported.

Benefits of technology

It improves the overall utilization of system resources, supports business-defined orchestration strategies, realizes refined message queue services, and enhances the flexibility and efficiency of message sending.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119584062B_ABST
    Figure CN119584062B_ABST
Patent Text Reader

Abstract

The application discloses a message scheduling method, belongs to the field of 5G messages, and aims to improve the arrangement and control capability of services. The method comprises the following steps: determining the namespace of a message queue according to the partition encoding of a message channel; saving a message to the namespace; determining the key of the message queue according to a self-defined arrangement strategy, maintaining the index and ordered set of the message queue according to the key, and triggering a scheduling notification event.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of 5G messaging, specifically involving a message scheduling method. Background Technology

[0002] The 5G messaging system, which integrates chatbot applications from various industries, is required to achieve more precise control over message distribution based on business priority, timeliness, and multiple message channels. The chatbot application access module of the 5G messaging system is responsible for maximizing the use of limited message channel resources through reasonable orchestration, scheduling a large number of industry application messages to user terminals. This means that, under the limited quota of southbound message channels and the platform's resource allocation limit, it needs to be able to automatically schedule and control messages through flexible strategies, even when the number of chatbot accesses changes dynamically and messages are sent dynamically. Implementing 5G message sending functionality based on message queue middleware, limited by the technical characteristics of message queue middleware mentioned above, generally adopts a scheme of predefining a fixed number of queues according to priority, and then storing messages of different priorities in corresponding priority queues for distribution. This approach has the following problems:

[0003] The overall system resource utilization rate is as follows: Each queue exclusively occupies the message producer and consumer server resources. Due to the lack of resource sharing among servers, the overall utilization rate is not high. There are situations where some queues are very busy and some queues are very idle, but the idle resources cannot be used. As a result, the system resources are not fully utilized.

[0004] Application-level (chatbot-level) orchestration is not supported: Each queue is shared, but multiple chatbot applications send messages at the same time. The same queue stores messages from multiple chatbot applications. The completion time of each chatbot's business is unpredictable. It does not support message scheduling orchestration by chatbot application, which is not conducive to chatbot business control.

[0005] Low message channel utilization: The message sending service needs to meet both chatbot and message channel level traffic control. Since the chatbot to which the message is sent is not fixed, the actual throughput of the message channel fluctuates greatly and the utilization rate is low.

[0006] Inaccurate priority control: Based on the first-in-first-out (FIFO) characteristic of queues, when message retry mechanisms occur, messages may return to the tail of the queue and cannot be sent in order of request time, which may lead to message expiration and invalidation.

[0007] Fixed message priority: Since the overall message scheduling situation cannot be perceived, message priority needs to be pre-set and cannot be dynamically adjusted. Because the priority cannot be adjusted, it may be distributed to a busy queue, resulting in timeouts and other issues that affect the success rate of sending.

[0008] The above illustrates that message queue middleware technology has distinct characteristics and limited functionality, lacking the ability to fine-grained orchestration and control of business processes in complex scenarios. Summary of the Invention

[0009] This application provides a message scheduling method that can solve the problem of lacking the ability to finely orchestrate and control business processes.

[0010] In a first aspect, embodiments of this application provide a message scheduling method, which includes: determining the namespace of a message queue based on the partition code of a message channel; saving messages to the namespace; determining the key of the message queue based on a custom orchestration strategy; maintaining an index and ordered set of the message queue based on the key; and triggering a scheduling notification event.

[0011] Secondly, embodiments of this application provide a message scheduling device, which includes: a determining module, configured to determine the namespace of a message queue based on the partitioning code of a message channel; a saving module, configured to save messages to the namespace; and a running module, configured to determine the key of the message queue based on a custom orchestration strategy, maintain the index and ordered set of the message queue using the key as a condition, and trigger a scheduling notification event.

[0012] Thirdly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0013] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0014] Fifthly, embodiments of this application provide a computer program product, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the steps of the method described in the first aspect.

[0015] In this embodiment, the namespace of the message queue is determined according to the partition code of the message channel; the message is saved to the namespace; the key of the message queue is determined according to the custom orchestration strategy; the index and ordered set of the message queue are maintained with the key as a condition; a scheduling notification event is triggered; and the business logic customizes the orchestration strategy, thereby realizing a finely controlled message queue service. Attached Figure Description

[0016] Figure 1 This is a flowchart illustrating a message scheduling method provided in an embodiment of this application;

[0017] Figure 2 This is a schematic diagram of another message scheduling process provided in an embodiment of this application;

[0018] Figure 3 This is a schematic diagram of another message scheduling process provided in an embodiment of this application;

[0019] Figure 4 This is a schematic diagram of the structure of a message scheduling device provided in an embodiment of this application;

[0020] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0022] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0023] The message scheduling method provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0024] Figure 1 This application illustrates a message scheduling method according to an embodiment of the present application. This method can be executed by an electronic device. In other words, the method can be executed by software or hardware installed in the electronic device, and includes the following steps:

[0025] Step 102: Determine the namespace of the message queue based on the partition code of the message channel.

[0026] In one implementation, the message queue's data structure and small messages are stored in a first-level distributed in-memory database, while the message queue's large messages and data structure are stored in a second-level distributed key-value storage engine.

[0027] This application employs a two-tier distributed storage scheme. The first-tier distributed in-memory database stores the queue's data structure and small messages, while the second-tier distributed key-value storage engine stores large messages and data structures, balancing functionality, performance, and cost-effectiveness. The distributed in-memory database stores data in memory and uses snapshots and log appending for data persistence, resulting in very fast read / write performance and low latency. The distributed key-value storage engine persistently stores data on disk and uses distributed protocols to ensure strong consistency replication, meeting the needs of large-scale data storage and retrieval.

[0028] In this embodiment, different message channels define independent partition codes. The distributed in-memory database supports namespaces, using partition codes as namespaces to isolate queue data between message channels. The queue data structure consists of an ordered set, a queue index, and a message body. The system sets a small message threshold; messages smaller than this threshold are stored in the in-memory database, otherwise they are stored in the distributed storage server. The ordered set stores the message storage type and message ID, and is sorted by message enqueue time by default. Specific sorting conditions can be determined by the business-defined message channel orchestration strategy, and it is responsible for connecting all messages in the same queue. The queue index stores the queue's attributes and is mainly used for controlling and operating the queue. The message queue data structure is defined as follows:

[0029] Message queue sorted set:

[0030]

[0031] Message queue index:

[0032]

[0033] Message body:

[0034]

[0035] In-transmission queue: Use a sorted set to store the queue key for in-transmission data.

[0036]

[0037] Queue to be sent: Use a sorted set to store the queue key to be sent.

[0038]

[0039] Message caching in progress

[0040]

[0041] The message queue supports custom orchestration strategies. The message producer service implements the message queue producer functionality, providing message queue push functionality to business modules and triggering queue events. The message producer service first determines the queue's namespace through the message channel's partition encoding.

[0042] Step 104: Save the message to the namespace.

[0043] Specifically, after determining the namespace of the queue through the partitioning encoding of the message channel, the message can be saved to the namespace.

[0044] In one implementation, saving the message to the namespace includes saving the message to the message area of ​​the namespace.

[0045] Specifically, saving a message to a namespace means saving the message to the message area of ​​the namespace.

[0046] Step 106: Determine the key of the message queue according to the custom orchestration strategy, maintain the index and ordered set of the message queue with the key as a condition, and trigger the scheduling notification event.

[0047] In one implementation, determining the key of the message queue according to a custom orchestration strategy, and maintaining the index and ordered set of the message queue based on the key, includes: determining the key of the message queue according to a custom orchestration strategy; querying the index of the message queue from the index area of ​​the namespace based on the key; and maintaining the index and ordered set of the message queue based on the state of the index.

[0048] Specifically, the `mq_key` of the queue is determined based on the business-defined orchestration strategy. Using `mq_key` as a condition, the queue index is queried from the `index` section of that namespace. If the queue index does not exist, it is created (initially with a state of 0). The queue index's `status` stores the queue's state. The message producer service then processes the queue based on its state as follows:

[0049] When status equals 0, add the queue mq_key to the sorted set of "to-send queues", with the score being "priority + orchestration request time". Update the message queue index: program_req_time = current system time, status = 1; save "storage_type + message_id" to the sorted set. Send a scheduling notification event.

[0050] When status equals 1, the queue mq_key is placed into the sorted set of "queue to be sent", and the score is "priority + orchestration request time"; "storage_type + message_id" is saved to the sorted set.

[0051] When status equals 2, save "storage_type+message_id" to the sorted set.

[0052] The push fails when status equals 3.

[0053] The orchestration and scheduling service listens for scheduling events or triggers scheduling notification events at regular intervals. The system uses a distributed lock mechanism to ensure that at most one orchestration and scheduling job is running at any given time.

[0054] The message scheduling method provided in this application determines the namespace of the message queue based on the partitioning code of the message channel; saves messages to the namespace; determines the key of the message queue based on a custom orchestration strategy, and maintains the index and ordered set of the message queue using the key as a condition; runs scheduling notification events, enabling custom orchestration strategies for business logic, and realizing a refined and controllable message queue service. This solves the problem that message queue middleware, with its distinct technical features and limited functionality, lacks the ability to fine-grainedly orchestrate and control business processes in complex scenarios. It supports custom orchestration strategies, allowing businesses to determine which messages are prioritized and have higher resource usage rights based on their business characteristics. It also boasts good scalability: this message queue service adopts a storage-compute separation architecture with good scalability, and reserves parameters to support businesses in controlling the queue service through monitoring, testing, big data, AI, and other technologies or means to achieve more precise message sending control. Finally, it achieves high overall system resource utilization: each queue in the message queue middleware exclusively occupies the computing resources of the producer, server, and consumer. In this embodiment, all queues share the computing resources of producers, servers, and consumers, and are dynamically allocated according to the orchestration results, resulting in higher overall system resource utilization.

[0055] In one implementation, triggering the scheduling notification event includes: responding to the running scheduling notification event, calculating a new orchestration result based on the orchestration formula and the custom orchestration strategy; calculating the outgoing difference set and the incoming difference set based on the new orchestration result and the old orchestration result; and completing the outgoing and incoming scheduling through the task message notification queue dispatcher.

[0056] The orchestration and scheduling service is responsible for performing orchestration calculations and service scheduling according to the business-defined orchestration strategy, allocating message queue services and message channel resources to specified queues, and determining which queues need to wait.

[0057] The orchestration and scheduling service listens for scheduling events or triggers orchestration and scheduling jobs at regular intervals. The system uses a distributed lock mechanism to ensure that at most one orchestration and scheduling job is running at any given time.

[0058] Key programming parameters:

[0059] The system's maximum throughput capacity = the maximum number of message scheduler instances planned for deployment * the number of sending threads per instance * the baseline throughput capacity of a single thread. The system's real-time throughput capacity = the number of real-time message scheduler instances * the number of sending threads per instance * the baseline throughput capacity of a single thread. The number of message scheduler instances can be obtained from the registry center, and the baseline throughput capacity of a single thread can be obtained through testing.

[0060] The maximum throughput capacity of a channel is calculated as MIN(maximum throughput capacity supported by the message channel, maximum system throughput capacity). The pre-allocated throughput of a channel is the sum of the throughput pre-allocated to the channel queue. The pre-allocated throughput of the system is the sum of the pre-allocated throughput of all channels. In one implementation, the orchestration formula includes a first formula and a second formula. The first formula states that the pre-allocated throughput of a channel is less than or equal to the maximum throughput capacity of the channel. The second formula states that the pre-allocated throughput of the system is less than or equal to the maximum real-time throughput capacity of the system. That is, the first formula states that the pre-allocated throughput of a channel is less than or equal to the maximum throughput capacity of the channel. The second formula states that the pre-allocated throughput of the system is less than or equal to the maximum real-time throughput capacity of the system.

[0061] In one implementation, calculating the new orchestration result based on the orchestration formula and the custom orchestration strategy includes: calculating the new candidate sending set and the pre-allocated throughput of the message queues according to the first formula, the maximum throughput capacity of the message channel, and the custom orchestration strategy; if the second formula is determined to be true based on the system's real-time maximum throughput and the pre-allocated throughput, determining the candidate sending set as the new sending queue set of the orchestration result; if the second formula is determined to be false based on the system's real-time maximum throughput and the pre-allocated throughput, recalculating the pre-allocated throughput of each message channel according to a preset calculation process.

[0062] Specifically, first obtain the configuration parameters for each message channel:

[0063]

[0064] Following the first formula, based on the maximum throughput capacity of each channel, the new candidate sending and waiting queue sets, as well as the pre-allocated throughput of each queue in the candidate sending are calculated according to the service-customized orchestration strategy of each channel. Then, according to the orchestration parameter calculation formula, the "system real-time maximum throughput capacity" is calculated, and the "channel pre-allocated throughput" and "system pre-allocated total throughput" are calculated based on the pre-orchestration results.

[0065] If the second formula holds true, the candidate sending queue set is determined as the new sending queue set, and the arrangement ends; otherwise, the pre-allocated throughput of each message channel is recalculated according to the preset accounting process.

[0066] In one implementation, the step of recalculating the pre-allocated throughput of each message channel according to a preset accounting process includes: calculating the corrected total pre-allocated throughput based on the pre-allocated excess throughput, system concurrency ratio, total system concurrency ratio of excess channels, surplus throughput of unfulfilled channels, and pre-allocated throughput; and calculating the new orchestration result based on the corrected total pre-allocated throughput.

[0067] Specifically, first calculate the system's pre-allocated excess throughput: System real-time maximum throughput = number of message scheduler instances * number of sending threads per instance * single-thread baseline throughput; System pre-allocated total throughput = sum of pre-allocated throughput for each channel; System pre-allocated excess throughput = System pre-allocated total throughput - System real-time maximum throughput.

[0068]

[0069] Calculate the pre-allocated excess throughput for each channel: Pre-allocated excess throughput = Pre-allocated total throughput - System real-time maximum throughput * System concurrency ratio.

[0070]

[0071] Calculate the excess throughput of the non-overloaded channels and the total concurrent ratio of the overloaded channels.

[0072]

[0073] Calculate the approved pre-allocated total throughput for each channel:

[0074] For excess channels: Pre-allocated throughput reduction = Pre-allocated excess throughput - System concurrency ratio / Total system concurrency ratio of excess channels * Surplus throughput of unfulfilled channels;

[0075] For channels that are not over-allocated: the pre-allocated throughput reduction is 0.

[0076] Corrected total pre-allocated throughput = pre-allocated throughput - pre-allocated throughput reduction.

[0077]

[0078] Following the first formula, based on the corrected pre-allocated total throughput, a new set of candidate sending queues is calculated according to the orchestration strategy of each message channel.

[0079] The scheduling process provided in this application includes the following steps:

[0080] If the real-time scheduling notification is "outgoing complete", the corresponding mq_key is deleted from the "outgoing difference set", and then the thread competes for orchestration scheduling permission. Once the orchestration scheduling permission is obtained, the current thread executes the orchestration scheduling job and proceeds to step b. At specified intervals (configurable parameters), an orchestration scheduling reset operation is performed, saving all queues in the "sending queue" set to the "pending sending queue" set. Then, the "sending queue" set is cleared, and the "orchestration scheduling reset time", "outgoing difference set", and "outgoing time" are cached, ending the current scheduling operation. If the cached "outgoing difference set" is not empty, and the "outgoing time" has not expired, the current scheduling operation ends; if the "outgoing time" has expired, the cached "outgoing difference set" and "outgoing time" are cleared, and the thread proceeds to step d to execute the incoming operation. If the cached "inbound difference" is not empty, update the throughput field of the new sending queue index in the cached cache to the newly orchestrated flow control value, save the new sending queue in the "Sending Queue" set, and delete it from the "Pending Sending Queue" set. Update the dispatching field of the queue index of the inbound difference to false, send the task message, and end the current scheduling. If there are no cached "outbound difference" or "inbound difference", perform orchestration processing, calculate the new sending and pending sending queue sets and the flow control value of the sending queue, calculate the difference between the old sending queue and the new sending queue (i.e., the outbound difference), and calculate the difference between the new sending queue set and the old sending queue set (i.e., the inbound difference). If the outbound difference is not empty, cache information such as "outbound time", "outbound difference", "inbound difference", "new sending queue and flow control value", save the mq_key of the outbound set to the "Pending Sending Queue" set, then delete it from the "Sending Queue" set, and end the current scheduling. If the outgoing difference set is empty and the incoming difference set is not empty, update the throughput field of the queue index of the newly sending queue to the newly orchestrated flow control value, save the newly sending queue in the "Sending Queues" set and delete it from the "Pending Queues" set, update the dispatching field of the queue index of the incoming difference set to false, send the task message, and end the current scheduling. If both the outgoing and incoming difference sets are empty, update the throughput field of the queue index of the newly sending queue to the newly orchestrated flow control value, and end the current scheduling. Periodically check queues whose old sending queue indexes have a dispatching status of false and compensate them with task messages.

[0081] In one implementation, after the task message notification queue dispatcher completes the outgoing and incoming scheduling, the method further includes: distributing messages from the message queue to the asynchronous message sender at a specified rate based on the token bucket flow control service.

[0082] The queue dispatcher listens for task messages, and the dispatcher is dynamically bound to a queue on a one-to-one basis. The queue dispatcher is responsible for distributing queue messages to the asynchronous message sender at a specified rate.

[0083] The orchestration and scheduling service publishes task messages, which include queue identifier mq_id (format: partition code.mq_key).

[0084] After receiving a task message, the queue dispatcher competes for the dispatching permission for that queue through the distributed lock service. Only one queue dispatcher can acquire the dispatching permission for each queue. If the queue dispatcher successfully competes for the dispatching permission for that queue, it updates the queue index `dispatching` to `true`, and the queue dispatcher is successfully bound to that queue.

[0085] If the queue dispatcher exits abnormally, it returns a Nack or reject status to the task event notification queue. This message is automatically pushed by the MQ server to the program exception dead-letter queue, which then resumes the interrupted dispatch task.

[0086] The queue distribution process provided in this application includes the following steps:

[0087] First, check if the queue is in the "Pending Send Queue" set. If so, update the queue index status to 1, send a "Recall Confirmation" notification, and release the queue distribution permission. If not in the "Pending Send Queue" set, query the queue index, calculate the queue distribution batch size, and obtain at most X (batch size) send tokens. If obtaining a send token fails, sleep (duration is configured parameter) and continue to step a. If obtaining a send token succeeds, pull up to the number of messages corresponding to the number of send tokens from the queue and save the pulled messages to the buffer. Distribute the pulled messages to the sender. If all messages are successfully distributed, clear the buffer and continue to step a. If the sender returns a 509 response code, retry distributing to other sender instances. If partially successful, retry distributing the undistributed portion to other sender instances until the remaining retries are 0, and call the retry service to set a retry timer for the failed messages, clear the buffer, sleep (duration is configured parameter), output an insufficient concurrency alarm log, and continue to step a. If all distributions fail, the retry service is invoked to set a retry timer for the failed messages, the message goes to sleep (duration is configured), an insufficient concurrency alarm log is output, and step a continues. The message retry timer is responsible for pushing the message back into the queue after the specified time has elapsed. If the message pulled is empty, the queue is removed from the sending queue set, the queue index status is updated to 0, a "distribution complete" notification is sent, and the distribution permission is released. In one implementation, after the message queue is distributed to the asynchronous message sender at a specified rate based on the token bucket flow control service, the method further includes: allocating the received message scheduling task to an idle message scheduling thread based on the asynchronous sender; and sending the message through the sending thread.

[0088] like Figure 2 As shown, the asynchronous message sender receives batch message scheduling tasks from the queue dispatcher and immediately assigns them to idle message sending threads, which then call the business module to send messages through the message channel.

[0089] 1. The batch message scheduling interface of the asynchronous message sender receives message scheduling tasks distributed by the queue dispatcher. The message scheduling task contains message path information (format: partition code.mq_key.mq_type.storage_type+message_id).

[0090] 2. The interface service first selects up to X (number of tasks) threads from the set of idle sending threads. If the number of sending threads is zero, it returns a response status code 509 and the dispatcher reroutes the task to another instance. Otherwise, it proceeds to step 3.

[0091] 3. Traverse the task list and perform idempotency checks on each message. If the check fails, discard the message. For messages that pass the idempotency check, cache their message path, set a message scheduling timeout timer through the timeout service, and accept the sending tasks based on the number of sending thread tokens obtained.

[0092] 4. Accepted message sending tasks are handed over to the sending thread for processing, while unaccepted tasks are returned to the queue dispatcher through the interface and rerouted to other instances by the dispatcher.

[0093] 5. The message sending line analyzes the message path information of the task message to obtain storage_type and message_id. When storage_type==1, the message body is retrieved from the in-memory database using message_id as the key. When storage_type==2, the message body is retrieved from the distributed storage engine using message_id as the key.

[0094] 6. Save idempotency verification data, call the message sending business module of the corresponding message channel to send the message, and the business module returns the sending result after the sending is completed, as well as whether to retry and the retry parameters if the sending fails. If the sending fails and can be retried, delete the idempotency verification data.

[0095] 7. Call the timeout service to delete the message scheduling timeout timer. If sending fails and is retried, call the retry service to set a retry timer for the message. If sending succeeds or fails and is not retried, delete the message index and delete the cached message path.

[0096] 8. If a sending timeout occurs, the message retry timer is responsible for calling the retry service to set a retry timer for the message after the sending timeout.

[0097] 9. The message sending thread completes its sending task and re-enters the idle thread set.

[0098] Figure 3 This document illustrates a flowchart of another message scheduling method provided in an embodiment of this application, as shown below. Figure 3As shown, the message queue service adopts a storage-compute separation architecture, separating the two key components of storage and computation. The system uses a two-level distributed storage service. The computation module mainly consists of key modules such as message producers, orchestration and scheduling, queue dispatchers, and message senders, as well as general modules such as token bucket flow control, distributed locks, microservice registry, idempotency verification, sending timeout timers, and failure retry timers. The key steps of this application embodiment are: 1. The queue storage service uses a two-level distributed storage scheme. The first-level distributed in-memory database stores the queue's data structure and small messages, and the second-level distributed key-value storage engine stores large messages; 2. The queue supports business-defined orchestration strategies. The message producer service first determines the queue's namespace through the partition encoding of the message channel. The queue's data is stored in this namespace, and then the messages are stored in the message area of ​​this namespace. Then, the queue's mq_key is determined according to the business-defined orchestration strategy. The queue's index and ordered set are maintained based on the mq_key, and a scheduling notification event is triggered; 3. The orchestration and scheduling service listens for scheduling events or triggers orchestration and scheduling jobs periodically, based on orchestration... The formulas "channel pre-allocated throughput <= channel maximum throughput capacity" and "system pre-allocated throughput <= system real-time maximum throughput capacity" are used to calculate new orchestration results through steps such as calculation, verification, correction, and confirmation based on the business-defined orchestration strategy. The outgoing and incoming difference sets are calculated based on the old and new orchestration results, and the queue dispatcher is notified via task messages to complete the outgoing and incoming scheduling. 4. The queue dispatcher listens for task messages. The dispatcher is dynamically bound one-to-one with the queue, and is responsible for distributing queue messages to the asynchronous message sender at a specified rate. 5. The asynchronous message sender receives batch message sending tasks from the queue dispatcher and immediately assigns them to idle message sending threads. These threads then call the business module to send messages through the message channel.

[0099] The message scheduling method provided in this application supports custom orchestration for specific business applications: message queue middleware has a single function and a fixed mode, and does not support custom orchestration for specific business applications. This application supports custom orchestration strategies for specific business applications, allowing the business to determine which messages are sent first and have higher resource usage rights based on its business characteristics.

[0100] Supports hundreds of millions of queues: The more queues a message queue middleware has, the more its performance degrades. In practical project experience, mainstream message queue middleware generally supports no more than a thousand queues or topics; otherwise, performance drops sharply. This application's embodiment implements a high-concurrency message queue service based on distributed storage, decoupling the message sending service from the message queue middleware. Its performance and scalability are not limited by the message queue middleware, and the number of supported queues is the same as the number of keys supported by the distributed storage, typically reaching the billion level.

[0101] Good scalability: This message queue service adopts a storage-compute separation architecture with good scalability. It reserves parameters to support businesses in controlling the queue service through monitoring, testing, big data, AI and other technologies or means to achieve more precise message sending control.

[0102] The overall system resource utilization is high: In message queue middleware, each queue has its own dedicated computing resources for the producer, server, and consumer. In contrast, this proposal allows all queues to share the computing resources for the producer, server, and consumer, and allocates them dynamically based on the orchestration results, resulting in a higher overall system resource utilization.

[0103] It should be noted that the message scheduling method provided in this application embodiment can be executed by a message scheduling device or a control module within that message scheduling device for executing the message scheduling method. This application embodiment uses the execution of the message scheduling method by a message scheduling device as an example to illustrate the message scheduling device provided in this application embodiment.

[0104] Figure 4 This is a schematic diagram of the structure of a message scheduling device according to an embodiment of this application. Figure 4 As shown, the message scheduling device 400 includes: a determination module 410, a storage module 420, and a running module 430.

[0105] The determination module 410 is used to determine the namespace of the message queue based on the partition code of the message channel; the saving module 420 is used to save the message to the namespace; the running module 430 is used to determine the key of the message queue based on the custom orchestration strategy, maintain the index and ordered set of the message queue based on the key, and trigger the scheduling notification event.

[0106] In one implementation, the storage module 420 is used to save the message to the message area of ​​the namespace.

[0107] In one implementation, the running module 430 is configured to determine the key of the message queue according to a custom orchestration strategy; query the index of the message queue from the index area of ​​the namespace based on the key; and maintain the index and ordered set of the message queue according to the state of the index.

[0108] In one implementation, the running module 430 is configured to respond to the running scheduling notification event, calculate a new orchestration result based on the orchestration formula and the custom orchestration strategy; calculate the outgoing difference set and the incoming difference set based on the new orchestration result and the old orchestration result; and complete the outgoing and incoming scheduling through the task message notification queue dispatcher.

[0109] In one implementation, the orchestration formula includes a first formula and a second formula, wherein the first formula is: the channel pre-allocated throughput is less than or equal to the channel maximum throughput capacity, and the second formula is: the system pre-allocated throughput is less than or equal to the system real-time maximum throughput capacity.

[0110] In one implementation, the running module 430 is configured to calculate the pre-allocated throughput of the new candidate sending set and message queues based on the first formula, the maximum throughput capacity of the message channel, and a custom orchestration strategy; if the second formula is found to be true based on the system's real-time maximum throughput and the pre-allocated throughput, the candidate sending set is determined to be the sending queue set of the orchestration result; if the second formula is found to be false based on the system's real-time maximum throughput and the pre-allocated throughput, the pre-allocated throughput of each message channel is recalculated according to a preset calculation process.

[0111] In one implementation, the running module 430 is used to calculate the corrected total pre-allocated throughput based on the pre-allocated excess throughput, system concurrency ratio, total system concurrency ratio of excess channels, surplus throughput of unfulfilled channels, and pre-allocated throughput; and to calculate the new orchestration result based on the corrected total pre-allocated throughput.

[0112] In one implementation, the running module 430 is further configured to distribute messages from the message queue to the asynchronous message sender at a specified rate based on the token bucket flow control service.

[0113] In one implementation, the running module 430 is further configured to allocate the received message scheduling task to an idle message scheduling thread based on the asynchronous sender; and send the message through the sending thread.

[0114] In one implementation, a first-level distributed in-memory database stores the data structure of the message queue and small messages, while a second-level distributed key-value storage engine stores large messages and the data structure of the message queue.

[0115] The message scheduling device in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.

[0116] The message scheduling device in this application embodiment can be a device with an operating system. The operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system.

[0117] The message scheduling device provided in this application embodiment can achieve... Figures 1 to 3 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.

[0118] like Figure 5 As shown in the illustration, this application embodiment also provides an electronic device 500, including a processor 501 and a memory 502. The memory 502 stores a program or instructions that can run on the processor 501. When the program or instructions are executed by the processor 501, they perform the following: determining the namespace of the message queue according to the partition code of the message channel; saving the message to the namespace; determining the key of the message queue according to a custom orchestration strategy; maintaining the index and ordered set of the message queue with the key as a condition; and triggering a scheduling notification event.

[0119] In one implementation, the message is saved to the message area of ​​the namespace.

[0120] In one implementation, the key of the message queue is determined according to a custom orchestration strategy; the index of the message queue is queried from the index area of ​​the namespace based on the key; and the index and ordered set of the message queue are maintained according to the state of the index.

[0121] In one implementation, in response to the runtime scheduling notification event, a new orchestration result is calculated based on the orchestration formula and the custom orchestration strategy; the outgoing difference set and the incoming difference set are calculated based on the new orchestration result and the old orchestration result; and the outgoing and incoming scheduling is completed through the task message notification queue dispatcher.

[0122] In one implementation, the orchestration formula includes a first formula and a second formula, wherein the first formula is: the channel pre-allocated throughput is less than or equal to the channel maximum throughput capacity, and the second formula is: the system pre-allocated throughput is less than or equal to the system real-time maximum throughput capacity.

[0123] In one implementation, based on the first formula, the maximum throughput of the message channel, and a custom orchestration strategy, a new set of candidate sending queues and the pre-allocated throughput of the message queues are calculated. If the second formula is found to be true based on the system's real-time maximum throughput and the pre-allocated throughput, the set of candidate sending queues is determined to be the set of the new sending queues in the orchestration result. If the second formula is found to be false based on the system's real-time maximum throughput and the pre-allocated throughput, the pre-allocated throughput of each message channel is recalculated according to a preset calculation process.

[0124] In one implementation, the corrected total pre-allocated throughput is calculated based on the pre-allocated excess throughput, the system concurrency ratio, the total system concurrency ratio of excess channels, the surplus throughput of unfulfilled channels, and the pre-allocated throughput; the new orchestration result is then calculated based on the corrected total pre-allocated throughput.

[0125] In one implementation, after the task message notification queue dispatcher completes the outgoing and incoming scheduling, the message queue is distributed to the asynchronous message sender at a specified rate based on the token bucket flow control service.

[0126] In one implementation, after the token bucket-based flow control service distributes messages from the message queue to the asynchronous message sender at a specified rate, the asynchronous sender assigns the received message scheduling task to an idle message scheduling thread; and the message is sent through the sending thread.

[0127] In one implementation, a first-level distributed in-memory database stores the data structure of the message queue and small messages, while a second-level distributed key-value storage engine stores large messages and the data structure of the message queue.

[0128] The specific execution steps can be found in the various steps of the above message scheduling method embodiment, and can achieve the same technical effect. To avoid repetition, they will not be repeated here.

[0129] It should be noted that the electronic devices in the embodiments of this application include: servers, terminals, or other devices besides terminals.

[0130] The above electronic device structure does not constitute a limitation on the electronic device. An electronic device may include more or fewer components than illustrated, or combine certain components, or arrange them differently. For example, an input unit may include a Graphics Processing Unit (GPU) and a microphone, and a display unit may use a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar display panels. User input units include at least one of a touch panel and other input devices. A touch panel is also called a touchscreen. Other input devices may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be elaborated further here.

[0131] Memory can be used to store software programs and various data. Memory can primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area can store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, memory can include volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (Synchlink DRAM, SLDRAM), and direct memory bus RAM (DRRAM).

[0132] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly handles operations related to the operating system, user interface, and applications, while the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into the processor.

[0133] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described message scheduling method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0134] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as ROM, RAM, magnetic disk, or optical disk.

[0135] This application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer performs various processes of the above-described message scheduling method embodiments and achieves the same technical effect. To avoid repetition, these will not be described again here.

[0136] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0137] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0138] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A message scheduling method, characterized by, include: The namespace of the message queue is determined based on the partition code of the message channel; Save the message to the aforementioned namespace; The key of the message queue is determined according to the custom orchestration strategy, and the index and ordered set of the message queue are maintained based on the key, triggering the scheduling notification event; The step of determining the key of the message queue according to a custom orchestration strategy and maintaining the index and ordered set of the message queue based on the key includes: determining the key of the message queue according to a custom orchestration strategy; querying the index of the message queue from the index area of ​​the namespace based on the key; and maintaining the index and ordered set of the message queue based on the state of the index. The triggered scheduling notification event includes: responding to the triggered scheduling notification event, calculating the new candidate sending set and the pre-allocated throughput of the message queues according to the first formula, the maximum throughput capacity of the message channel, and the custom orchestration strategy; if the second formula is true based on the system's real-time maximum throughput and the pre-allocated throughput, determining the candidate sending set as the new sending queue set of the new orchestration result; if the second formula is false based on the system's real-time maximum throughput and the pre-allocated throughput, recalculating the pre-allocated throughput of each message channel according to a preset calculation process; the first formula is: the channel's pre-allocated throughput is less than or equal to the channel's maximum throughput capacity, and the second formula is: the system's pre-allocated throughput is less than or equal to the system's real-time maximum throughput capacity; calculating the outgoing difference set and the incoming difference set based on the new orchestration result and the old orchestration result; and completing the outgoing and incoming scheduling through the task message notification queue distributor. The step of recalculating the pre-allocated throughput of each message channel according to the preset accounting process includes: The corrected total pre-allocated throughput is calculated based on the pre-allocated excess throughput, system concurrency ratio, total system concurrency ratio of excess channels, surplus throughput of unfulfilled channels, and pre-allocated throughput. The new orchestration result is calculated based on the revised pre-allocated total throughput.

2. The method according to claim 1, characterized in that, Saving the message to the namespace includes: Save the message to the message area of ​​the namespace.

3. The method according to claim 1, characterized in that, After the task message notification queue dispatcher completes the outgoing and incoming scheduling, the process also includes: The token bucket flow control service distributes messages from the message queue to the asynchronous message sender at a specified rate.

4. The method according to claim 3, characterized in that, After the token bucket flow control service distributes messages from the message queue to the asynchronous message sender at a specified rate, the following is also included: The received message scheduling task is assigned to an idle message sending thread based on the asynchronous sender; Messages are sent through the message sending thread.

5. The method according to claim 1, characterized in that, The message queue's data structure and small messages are stored in a first-level distributed in-memory database, while the message queue's large messages and data structure are stored in a second-level distributed key-value storage engine.

6. A message scheduling device, characterized in that, include: The determination module is used to determine the namespace of the message queue based on the partition code of the message channel; A save module is used to save messages to the namespace; The execution module is used to determine the key of the message queue according to the custom orchestration strategy, maintain the index and ordered set of the message queue with the key as a condition, and trigger the scheduling notification event; The running module is configured to determine the key of the message queue according to a custom orchestration strategy; query the index of the message queue from the index area of ​​the namespace based on the key; maintain the index and ordered set of the message queue according to the state of the index; and, in response to the triggered scheduling notification event, calculate the new candidate sending set and the pre-allocated throughput of the message queue according to the first formula, the maximum throughput capacity of the message channel and the custom orchestration strategy. If the second formula is found to be true based on the system's real-time maximum throughput and the pre-allocated throughput, the candidate sending set is determined to be the new sending queue set of the new orchestration result; If the second formula is determined to be invalid based on the system's real-time maximum throughput and the pre-allocated throughput, the pre-allocated throughput of each message channel is recalculated according to the preset accounting process. The first formula is: the channel pre-allocated throughput is less than or equal to the channel maximum throughput capacity; the second formula is: the system pre-allocated throughput is less than or equal to the system real-time maximum throughput capacity. Based on the new and old arrangement results, the outgoing difference set and the incoming difference set are calculated. The task message notification queue dispatcher completes the outgoing and incoming scheduling; The operation module is used to calculate the corrected total pre-allocated throughput based on the pre-allocated excess throughput, system concurrency ratio, total system concurrency ratio of excess channels, surplus throughput of unfulfilled channels, and pre-allocated throughput. The new orchestration result is calculated based on the revised pre-allocated total throughput.

7. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the message scheduling method as described in any one of claims 1-5.

8. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the message scheduling method as described in any one of claims 1-5.

9. A computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to perform the steps of the message scheduling method as described in any one of claims 1-5.