Message processing method, cloud platform, computing device, computer readable storage medium and computer program product

Through the multi-level time dimension storage file structure and sequential reading mechanism, the problems of limited storage time range and low reading efficiency of scheduled messages are solved, and efficient scheduled message delivery and storage are achieved.

CN120704906APending Publication Date: 2025-09-26HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410352079.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-25
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

The storage method of scheduled messages in the existing technology leads to a limited storage time range, serious write amplification problem, and low message reading efficiency, which easily causes scheduled message delivery delays and page cache pollution.

Method used

A multi-level time dimension storage file structure is adopted to search and write the corresponding storage file according to the current delay time of the scheduled message, and the message is delivered in descending order according to the hierarchy of the time dimension, realizing hierarchical nested storage and sequential reading of scheduled messages.

Benefits of technology

The storage time range of scheduled messages has been expanded, the message delivery efficiency has been improved, page cache pollution caused by random reading has been avoided, and the timely delivery of scheduled messages has been ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120704906A_ABST
    Figure CN120704906A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a message processing method, a cloud platform, computing equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: acquiring a first timing message; according to the current delay time of the first timing message, a first storage file corresponding to the first time dimension to which the current delay time belongs is searched, the current delay time refers to the delay processing time of the first timing message relative to the current time point, and the time dimension of each level is correspondingly provided with a plurality of mutually independent storage files; and writing the first timing message into the first storage file. According to the method, the first storage file is searched according to the level of the time dimension from low to high through the current delay time of the first timing message, so that the timing message can be stored according to the time dimension, and the time range of timing message storage is expanded; by writing the first timing message into the first storage file, sequential reading of the timing message can be realized based on the storage file, and the timing message delivery efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of computer technology, and in particular to a message processing method, a cloud platform, a computing device, a computer-readable storage medium, and a computer program product. Background Art

[0002] The current internet environment has a significant demand for scheduled messaging applications. Scheduled messaging involves the server delivering a scheduled message to a consumer at a fixed time based on the message's scheduled time. Due to the nature of scheduled message delivery, the content of scheduled messages is currently often stored in commitlog files on disk or in databases, accessed through random reads using message indexes.

[0003] However, the current storage method only allows for a very limited time range for storing scheduled messages, resulting in a serious write amplification problem and low message reading efficiency, which can easily lead to delayed delivery of scheduled messages and page cache pollution. Summary of the Invention

[0004] In view of this, embodiments of this specification provide a message processing method. One or more embodiments of this specification also relate to a cloud platform, a message processing apparatus, a computing device, a computer-readable storage medium, and a computer program product to address technical deficiencies in the prior art.

[0005] According to a first aspect of an embodiment of this specification, a message processing method is provided, including:

[0006] Obtaining a first timing message;

[0007] According to the current delay time of the first scheduled message, searching for a first storage file corresponding to the first time dimension to which the current delay time belongs, wherein each level of the time dimension is corresponding to multiple independent storage files, and the current delay time refers to the delayed processing time of the first scheduled message relative to the current time point;

[0008] The first timing message is written into the first storage file.

[0009] According to a second aspect of the embodiments of this specification, a message processing method is provided, including:

[0010] Monitor the timing messages stored in the storage files corresponding to the time dimensions of each level, where each level of time dimension is corresponding to multiple independent storage files;

[0011] When the second timed message of the storage file storage corresponding to the target level time dimension expires, the second timed message is sent to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension, where the target level time dimension is any one of the time dimensions of each level.

[0012] According to a third aspect of an embodiment of this specification, a cloud platform is provided, including a control terminal and a storage space, wherein the storage space is provided with a plurality of mutually independent storage files corresponding to time dimensions at different levels;

[0013] The control end is used to obtain a first timing message; according to the current delay time of the first timing message, search for the first storage file corresponding to the first time dimension to which the current delay time belongs, wherein the current delay time refers to the delayed processing time of the first timing message relative to the current time point; and write the first timing message into the first storage file.

[0014] According to a fourth aspect of the embodiments of this specification, a message processing device is provided, including:

[0015] An acquisition module, configured to acquire a first timing message;

[0016] a search module configured to search, based on a current delay time of the first scheduled message, for a first storage file corresponding to a first time dimension to which the current delay time belongs, wherein each level of the time dimension is provided with a plurality of mutually independent storage files, and the current delay time refers to a delayed processing time of the first scheduled message relative to the current time point;

[0017] The writing module is configured to write the first timing message into the first storage file.

[0018] According to a fifth aspect of the embodiments of this specification, a message processing device is provided, including:

[0019] A monitoring module is configured to monitor the timing messages stored in the storage files corresponding to the time dimensions of each level, wherein each time dimension of each level is corresponding to a plurality of independent storage files;

[0020] The sending module is configured to send the second timing message to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension when the second timing message of the storage file storage corresponding to the target level time dimension expires, wherein the target level time dimension is any one of the time dimensions of each level.

[0021] According to a sixth aspect of the embodiments of this specification, a computing device is provided, including:

[0022] memory and processor;

[0023] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the above-mentioned message processing method are implemented.

[0024] According to a seventh aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned message processing method are implemented.

[0025] According to an eighth aspect of the embodiments of this specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the above-mentioned message processing method when executed by a processor.

[0026] One embodiment of the present specification realizes obtaining a first scheduled message; searching for a first storage file corresponding to the first time dimension to which the current delay time belongs according to the current delay time of the first scheduled message, wherein a plurality of independent storage files are provided corresponding to the time dimension of each level, and the current delay time refers to the delayed processing time of the first scheduled message relative to the current time point; writing the first scheduled message into the first storage file. By searching for the first storage file corresponding to the first time dimension to which the current delay time belongs according to the current delay time of the first scheduled message, it is possible to search for storage files based on the hierarchy of the time dimension, thereby storing scheduled messages according to the time dimension; by providing a plurality of independent storage files corresponding to the time dimension of each level, it is possible to divide time according to the hierarchy of the time dimension, thereby realizing hierarchical nested storage of messages, rather than linear storage, and expanding the time range in which scheduled messages can be stored; by writing the first scheduled message into the first storage file, it is possible to realize sequential reading of scheduled messages based on the storage files, thereby improving the efficiency of scheduled message delivery. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 This is a diagram of the open source RocketMQ scheduled message solution;

[0028] Figure 2 This is a schematic diagram of a solution that relies on RocksDB for scheduled message access;

[0029] Figure 3 This is an architectural diagram of a cloud platform provided in one embodiment of this specification;

[0030] Figure 4 This is a flow chart of a message processing method provided by one embodiment of this specification;

[0031] Figure 5 This is a flow chart of a message processing method provided by one embodiment of this specification;

[0032] Figure 6 This is a schematic diagram of a storage structure of a multi-level time wheel of a message processing method provided by an embodiment of this specification;

[0033] Figure 7 This is a timing wheel diagram of a message processing method provided by an embodiment of this specification;

[0034] Figure 8 This is a schematic diagram of scheduled message distribution of a message processing method provided by an embodiment of this specification;

[0035] Figure 9 This is a schematic diagram of a timed message access process of a message processing method provided by an embodiment of this specification;

[0036] Figure 10 This is a structural diagram of a message processing device provided by an embodiment of this specification;

[0037] Figure 11 This is a structural diagram of a message processing device provided by an embodiment of this specification;

[0038] Figure 12 This is a structural block diagram of a computing device provided by one embodiment of this specification. DETAILED DESCRIPTION

[0039] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.

[0040] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0041] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0042] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0043] First, the terms involved in one or more embodiments of this specification are explained.

[0044] Scheduled message: refers to a message that is automatically sent within a specified time.

[0045] The time wheel is a timer divided into multiple slots. Each slot represents a division of the time wheel, used to record the passage of time. The rotation of the time wheel refers to the rotation of the time wheel, and the backward movement of the time wheel slots represents the passage of time.

[0046] Slot file: A file used to store timed messages. Its logical meaning is a "grid" in the time wheel, which contains the sending time and content of the message.

[0047] Recursion: A computer programming technique that solves a problem by calling upon itself.

[0048] Commitlog file: A data storage file stored on disk, which contains the entity content of the message data rather than index information.

[0049] The current internet environment has a significant demand for scheduled messaging applications. Scheduled messaging involves the server delivering a scheduled message to a consumer at a fixed time based on the message's scheduled time. Due to the nature of scheduled message delivery, the content of scheduled messages is currently often stored in commitlog files on disk or in databases, accessed through random reads using message indexes.

[0050] However, the current storage method only allows for a very limited time range for storing scheduled messages, resulting in a serious write amplification problem and low message reading efficiency, which can easily lead to delayed delivery of scheduled messages and page cache pollution.

[0051] The following combined Figure 1 -Attached Figure 2 , describes the current access scheme for scheduled messages. Figure 1 A schematic diagram of an open source RocketMQ timed message solution is shown. Figure 2 A schematic diagram of a solution that relies on RocksDB for scheduled message access is shown.

[0052] See also Figure 1 The current open source RocketMQ scheduled message solution uses the local file system as a reliable storage medium for delayed messages and a single-level time wheel as a transit point for scheduled messages. The index information of delayed messages is also stored in the TimerLog file. Scheduled messages are located and accessed through a single-level time wheel. For long-term scheduled messages, message rolling is used to avoid excessive message storage. If the single-level time wheel stores a scheduled message with a duration of 3 days, then a scheduled message with a current delay of 31 days will need to be rolled 10 times in the single-level time wheel, causing a serious write amplification problem.

[0053] In this implementation, a single-level time wheel is stored in memory, and each slot only stores the timerLog index of the message. In commitLog and timerLog, scheduled messages are written in order of arrival time, which is fast, but read randomly. Figure 1 As shown, it is necessary to access the timerLog file according to the address in the slot and perform a large number of random reads on the commitLog file based on the timerLog index. This reading process is not only slow but also easily pollutes the page cache.

[0054] See also Figure 2 The current solution that relies on RocksDB for scheduled message storage and access requires an additional Producer Proxy to determine whether a message is a scheduled message when it is received. If so, the message is sent to RocksDB through a separate storage path for sorted storage. After storage is complete, the RocksDB database content is scanned. If any expired data is sent back to the RocketMQ cluster as a regular message. This sorting and storage of scheduled messages in RocksDB generates a key for each time point, resulting in significant delays when subsequently reading and retrieving data, and can also pollute the page cache.

[0055] Based on this, an embodiment of the present specification realizes obtaining a first scheduled message; according to the current delay time of the first scheduled message, searching for the first storage file corresponding to the first time dimension to which the current delay time belongs, wherein a plurality of independent storage files are provided corresponding to the time dimension of each level, and the current delay time refers to the delayed processing time of the first scheduled message relative to the current time point; writing the first scheduled message into the first storage file. By searching for the first storage file corresponding to the first time dimension to which the current delay time belongs according to the current delay time of the first scheduled message, it is possible to search for storage files based on the hierarchy of the time dimension, and store scheduled messages according to the time dimension; by setting a plurality of independent storage files corresponding to the time dimension of each level, it is possible to divide time according to the hierarchy of the time dimension, and realize hierarchical nested storage of messages instead of linear storage, thereby expanding the time range in which scheduled messages can be stored; by writing the first scheduled message into the first storage file, it is possible to realize sequential reading of scheduled messages based on the storage file, thereby improving the efficiency of scheduled message delivery and avoiding page cache pollution caused by random reads.

[0056] In this specification, a message processing method is provided. This specification also involves a cloud platform, a message processing device, a computing device, a computer-readable storage medium and a computer program product, which are described in detail one by one in the following embodiments.

[0057] See also Figure 3 , Figure 3 The cloud platform 300 includes a control terminal 302 and a storage space 304 , wherein the storage space 304 is provided with multiple independent storage files corresponding to different levels of time dimensions.

[0058] Control terminal 302: used to obtain a first timing message; according to the current delay time of the first timing message, search for a first storage file corresponding to the first time dimension to which the current delay time belongs, wherein the current delay time refers to the delayed processing time of the first timing message relative to the current time point; write the first timing message into the first storage file.

[0059] In practical applications, storage space can include disks and memory, as well as data storage objects such as databases. Specifically, storage space can be divided into space for storing storage files and space for storing commit logs. Each storage file can be independently stored in a slot on each level of the time wheel. Storage files can be stored in a multi-level time wheel storage structure.

[0060] The control terminal 302 and the storage space 304 can be connected via a network. The network provides a medium for the communication link between the control terminal 302 and the storage space 304. The network can include various connection types, such as wired or wireless communication links or fiber optic cables. Data transmitted by the control terminal 302 may need to undergo encoding, transcoding, compression, and other processing before being sent to the storage space 304.

[0061] By applying the embodiments of this specification, by setting up multiple independent storage files corresponding to different levels of time dimensions in storage space 304, it is possible to sequentially write and store scheduled messages according to the different levels of time dimensions, expand the upper limit of the storage duration of scheduled messages, and increase the number and duration of scheduled messages that can be stored. A first scheduled message is obtained through control terminal 302; based on the current delay time of the first scheduled message, the first storage file corresponding to the first time dimension to which the current delay time belongs is searched in ascending order of the time dimension levels; and the first scheduled message is written to the first storage file, thereby improving the storage efficiency and accuracy of scheduled messages.

[0062] Furthermore, in an optional embodiment of the present specification, the multiple storage files corresponding to the time dimension of each level in the storage space 304 include multiple working storage files and reserved storage files.

[0063] Control terminal 302: is also used to monitor the timed messages stored in the storage files corresponding to the time dimensions of each level; when the second timed message stored in the storage file corresponding to the time dimension of the target level expires, based on the current delay time of the second timed message, in descending order of the levels of the time dimension, the second reserved storage file corresponding to the time dimension of the next level is determined, and the second timed message is sent to the second reserved storage file storage, wherein the target level time dimension is any one of the time dimensions of each level; when the current delay time of the second timed message matches the current storage time range of the time dimension of the next level, the second timed message is stored in the second working storage file corresponding to the second reserved storage file.

[0064] In an optional embodiment of the present specification, the control terminal 302 obtains a first timing message; based on the current delay time of the first timing message, searches for a first storage file corresponding to the first time dimension to which the current delay time belongs; and writes the first timing message into the first storage file in the storage space 304. The storage space 304 includes a multi-level time wheel for storing timing messages, and a submission log for storing messages. Among them, the multi-level time wheel is constructed according to the hierarchy of the time dimension, each level of the time wheel corresponds to a level of the time dimension, and each level of the time wheel includes multiple independent storage files (i.e., Slot files) for storing timing messages within the corresponding time range. When the control terminal 302 obtains the first timing message, it can recursively search upward from the low-level time wheel in the order of the hierarchy of the time dimension from low to high until the time wheel of the time dimension level to which the current delay time belongs is found, and the first timing message is stored in the storage file of the time wheel.

[0065] For example, if each level of time wheel contains 60 storage files, the first-level time wheel is a second-level wheel (the delay time range that can be stored is 0-59s, and each storage file can store a timed message within 1s), the second-level time wheel is a graded wheel (the delay time range that can be stored is 0-59min, and each storage file can store a timed message within 1min), the third-level time wheel is an hour-level wheel (the delay time range that can be stored is 0-59h, and each storage file can store a timed message within 1h),..., assuming that the current delay time of the first timed message is 1 minute and 6s, the first timed message can be stored in the second storage file in the second-level time wheel.

[0066] The control terminal 302 monitors the timed messages stored in the multi-level time wheels. When a timed message expires or is about to expire, it forwards the timed message from the currently stored time wheel to the next-level time wheel in descending order of time dimensions. If the currently stored time wheel is the lowest-level time wheel, the third timed message that expires in the lowest-level time wheel is sent to the commit log and stored as a normal message.

[0067] By applying the embodiments of this specification, by setting up multiple working storage files and multiple reserved storage files corresponding to the time dimension of each level in the storage space 304, it is possible to support the early distribution of messages, thereby avoiding the problem of delayed sending of scheduled messages due to too many scheduled messages to be sent, which causes the scheduled messages to be sent to the storage files corresponding to the low-level time dimensions in time, and also avoiding the problem of message overwriting due to the early triggering of forwarding tasks.

[0068] Furthermore, in an optional embodiment of this specification, the storage space 304 also includes a submission log;

[0069] The control terminal 302 is further configured to write the third timing message into the submission log when the third timing message stored in the storage file corresponding to the lowest layer time dimension expires.

[0070] By applying the embodiments of this specification, when the third timed message stored in the storage file corresponding to the lowest time dimension expires, the third timed message is written into the submission log. The expired timed message can be resent back to the submission log for storage, thereby completing the management of the entire life cycle of the timed message.

[0071] See also Figure 4 , Figure 4 A flow chart of a message processing method provided according to an embodiment of this specification is shown, which specifically includes the following steps.

[0072] Step 402: Obtain a first timing message.

[0073] In actual applications, the first scheduled message may be acquired, and then written to the first scheduled message, so that the written first scheduled message may be subsequently delivered according to the passage of time.

[0074] Specifically, the first scheduled message can be understood as a newly generated scheduled / delayed message that has not yet been delivered, or as a scheduled message / delayed message that has not yet expired. The first scheduled message carries the corresponding scheduled delivery time or current delay time, wherein the scheduled delivery time can be used to indicate the specific time at which the first scheduled message is delivered, and the current delay time can be understood as the delay duration required to wait for the first scheduled message to be delivered. For example, if the current time is 14:00:00, if the message type of the first scheduled message is a scheduled message, the corresponding scheduled delivery time can be 14:10:00, and if the message type of the first scheduled message is a delayed message, the corresponding current delay time can be 10 minutes.

[0075] It should be noted that while the scheduled delivery time and the current delay time differ in semantics, they both reflect that, in practice, the message requires delayed delivery, unlike regular messages that are delivered immediately. Therefore, for ease of explanation, in this specification, scheduled messages and delayed messages are collectively referred to as scheduled messages, and the scheduled delivery time and the current delay time are collectively referred to as the current delay time.

[0076] During actual implementation, each time a new first timed message is generated, a corresponding current delay time is generated for the first timed message. The current delay time can be used to subsequently store and retrieve the first timed message. Furthermore, the current delay time for the first timed message can be determined based on the specific circumstances of the actual application scenario.

[0077] For example, in an online shopping scenario, you can set an online order to be closed if it's not paid within 45 minutes. In this case, the current delay time for the first scheduled message can be set to 45 minutes. In a memo reminder scenario, you can set a reminder message for a pending item to be sent 30 days later. In this case, the current delay time for the first scheduled message can be set to 30 days.

[0078] In an optional embodiment of the present specification, when the first timing message is generated, the first timing message may be directly acquired, and the first timing message may be written and delivered according to the corresponding current delay time.

[0079] In actual applications, newly generated messages can include scheduled messages and regular messages. After each message is generated, the message content can be first stored on disk and then delivered separately based on the message type. Since scheduled messages cannot be delivered immediately, they often need to be stored for a period of time before being delivered. Therefore, if a large number of scheduled messages are generated suddenly within a period of time, the accumulation of scheduled messages can easily lead to insufficient storage space, excessive server scheduling pressure, and other problems, resulting in the loss of scheduled messages or delayed delivery.

[0080] Based on this, in an optional embodiment of this specification, obtaining the first timing message may include the following steps:

[0081] receiving a timed message to be stored;

[0082] Write the scheduled message to be stored into the submission log;

[0083] Scan each timed message recorded in the submission log, write rules in order based on the current delay time of each timed message, and extract the first unexpired timed message from the submission log.

[0084] Specifically, scheduled messages to be stored can be understood as newly generated scheduled messages that have not yet been written to disk. A commit log can be a commitlog file on disk or a database in a storage engine, any storage object capable of storing message content. Sequential write rules can be understood as rules for writing scheduled messages in chronological order.

[0085] In actual applications, newly generated scheduled messages and ordinary messages on each server can be sent to the message processing system in the cloud platform. When the message processing system receives these messages to be stored, it can write them to the disk, that is, receive the scheduled messages to be stored; and write the scheduled messages to be stored into the submission log.

[0086] Optionally, according to a specific implementation of the present specification, after the scheduled message to be stored is written into the submission log, it may include: scanning each scheduled message recorded in the submission log, and having the enqueue thread take out each scheduled message and put it into the queue; when the scheduled message is taken out from the queue and has not expired, writing the scheduled message into the storage file; when the scheduled message is taken out from the queue and has expired, putting the scheduled message back into the submission log, and updating the message type of the scheduled message to a normal message.

[0087] Optionally, according to another specific embodiment of the present specification, after writing the scheduled message to be stored into the submission log, the method may further include scanning each scheduled message recorded in the submission log and extracting the first scheduled message that has not expired from the submission log according to a sequential writing rule based on the current delay time of each scheduled message. Furthermore, the first scheduled message that has not expired may be written into a storage file, thereby enabling delivery of the first scheduled message based on reading the expired scheduled messages in the storage file.

[0088] In actual applications, in order to achieve sequential reading and writing of scheduled messages, in the process of extracting the first unexpired scheduled message from the submission log, the first scheduled message can be extracted according to the sequential writing rules based on the current delay time of each scheduled message recorded in the submission log, so that the first scheduled message can be sorted according to the chronological order of message delivery, thereby achieving sequential reading and writing of the first scheduled message, which is conducive to improving the processing efficiency of scheduled messages.

[0089] Furthermore, according to a specific implementation of the present specification, based on the current delay time of each scheduled message, according to the sequential writing rules, extracting the first scheduled message that has not expired from the submission log can include: according to the current delay time of each scheduled message, according to the sequential writing rules, determining the extraction order; extracting the first scheduled message that has not expired from the submission log according to the extraction order.

[0090] According to another specific implementation of the present specification, based on the current delay time of each scheduled message, according to the sequential writing rule, extracting the unexpired first scheduled message from the submission log can include: extracting the unexpired first scheduled message from the submission log, and sorting the extracted first scheduled messages in chronological order according to the sequential writing rule based on the current delay time of each scheduled message.

[0091] Through the embodiments of the present specification, a scheduled message to be stored is received; the scheduled message to be stored is written into a submission log, so that the scheduled message to be stored can be written to a disk; by scanning each scheduled message recorded in the submission log, based on the current delay time of each scheduled message, the first scheduled message that has not expired is extracted from the submission log according to a sequential writing rule, and the first scheduled message can be extracted in chronological order, and the first scheduled message can be sequentially written into a storage file, so that the scheduled messages in the storage file can be subsequently obtained in a sequential reading manner, thereby improving the efficiency of reading and writing scheduled messages.

[0092] Step 404: According to the current delay time of the first scheduled message, search for the first storage file corresponding to the first time dimension to which the current delay time belongs, wherein each level of the time dimension is corresponding to multiple independent storage files, and the current delay time refers to the delayed processing time of the first scheduled message relative to the current time point.

[0093] In an optional embodiment of the present specification, upon receiving a first scheduled message, an index can be assigned to the message content of each first scheduled message according to the corresponding current delay time. The index can be stored in a one-dimensional format in memory, and the message content corresponding to the index can be stored on disk or in a database. Based on the index, the message content can be read from the disk or database according to the expiration time of each first scheduled message, completing message delivery. Specifically, the one-dimensional format can include data storage formats such as arrays, queues, and linked lists.

[0094] In another optional embodiment of the present specification, when the first timing message is obtained, the first storage file corresponding to the first time dimension to which the current delay time belongs may be searched according to the current delay time of the first timing message.

[0095] Specifically, the levels of the time dimension may include second level, minute level, hour level, day level, year level, etc., which can be set according to actual needs. The lower the level of the time dimension, the higher the time accuracy. For example, in the second-level storage file, timed messages accurate to one second are stored (for example, timed messages between 8:00:00 and 8:00:01), while in the day-level storage file, all timed messages within a day are stored (for example, timed messages between 8:00:00 yesterday and 7:59:59 today).

[0096] In actual applications, the first time dimension to which the current delay time belongs can be searched in each level of time dimensions according to the current delay time of the first scheduled message.

[0097] Furthermore, the first time dimension to which the current delay time belongs may be searched in order of the levels of the time dimensions from low to high.

[0098] For example, the order of the levels of the time dimension from low to high can be understood as the order of seconds, then minutes, then hours, and so on.

[0099] Specifically, the first time dimension can be understood as the time dimension to which the current delay time belongs. The first storage file can be understood as a storage file included in the first time dimension, and the first storage file is a storage file used to store the first scheduled message. In each time dimension, the multiple storage files included in any time dimension can be stored in a storage format such as an array, a linked list, or a queue.

[0100] In one or more embodiments of the present specification, each different time dimension may include multiple different storage files, and each different time dimension may include the same number of storage files. The multiple storage files included in each different time dimension may be stored in the form of a time wheel, and each grid of the time wheel may be configured with a corresponding storage file. For example, assuming that the time dimension includes four different levels, namely, second level, minute level, hour level, and day level, the second-level time dimension may include 60 different storage files, each storage file is used to store timed messages within one second; the minute-level time dimension may include 60 different storage files, each storage file is used to store timed messages within one minute; the hour-level time dimension may include 60 different storage files, each storage file is used to store timed messages within one hour; the day-level time dimension may include 60 different storage files, each storage file is used to store timed messages within one day. Through the 240 storage files at the above four different levels, the storage of timed messages within 150 days, or nearly half a year, can be achieved.

[0101] It should be noted that the above is only an example of an optional multi-level storage method. The number of storage files that can be stored in each time dimension, as well as the time range for each storage file to be stored, can be determined based on actual needs, and this manual does not impose any restrictions on this. Preferably, the number of storage files at the lowest level can be set as large as possible, so that the time range that can be stored by the multi-level storage files can be expanded as much as possible, thereby avoiding the problem of write amplification caused by the need to rewrite the storage files for scheduled messages in the short term.

[0102] Optionally, in one embodiment of the present specification, based on the current delay time of the first scheduled message, the first time dimension to which the current delay time belongs can be searched in ascending order of the time dimension hierarchy, and then the first scheduled message can be stored in any first storage file included in the first time dimension. Furthermore, when reading the scheduled message based on the storage file of the first time dimension, the scheduled message in the first storage file can be obtained by traversing each first storage file.

[0103] Optionally, in another embodiment of the present specification, searching, according to the current delay time of the first timing message, for a first storage file corresponding to a first time dimension to which the current delay time belongs may include the following steps:

[0104] Determine, based on the current delay time of the first scheduled message and the current storage time range of each level of time dimension, the first time dimension to which the current delay time belongs;

[0105] Search for a first storage file in multiple storage files corresponding to the first time dimension.

[0106] Specifically, the current storage time range of each level of time dimension is different. For example, assuming that each level of time dimension includes 60 storage files, and the storage time range of each storage file corresponding to the second-level time dimension is 1 second, the storage time range of each storage file corresponding to the minute-level time dimension is 1 minute, the storage time range of each storage file corresponding to the hour-level time dimension is 1 hour, and the storage time range of each storage file corresponding to the day-level time dimension is 2.5 days, then the current storage time range of the second-level time dimension is 1 minute; the current storage time range of the minute-level time dimension is 1 hour; the current storage time range of the hour-level time dimension is 60 hours (i.e., 2.5 days); and the current storage time range of the day-level time dimension is 150 days.

[0107] Optionally, the first time dimension to which the current delay time belongs may be determined based on the current delay time of the first timing message and the current storage time range of the time dimensions at each level in order of the time dimensions from low to high levels.

[0108] During the actual implementation process, you can start searching from the current storage time range corresponding to the lowest-level time dimension. If the current delay time is within the current storage time range, the lowest-level time dimension is determined as the first time dimension to which the current delay time belongs. If it is not within the current storage time range, continue searching in the next-level time dimension until the first time dimension corresponding to the current storage time range that includes the current delay time is found.

[0109] Optionally, searching for the first storage file in multiple storage files corresponding to the first time dimension can be done by determining any one of the multiple storage files corresponding to the first time dimension as the first storage file; or the first storage file can be determined in chronological order based on the storage time ranges corresponding to each storage file.

[0110] By applying the embodiments of this specification, the first time dimension to which the current delay time belongs is determined based on the current delay time of the first scheduled message and the current storage time range of the time dimensions at each level, in order from low to high levels of the time dimension; the first storage file is searched for in multiple storage files corresponding to the first time dimension, and the first storage file corresponding to the first scheduled message can be recursively found from bottom to top according to the levels of the time dimension, thereby improving the accuracy and efficiency of the storage of the first scheduled message. At the same time, by setting multi-level storage files according to the levels of the time dimension, the storage duration of the scheduled message can be expanded exponentially, the storage capacity of the scheduled message can be increased, and the original write amplification factor of O(n) can be reduced to O(logn), so that the write amplification problem is effectively alleviated.

[0111] Optionally, in one embodiment of the present specification, determining the first time dimension to which the current delay time belongs based on the current delay time of the first timing message and the current storage time range of the time dimensions at each level in descending order of the levels of the time dimensions may include the following steps:

[0112] In order of the time dimension levels from low to high, it is identified whether the current delay time of the first scheduled message is within the current storage time range of the current level time dimension, until the first time dimension whose current storage time range includes the current delay time is found.

[0113] In actual applications, when the first timed message and its current delay time are obtained, the search can be started from the current storage time range of the lowest-level time dimension in order of the time dimension levels from low to high. If the current delay time does not belong to the current storage time range of the lowest-level time dimension, continue to search within the current storage time range of the next-level time dimension, and continue to search recursively upward until the first time dimension to which the current delay time belongs is found.

[0114] For example, assuming that the current storage time range corresponding to the lowest level time dimension (seconds) is 0:00:00-0:00:59, and the current delay time of the first scheduled message is 1 minute and 32 seconds, by comparing with the current storage time range corresponding to the seconds level, it can be seen that the current delay time does not belong to the seconds level time dimension. Continue to search the time dimension (minutes level) of the next level above the seconds level. Since the current storage time range corresponding to the minutes level is 0:00-0:59, it can be seen that the current delay time belongs to the minutes level time dimension, and the minutes level time dimension is determined as the first time dimension.

[0115] By applying the embodiments of this specification, the first time dimension to which the current delay time belongs is determined by recursively searching from bottom to top, which can improve the search efficiency of the first time dimension.

[0116] Optionally, in one embodiment of the present specification, searching for a first storage file in multiple storage files corresponding to a first time dimension may include the following steps:

[0117] In the multiple storage files corresponding to the first time dimension, the rules are written in order to search for the first storage file.

[0118] Specifically, the sequential writing rule can be understood as a rule for sequentially writing the scheduled messages in chronological order. It can also be understood as a rule for sequentially writing the first scheduled messages into the storage file according to the chronological order of their current delay times.

[0119] In practical applications, after determining the first time dimension, the first storage file that can be written to the first timing message can be found according to the order of the current time ranges among multiple storage files corresponding to the first time dimension and the sequential writing rule.

[0120] For example, assuming that the current storage time range corresponding to the second level is 0:00:00-0:00:59, the current storage time range corresponding to the minute level is 0:00-0:59, and the current delay time of the first scheduled message is 1 minute and 32 seconds. Then the time ranges corresponding to the various storage files corresponding to the first time dimension should be: 0:00-0:01, 0:01-0:02, ..., 0:58-0:59 (a total of 60 storage files, each storage file corresponding to a scheduled message within 1 minute). According to the sequential writing rule, it can be determined that the time range corresponding to 1 minute and 32 seconds should be 0:01-0:02, and the storage file corresponding to this time range is determined as the first storage file corresponding to the first scheduled message.

[0121] By applying the embodiments of this specification, by searching for the first storage file according to the sequential writing rules in multiple storage files corresponding to the first time dimension, the first scheduled file can be written into the corresponding storage file in chronological order, thereby supporting the sequential reading of scheduled messages during the message delivery process, improving the message delivery efficiency, and avoiding delayed delivery.

[0122] Step 406: Write the first timing message into the first storage file.

[0123] In an optional embodiment of the present specification, the message content of the first scheduled message may be directly written into the first storage file.

[0124] In another optional embodiment of the present specification, the index information of the first timed message can be written into the first storage file, and the message content can be stored in a disk or a database, wherein the index information is used to indicate the specific storage location of the message content in the disk file or the database.

[0125] Optionally, the storage structure of the first storage file may be any data structure. In order to support sequential reading of scheduled messages during the delivery process of scheduled messages upon expiration, in an optional embodiment of this specification, the storage file may include a file log; writing the first scheduled message to the first storage file may include the following steps:

[0126] The first timing message is written into the file log of the first storage file.

[0127] Specifically, the file log is a storage structure that only supports writing data from the tail and reading data from the head. Writing the first scheduled message into the file log of the first storage file specifically directly writes the message content of the first scheduled message into the file log of the first storage file.

[0128] By applying the embodiments of this specification, by writing the first scheduled message into the file log of the first storage file, sequential writing and sequential reading of the first scheduled message can be achieved, thereby improving the processing efficiency of the scheduled message.

[0129] In actual applications, when a scheduled message in a multi-level storage file expires, the expired scheduled message needs to be delivered.

[0130] In an optional embodiment of this specification, the following S4002-S4004 may also be included:

[0131] S4002: Monitor the timing messages stored in the storage files corresponding to the time dimension of each level.

[0132] Optionally, monitoring the timed messages stored in the storage files corresponding to the time dimensions at each level may include: monitoring the timed messages in each storage file corresponding to the time dimensions at each level respectively.

[0133] S4004: When the second timed message of the storage file storage corresponding to the target level time dimension expires, the second timed message is sent to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension, where the target level time dimension is any one of the time dimensions of each level.

[0134] Specifically, the second timed message can be understood as a timed message stored in a storage file corresponding to the target level time dimension. The second storage file can be understood as a storage file corresponding to the next level time dimension of the target level time dimension.

[0135] Specifically, the expiration of the second scheduled message can be understood as the current time having reached or approaching the current delay time of the second scheduled message. For example, assuming the current delay time of the second scheduled message is "8:01:32", when the current time has reached "8:01:32" or the current time is approaching "8:01:32", the second scheduled message is determined to have expired and the second scheduled message is sent down to the corresponding second-level storage file.

[0136] By applying the embodiments of this specification, the timed messages stored in the storage files corresponding to the time dimensions of each level can be monitored. When the second timed message stored in the storage file corresponding to the time dimension of the target level expires, the second timed message can be sent to the second storage file storage corresponding to the time dimension of the next level in descending order of the levels of the time dimension, thereby realizing the sending of the timed message from the high-level storage file to the low-level storage file, and realizing dynamic management of the timed message based on the rolling of the time wheel as time goes by.

[0137] In an optional embodiment of the present specification, the multiple storage files corresponding to each level of the time dimension include multiple working storage files and reserved storage files; sending the second timing message to the second storage file storage corresponding to the next level of the time dimension in descending order of the levels of the time dimension may include the following steps:

[0138] Based on the current delay time of the second scheduled message, determine the second reserved storage file corresponding to the next level time dimension in descending order of the time dimension levels, and send the second scheduled message to the second reserved storage file for storage;

[0139] When the current delay time of the second scheduled message matches the current storage time range of the next-level time dimension, the second scheduled message is stored from the second reserved storage file to the second working storage file corresponding to the next-level time dimension.

[0140] In actual applications, in order to avoid the situation where the scheduled message cannot be sent to the storage file corresponding to the low-level time dimension in time due to too many scheduled messages to be sent when sending the scheduled message from the high level to the low level, resulting in a delay in sending the scheduled message, in one or more embodiments of the present specification, multiple working storage files and multiple reserved storage files can be set for each level of time dimension, wherein the working storage file is used to normally write and read the scheduled messages within the corresponding time range, and the reserved storage file is used to store the scheduled messages in the storage file of the previous level that are about to expire in advance. That is, when the second scheduled message stored in the storage file of the target level time dimension is about to expire, the second scheduled message can be first stored in the second reserved storage file corresponding to the next level time dimension; when the second scheduled message expires, the second scheduled message is stored from the second reserved storage file to the second working storage file corresponding to the next level time dimension.

[0141] The number of reserved storage files can be determined according to the needs of actual applications, and the time dimension corresponding to the reserved storage files is the same as the time dimension corresponding to the working storage files.

[0142] For example, each time dimension at each level may correspond to 60 working storage files and 60 reserved storage files. If the time range of the scheduled messages stored in the second-level working storage file is 0:00:00-0:00:59, the time range of the scheduled messages stored in the second-level reserved storage file may be 0:01:00-0:01:59.

[0143] Specifically, the second reserved storage file can be understood as a reserved storage file corresponding to the next level time dimension of the current level time dimension.

[0144] Optionally, based on the current delay time of the second timed message, in descending order of the levels of the time dimension, the second reserved storage file corresponding to the next level time dimension is determined, and the second timed message is sent to the second reserved storage file storage, which may include: in the case where the forwarding task is triggered in advance, based on the current delay time of the second timed message, in descending order of the levels of the time dimension, the second reserved storage file corresponding to the next level time dimension is determined, and the second timed message is sent to the second reserved storage file storage.

[0145] Specifically, the forwarding task can be understood as a task of sending the second timing message from the storage file at the current level to the storage file at the next level when the second timing message expires.

[0146] Specifically, the current storage time range can be understood as the storage time range corresponding to the working storage file.

[0147] For example, when the current time is 0:01:00, all messages within the period of 0:00:00-0:00:59 have been delivered, and the current storage time range corresponding to the second-level working storage file is updated to 0:01:00-0:01:59. At this time, the current delay time of the second scheduled message matches the current storage time range of the next-level time dimension, and the second scheduled message can be stored from the second reserved storage file to the second working storage file corresponding to the next-level time dimension.

[0148] By applying the embodiments of this specification, the second reserved storage file corresponding to the next-level time dimension is determined based on the current delay time of the second scheduled message and in descending order of the levels of the time dimension, and the second scheduled message is sent to the second reserved storage file for storage; when the current delay time of the second scheduled message matches the current storage time range of the next-level time dimension, the second scheduled message is stored in the second working storage file corresponding to the second reserved storage file, so that the second scheduled message that is about to expire in the storage file of the current level can be sent downward to the reserved storage file of the next level in advance, so that when the second scheduled message expires for delivery, the scheduled message can be directly obtained from the reserved storage file corresponding to the time dimension of the same level, thereby improving the message acquisition efficiency and avoiding delayed message delivery.

[0149] Optionally, when the second timed message of the storage file storage corresponding to the target level time dimension expires, before sending the second timed message to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension, the following steps may be further included:

[0150] identifying a time difference between a current time and a current delay time of a second timing message;

[0151] When the time difference is smaller than a preset threshold, it is determined that the second timing message is expired.

[0152] Specifically, the time difference can be understood as the length of time between the current time and the current delay time of the second scheduled message. For example, if the current time is 8:00:00 and the current delay time of the second scheduled message is "8:00:20", the time difference between the current time and the current delay time of the second scheduled message is 20 seconds.

[0153] In actual applications, the advance forwarding time of scheduled messages in storage files corresponding to different levels of time dimensions can be different, that is, the preset thresholds can be different. For example, for storage files corresponding to minute-level time dimensions, the preset threshold can be 10s, that is, when the time difference is 10 seconds, the scheduled messages that are about to expire in the minute-level storage file are sent to the reserved storage file at the second level; for storage files corresponding to hourly time dimensions, the preset threshold can be 10 minutes, that is, when the time difference is 10 minutes, the scheduled messages that are about to expire in the hour-level storage file are sent to the reserved storage file at the minute level.

[0154] It should be noted that the preset thresholds corresponding to storage files at different levels of time dimensions can be set according to actual needs, and this specification does not limit this.

[0155] By applying the embodiments of this specification, the time difference between the current time and the current delay time of the second timed message is identified; when the time difference is less than a preset threshold, the second timed message is determined to be expired, and the task trigger condition of the forwarding task corresponding to the advance amount can be set based on the preset threshold, thereby triggering the sending of the expired timed file in the storage file of the current level time dimension in advance, further improving the efficiency of reading timed messages and avoiding delays in the delivery of timed messages.

[0156] Optionally, when the current level time dimension is the lowest level time dimension, the following steps may also be included:

[0157] When the third timing message stored in the storage file corresponding to the lowest level time dimension expires, the third timing message is written into the submission log.

[0158] Specifically, the third timed message can be understood as the timed message stored in the storage file corresponding to the lowest time dimension, that is, the timed message stored in the second-level storage file. The commit log can be understood as the commitlog file on the disk.

[0159] In practice, when the third-tier scheduled message stored in the storage file corresponding to the lowest-level time dimension expires, it is removed from the multi-tiered storage file and is not rewritten to the storage file. Instead, it is sent to the commitlog file for storage. After being removed from the storage file corresponding to the lowest-level time dimension and written to the commit log, the third-tier scheduled message can be processed as a normal message.

[0160] By applying the embodiments of this specification, when the third timed message stored in the storage file corresponding to the lowest time dimension expires, the third timed message is written into the commit log. The expired timed message can be resent back to the commitlog file for storage, thereby completing the management of the entire life cycle of the timed message.

[0161] An embodiment of the present specification realizes obtaining a first scheduled message; according to the current delay time of the first scheduled message, in the order of the levels of the time dimension from low to high, searching for the first storage file corresponding to the first time dimension to which the current delay time belongs, wherein each level of the time dimension is provided with multiple independent storage files; writing the first scheduled message into the first storage file. Applying the embodiment of the present specification, by searching for the first storage file corresponding to the first time dimension to which the current delay time belongs in the order of the levels of the time dimension from low to high according to the current delay time of the first scheduled message, it is possible to search for the storage file based on the order of the levels of the time dimension from low to high, thereby realizing the storage of scheduled messages according to the time dimension and expanding the time range in which scheduled messages can be stored; by writing the first scheduled message into the first storage file, it is possible to realize sequential reading of scheduled messages based on the storage file, thereby improving the efficiency of scheduled message delivery.

[0162] See also Figure 5 , Figure 5 A flow chart of a message processing method provided according to an embodiment of this specification is shown, which specifically includes the following steps.

[0163] Step 502: monitoring the timing messages stored in the storage files corresponding to the time dimensions of each level, wherein each level of the time dimension is provided with a plurality of independent storage files.

[0164] Step 504: When the second timed message of the storage file storage corresponding to the target level time dimension expires, the second timed message is sent to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension, where the target level time dimension is any one of the time dimensions of each level.

[0165] It should be noted that the specific implementation of steps 502 to 504 is the same as the specific implementation of steps S4002 to S4004 described above, and will not be described in detail in this specification.

[0166] By applying the embodiments of this specification, the timed messages stored in the storage files corresponding to the time dimensions of each level can be monitored. When the second timed message stored in the storage file corresponding to the time dimension of the current level expires, the second timed message can be sent to the second storage file storage corresponding to the time dimension of the next level in descending order of the levels of the time dimension, thereby realizing the sending of the timed message from the high-level storage file to the low-level storage file, and realizing dynamic management of the timed message as time goes by.

[0167] The following combined Figure 6 -Attached Figure 9 , taking the application of the message processing method provided in this specification in the timing message rolling / access scheme based on the multi-level time wheel as an example, the message processing method is further explained. Figure 6 A schematic diagram of the storage structure of a multi-level time wheel of a message processing method provided by an embodiment of this specification is shown. Figure 7 A schematic diagram of a time wheel of a message processing method provided by an embodiment of this specification is shown. Figure 8 A schematic diagram of scheduled message distribution of a message processing method provided by an embodiment of this specification is shown. Figure 9 A schematic diagram of a timed message access process of a message processing method provided by an embodiment of this specification is shown.

[0168] See also Figure 6 The multi-level time wheel-based scheduled message scrolling / access solution primarily replaces a single-level time wheel with a multi-level one to address the storage and read issues of scheduled messages. This solution replaces the single-level time wheel with a multi-level one based on different time dimensions, and changes the storage structure corresponding to each slot in each level of the time wheel to a grid storage structure (SlotLog). This allows for independent storage files corresponding to each SlotLog, supporting sequential writes and reads. Each level of the time wheel has different precision.

[0169] In practical applications, the first-level (second-level) time wheel can be stored in memory, while the remaining higher-level time wheels can be stored on disk. Except for the second-level time wheel, each independent slot file of the other-level time wheels can directly store the message content corresponding to the scheduled message, without the need for additional indexing. Each slot of the second-level wheel can be configured with an independent slot file for directly writing the message content of the scheduled message, or for storing the message index of the scheduled message, which can be used to read the message content from the commitlog file based on the message index.

[0170] Figure 6For example, a time wheel consisting of timerWheel Level 1, timerWheel Level 2, and timerWheel Level 3 is represented by timerWheel Level 1, which corresponds to the lowest level of the time dimension. This is the second-level time wheel, where each slot can store a scheduled message within one second. TimerWheel Level 2 is the minute-level time wheel, where each slot can store a scheduled message within one minute. TimerWheel Level 3 is the hour-level time wheel, where each slot can store a scheduled message within one hour. Each time wheel can contain the same number of slots, that is, the same number of independent slot files (Slot 1, Slot 2, ..., Slot n).

[0171] The multi-level time wheel designed according to the above structure can expand the storage duration of scheduled messages exponentially as the time dimension level increases, breaking the fixed-length storage duration limit, supporting scheduled messages with arbitrary delays, and avoiding the linear increase in storage space size, thereby saving a large amount of storage space.

[0172] Moreover, since the timing messages in the upper-level time wheel are sent downward one level at a time, the original write amplification factor of O(n) can be reduced to O(logn), effectively alleviating the serious write amplification problem existing in the single-level time wheel.

[0173] In practice, the number of slot files in each time wheel can be configured according to actual needs. The number of slot files in the first time wheel can be increased as much as possible to avoid write amplification caused by short-term scheduled messages being written to subsequent time wheels and repeatedly distributed downward.

[0174] When an unexpired timed message is obtained, the current delay time of the timed message can be retrieved from timerWheel Level 1 and recursively searched for the time wheel level corresponding to the current delay time. When the corresponding time wheel level is found, the slot in the time wheel of the corresponding level can be determined according to the time sequence, so that the timed message can be written sequentially into the corresponding slot file of the time wheel of the corresponding level.

[0175] When a message in a time wheel expires, the message in the higher-level time wheel can be sent down from top to bottom. When a scheduled message in a second-level time wheel expires, the message can be delivered from the second-level time wheel and written to the commitlog file for storage. When a scheduled message expires and is delivered from the second-level time wheel, the lifecycle of the scheduled message ends.

[0176] See also Figure 7 , Figure 7 The specific storage structure design of each level of time wheel is shown. Taking the example of each level of time wheel including 60 storage grids, each level of time wheel can actually include a 60-grid write window and set an additional 60-grid reserved window to provide advance information for message distribution.

[0177] It should be noted that the number of reserved windows can be determined according to actual needs, and this specification does not impose any limitation on this.

[0178] See also Figure 8 , the following combined with the attached Figure 8 , further explains why a reserved window needs to be set for a timed message scrolling / access solution based on a multi-level time wheel.

[0179] For example, if the accuracy of the lowest-level time wheel is 1 second (second wheel), the second-level accuracy is 1 minute (grading wheel), and the third-level accuracy is 1 hour (hour wheel), then from 19:59:00 to 19:59:59, the second wheel can operate normally and consume the messages in its grid. When it reaches 20:00:00, the messages needed by the second wheel must be obtained from the grading wheel. At this time, the grading wheel only stores messages from 19:00 to 19:59, and the messages for 20:00 must be obtained from the hour wheel.

[0180] Therefore, at 20:00:00, the second wheel on the bottom layer triggers the simultaneous rotation of the two time wheels on the upper layer. In this second, the messages on the two upper layers obviously cannot fall into the grid corresponding to 20:00:00 on the bottom layer in time.

[0181] To avoid delays in scheduled message delivery, a forwarding timeout is set. This triggers the forwarding task in advance, ensuring that each time wheel begins forwarding before reaching the round boundary, sending expiring scheduled messages to the next time wheel. If the total number of slots in the time wheel is not redundant, the premature forwarding task will inevitably overwrite the data in the slots of the next time wheel, resulting in the serious consequence of lost scheduled messages.

[0182] Therefore, a reserved window is set for each level of the time wheel. At 19:59:50 seconds, the data at 20:00 in the grading wheel will be distributed to the reserved window corresponding to 20:00:00-20:00:59 in the second wheel. The data at 20:00 in the grading wheel is pre-fetched from the hour wheel at 19:50 and stored in the reserved window corresponding to 20:00-20:59 in the grading wheel.

[0183] In this way, it is possible to avoid delays in the delivery and loss of scheduled messages, and greatly improve the efficiency of scheduled message reading and delivery.

[0184] See also Figure 9 , the following combined with the attached Figure 9 , further explains the access logic of scheduled messages in the scheduled message scrolling / access solution based on the multi-level time wheel.

[0185] When a message enters the system, it is usually written to disk first, that is, stored in commitlog. After entering commitlog, the timed messages in it can be scanned and taken out by the queue thread (TimerEnqueueGetService) and put into the enqueue queue. The messages in the queue are divided into two types: one is the unexpired timed message, which will be written as follows: Figure 9 The dotted box on the left is used as a timed message rotation. The other type is messages that have expired when they are taken from the enqueue queue. These messages are directly put back into the commitlog.

[0186] Figure 9 The dotted boxes on the left include timerWheel Level 1 and timerWheel Level 2, representing multi-level time wheels of varying precision. As the higher-level time wheel (Level 2) rotates, it dumps messages in expired slots onto the next-level time wheel (Level 1), directly writing the message contents sequentially into their corresponding slots. As each slot in the lower-level time wheel expires, the scheduled message in that slot leaves the time wheel and is written to the commitlog file. Once a message enters the commitlog, it becomes a consumable regular message, thus completing its lifecycle.

[0187] By applying the embodiments of this specification, through a timed message scrolling / access scheme based on a multi-level time wheel, when an unexpired timed message is obtained, starting from the low-level time wheel, the time wheel of the corresponding level is recursively searched from bottom to top according to the current delay time corresponding to the timed message, and the timed message is sequentially written into the corresponding slot of the time wheel of that level, thereby achieving accurate writing of the timed message and improving the efficiency of writing the timed message; by triggering the timed message forwarding task in advance, before the message in the time wheel is about to expire, the message that is about to expire in the current level time wheel is forwarded in advance to the reserved slot of the next level time wheel, thereby supporting distribution advance, avoiding delayed message delivery and message loss, and further improving the processing efficiency and accuracy of the timed message.

[0188] Corresponding to the above method embodiment, this specification also provides a message processing device embodiment, Figure 10 FIG1 shows a schematic diagram of the structure of a message processing device provided by an embodiment of this specification. Figure 10 As shown, the device includes:

[0189] The acquisition module 1002 is configured to acquire a first timing message.

[0190] Search module 1004: is configured to search for the first storage file corresponding to the first time dimension to which the current delay time belongs based on the current delay time of the first scheduled message, wherein each level of the time dimension is corresponding to multiple independent storage files, and the current delay time refers to the delayed processing time of the first scheduled message relative to the current time point.

[0191] The writing module 1006 is configured to write the first timing message into the first storage file.

[0192] Optionally, the search module 1004 is further configured to:

[0193] Determine, based on the current delay time of the first scheduled message and the current storage time range of each level of time dimension, the first time dimension to which the current delay time belongs;

[0194] Search for a first storage file in multiple storage files corresponding to the first time dimension.

[0195] Optionally, the search module 1004 is further configured to:

[0196] Identify, in descending order of the levels of the time dimension, whether the current delay time of the first scheduled message is within the current storage time range of the time dimension of the current level;

[0197] If so, it is determined that the current level time dimension is the first time dimension to which the current delay time belongs.

[0198] Optionally, the search module 1004 is further configured to:

[0199] In the multiple storage files corresponding to the first time dimension, the rules are written in order to search for the first storage file.

[0200] Optionally, the message processing device further includes a sending module configured to:

[0201] Monitor the timed messages stored in storage files corresponding to the time dimension of each level;

[0202] When the second timed message of the storage file storage corresponding to the target level time dimension expires, the second timed message is sent to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension, where the target level time dimension is any one of the time dimensions of each level.

[0203] Optionally, the multiple storage files corresponding to the time dimension of each level include multiple working storage files and reserved storage files; the sending module is further configured to:

[0204] Based on the current delay time of the second scheduled message, determine the second reserved storage file corresponding to the next level time dimension in descending order of the time dimension levels, and send the second scheduled message to the second reserved storage file for storage;

[0205] When the current delay time of the second scheduled message matches the current storage time range of the next-level time dimension, the second scheduled message is stored from the second reserved storage file to the second working storage file corresponding to the next-level time dimension.

[0206] Optionally, the sending module is further configured to:

[0207] identifying a time difference between a current time and a current delay time of a second timing message;

[0208] When the time difference is smaller than a preset threshold, it is determined that the second timing message is expired.

[0209] Optionally, when the current level time dimension is the lowest level time dimension, the sending module is further configured to:

[0210] When the third timing message stored in the storage file corresponding to the lowest level time dimension expires, the third timing message is written into the submission log.

[0211] Optionally, the acquisition module 1002 is further configured to:

[0212] receiving a timed message to be stored;

[0213] Write the scheduled message to be stored into the submission log;

[0214] Scan each timed message recorded in the submission log, write rules in order based on the current delay time of each timed message, and extract the first unexpired timed message from the submission log.

[0215] Optionally, the stored file includes a file log; the writing module 1006 is further configured to:

[0216] The first timing message is written into the file log of the first storage file.

[0217] By applying the embodiments of this specification, by searching for the first storage file corresponding to the first time dimension to which the current delay time belongs according to the current delay time of the first scheduled message and in order of the levels of the time dimension from low to high, it is possible to search for the storage file based on the order of the levels of the time dimension from low to high, thereby storing the scheduled messages according to the time dimension and expanding the time range in which the scheduled messages can be stored; by writing the first scheduled message into the first storage file, it is possible to sequentially read the scheduled messages based on the storage file, thereby improving the efficiency of scheduled message delivery.

[0218] The above is a schematic scheme of a message processing device of this embodiment. It should be noted that the technical scheme of the message processing device and the technical scheme of the message processing method described above are of the same concept. For details not described in detail in the technical scheme of the message processing device, please refer to the description of the technical scheme of the message processing method described above.

[0219] Corresponding to the above method embodiment, this specification also provides a message processing device embodiment, Figure 11 FIG1 shows a schematic diagram of the structure of a message processing device provided by an embodiment of this specification. Figure 11 As shown, the device includes:

[0220] The monitoring module 1102 is configured to monitor the timing messages stored in the storage files corresponding to the time dimensions of each level, wherein each level of the time dimension is corresponding to a plurality of independent storage files.

[0221] Sending module 1104: is configured to send the second timing message to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension when the second timing message of the storage file storage corresponding to the target level time dimension expires, wherein the target level time dimension is any one of the time dimensions of each level.

[0222] By applying the embodiments of this specification, the timed messages stored in the storage files corresponding to the time dimensions of each level can be monitored. When the second timed message stored in the storage file corresponding to the time dimension of the current level expires, the second timed message can be sent to the second storage file storage corresponding to the time dimension of the next level in descending order of the levels of the time dimension, thereby realizing the sending of the timed message from the high-level storage file to the low-level storage file, and realizing dynamic management of the timed message as time goes by.

[0223] The above is a schematic scheme of a message processing device of this embodiment. It should be noted that the technical scheme of the message processing device and the technical scheme of the message processing method described above are of the same concept. For details not described in detail in the technical scheme of the message processing device, please refer to the description of the technical scheme of the message processing method described above.

[0224] Figure 12 The following is a block diagram of a computing device 1200 according to one embodiment of the present disclosure. Components of the computing device 1200 include, but are not limited to, a memory 1210 and a processor 1220. The processor 1220 is connected to the memory 1210 via a bus 1230, and a database 1250 is used to store data.

[0225] The computing device 1200 also includes an access device 1240 that enables the computing device 1200 to communicate via one or more networks 1260. Examples of such networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1240 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, or a near field communication (NFC) interface.

[0226] In one embodiment of the present specification, the above components of the computing device 1200 and Figure 12 Other components not shown in the figure may also be connected to each other, for example, via a bus. Figure 12 The computing device structure block diagram shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art may add or replace other components as needed.

[0227] Computing device 1200 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, personal digital assistant, laptop computer, notebook computer, netbook computer, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or personal computer (PC). Computing device 1200 may also be a mobile or stationary server.

[0228] The processor 1220 is configured to execute the following computer-executable instructions, which implement the steps of the above-mentioned message processing method when executed by the processor.

[0229] The above is a schematic solution of a computing device of this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned message processing method are of the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the above-mentioned message processing method.

[0230] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which implement the steps of the above-mentioned message processing method when executed by a processor.

[0231] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the message processing method described above are of the same concept. For details not described in detail in the technical scheme of the storage medium, please refer to the description of the technical scheme of the message processing method described above.

[0232] An embodiment of the present specification further provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned message processing method when executed by a processor.

[0233] The above is a schematic solution of a computer program product of this embodiment. It should be noted that the technical solution of this computer program product and the technical solution of the above-mentioned message processing method are based on the same concept. For details not described in detail in the technical solution of the computer program product, please refer to the description of the technical solution of the above-mentioned message processing method.

[0234] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0235] The computer instructions include computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal, and software distribution medium. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media does not include electric carrier signals and telecommunication signals.

[0236] It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0237] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0238] The preferred embodiments disclosed above are intended only to help illustrate this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made based on the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. A message processing method, comprising: Obtaining a first timing message; Searching, based on the current delay time of the first scheduled message, a first storage file corresponding to a first time dimension to which the current delay time belongs, wherein each level of the time dimension is provided with multiple independent storage files, and the current delay time refers to the delayed processing time of the first scheduled message relative to the current time point; The first timing message is written into the first storage file.

2. The method according to claim 1, wherein searching, based on the current delay time of the first timing message, for a first storage file corresponding to a first time dimension to which the current delay time belongs comprises: Determining, based on the current delay time of the first timing message and the current storage time range of each level of time dimension, the first time dimension to which the current delay time belongs; Search for a first storage file in multiple storage files corresponding to the first time dimension.

3. The method according to claim 2, wherein determining the first time dimension to which the current delay time belongs based on the current delay time of the first timing message and the current storage time range of each level of time dimension comprises: Identifying, in descending order of the levels of the time dimension, whether the current delay time of the first timing message is within the current storage time range of the time dimension of the current level; If so, it is determined that the current level time dimension is the first time dimension to which the current delay time belongs.

4. The method according to claim 2 or 3, wherein searching for the first storage file in the plurality of storage files corresponding to the first time dimension comprises: In the multiple storage files corresponding to the first time dimension, the rules are written in order to search for the first storage file.

5. The method according to claim 1, further comprising: Monitor the timed messages stored in storage files corresponding to the time dimension of each level; When the second timed message of the storage file storage corresponding to the target level time dimension expires, the second timed message is sent to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension, wherein the target level time dimension is any one of the time dimensions of each level.

6. The method according to claim 5, wherein the plurality of storage files corresponding to the time dimension of each level include a plurality of working storage files and a reserved storage file; The sending of the second timing message to a second storage file storage corresponding to a next-level time dimension in descending order of the levels of the time dimension includes: Based on the current delay time of the second timing message, determine the second reserved storage file corresponding to the next level time dimension in descending order of the time dimension levels, and send the second timing message to the second reserved storage file for storage; When the current delay time of the second timing message matches the current storage time range of the next-level time dimension, the second timing message is stored from the second reserved storage file to the second working storage file corresponding to the next-level time dimension.

7. The method according to claim 5 or 6, wherein when the second timed message stored in the storage file corresponding to the target level time dimension expires, before sending the second timed message to the second storage file corresponding to the next level time dimension in descending order of the time dimension, the method further comprises: identifying a time difference between a current time and a current delay time of the second timing message; When the time difference is smaller than a preset threshold, it is determined that the second timing message is expired.

8. The method according to claim 5 or 6, wherein when the current level time dimension is the lowest level time dimension, the method further comprises: When the third timing message stored in the storage file corresponding to the lowest level time dimension expires, the third timing message is written into the submission log.

9. The method according to any one of claims 1-3, 5-6, wherein obtaining the first timing message comprises: receiving a timed message to be stored; Writing the timed message to be stored into a submission log; Scan each timed message recorded in the submission log, write rules in order based on the current delay time of each timed message, and extract the first timed message that has not expired from the submission log.

10. The method according to any one of claims 1-3, 5-6, wherein the stored file comprises a file log; Writing the first timing message into the first storage file includes: The first timing message is written into the file log of the first storage file.

11. A message processing method, comprising: Monitor the timing messages stored in the storage files corresponding to the time dimensions of each level, where each level of time dimension is corresponding to multiple independent storage files; When the second timed message of the storage file storage corresponding to the target level time dimension expires, the second timed message is sent to the second storage file storage corresponding to the next level time dimension in descending order of the levels of the time dimension, wherein the target level time dimension is any one of the time dimensions of each level.

12. A cloud platform comprising a control terminal and a storage space, wherein the storage space is provided with a plurality of mutually independent storage files corresponding to different levels of time dimensions; The control terminal is used to obtain a first timing message; according to the current delay time of the first timing message, search for a first storage file corresponding to the first time dimension to which the current delay time belongs, wherein, The current delay time refers to the delayed processing time of the first timing message relative to the current time point; the first timing message is written into the first storage file.

13. The cloud platform according to claim 12, wherein the plurality of storage files corresponding to the time dimension of each level in the storage space include a plurality of working storage files and a reserved storage file; The control end is also used to monitor the timed messages stored in the storage files corresponding to the time dimensions of each level; when the second timed message stored in the storage file corresponding to the time dimension of the current level expires, based on the current delay time of the second timed message, in the order of the levels of the time dimension from high to low, the second reserved storage file corresponding to the time dimension of the next level is determined, and the second timed message is sent to the second reserved storage file storage; when the current delay time of the second timed message matches the current storage time range of the time dimension of the next level, the second timed message is stored from the second reserved storage file to the second working storage file corresponding to the time dimension of the next level.

14. The cloud platform according to claim 12 or 13, wherein the storage space further comprises a submission log; The control end is further configured to write the third timing message into the submission log when the third timing message stored in the storage file corresponding to the lowest layer time dimension expires.

15. A computing device comprising: memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer program / instructions are executed by the processor, the steps of the message processing method according to any one of claims 1 to 11 are implemented.

16. A computer-readable storage medium storing a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the steps of the message processing method according to any one of claims 1 to 11.

17. A computer program product, comprising a computer program / instruction, which implements the steps of the message processing method according to any one of claims 1 to 11 when executed by a processor.