Message processing method and device and electronic equipment

CN120435843APending Publication Date: 2025-08-05BIGO TECH PTE LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202180073625.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2025-08-05

AI Technical Summary

Technical Problem

When the existing technology processes a large number of bell messages, the database stability is poor and the cost is high. Especially in high concurrency situations, it is difficult to maintain the real-time and low-latency of the system.

Method used

Real-time writing and persistent storage are achieved by obtaining the priority of the target message, caching it to a real-time database (such as Redis), and transferring the message to a persistent database (such as Pika) when the cache time exceeds the preset time. , reduce system costs.

Benefits of technology

While maintaining efficient message processing and system stability, it reduces storage costs, improves the system's anti-concurrency capabilities, and reduces user churn.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120435843A_ABST
    Figure CN120435843A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a message processing method and device and electronic equipment, and relates to the technical field of message processing. The method comprises the following steps: acquiring a target message, and determining the priority of the target message; caching the target message to a first database according to the priority of the target message; and transferring the target message with the cache duration exceeding a first preset duration in the first database from the first database to a second database. According to the scheme, the cache can be written in real time, the persistent data can be stored, and the system stability is ensured and the cost is reduced while the efficient message processing is maintained.
Need to check novelty before this filing date? Find Prior Art

Description

Message processing method, device and electronic device

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This disclosure claims priority to the Chinese patent application filed with the China Patent Office on November 30, 2020, with application number 202011377144.0 and titled “Message Processing Method, Device and Electronic Device,” the entire contents of which are incorporated by reference into this disclosure. Technical Field

[0003] The present disclosure relates to the field of message processing technology, and in particular to a message processing method, device, and electronic device. Background Art

[0004] As a form of instant interaction, the key to the success of the bell function is its timeliness. If every message is delivered with zero delay, users can get real-time feedback faster, thus stimulating their enthusiasm. Furthermore, this real-time nature is equivalent to an instant online call, allowing users to communicate better and playing a vital role in building social connections. Conversely, if there is a significant delay in consumption, the longer the wait time, the greater the user churn.

[0005] In addition to timeliness, the stability of the bell system is also fundamental to the bell system. In social applications (apps), bells are prone to a surge. For example, a popular user posting a video may trigger a large number of like and comment bells in a short period of time, which can have a significant impact on the system. Therefore, it is necessary to properly handle the surge and maintain system stability.

[0006] Existing technologies store all user bell messages in a relational database. These messages are then sorted and paged in reverse chronological order when users retrieve them. However, this approach may be limited by the system scale. As the number of users increases, the concurrent volume of messages becomes very high, and the database becomes unsuitable. Even if the remote dictionary service Redis is used as a cache to build a message list for each user, this solution is costly due to the large amount of data.

[0007] Overview

[0008] The present disclosure provides a message processing method, device, and electronic device to solve the problems of large data volume and poor system stability to a certain extent.

[0009] In a first aspect of the present disclosure, a message processing method is provided, the method comprising:

[0010] Obtaining a target message and determining a priority of the target message;

[0011] caching the target message in a first database according to the priority of the target message;

[0012] The target message that has been cached in the first database for a period exceeding a first preset period is transferred from the first database to the second database.

[0013] In a second aspect of the present disclosure, a message processing device is provided, the device comprising:

[0014] A processing module, configured to obtain a target message and determine a priority of the target message;

[0015] a cache module, configured to cache the target message in a first database according to the priority of the target message;

[0016] The first transfer module is configured to transfer target messages that have been cached in the first database for a period exceeding a first preset period from the first database to a second database.

[0017] In a third aspect of the present disclosure, an electronic device is provided, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0018] Memory for storing computer programs;

[0019] The processor is configured to implement the steps of the message processing method described above when executing the program stored in the memory.

[0020] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the message processing method described above is implemented.

[0021] In a fifth aspect of the embodiments of the present disclosure, a computer program product comprising instructions is further provided, which, when executed on a computer, enables the computer to execute the message processing method described above.

[0022] Compared with the prior art, the present disclosure has the following advantages:

[0023] In an embodiment of the present disclosure, a target message is obtained and the priority of the target message is determined, and the target message is cached in a first database according to the priority of the target message. If the cache time of the target message in the first database exceeds a first preset time, the target message is transferred from the first database to the second database. This allows for real-time writing to the cache and storage of persistent data, thereby ensuring system stability and reducing costs while maintaining efficient message processing.

[0024] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the specific implementation methods of the present disclosure are listed below.

[0025] BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for describing the embodiments.

[0027] FIG1 is a flow chart of a message processing method provided by an embodiment of the present disclosure;

[0028] FIG2 is a schematic diagram of the structure of a message processing system provided by an embodiment of the present disclosure;

[0029] FIG3 is a specific flow chart of a message processing method provided by an embodiment of the present disclosure;

[0030] FIG4 is a structural block diagram of a message processing device provided by an embodiment of the present disclosure;

[0031] FIG5 is a structural block diagram of an electronic device provided by an embodiment of the present disclosure;

[0032] FIG6 schematically shows a block diagram of another electronic device for executing the method according to the present disclosure; and

[0033] FIG7 schematically shows a storage unit for holding or carrying program codes for implementing the method according to the present disclosure.

[0034] Detailed description

[0035] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0036] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0037] When describing the embodiments of the present disclosure, some concepts used in the following description are first explained.

[0038] Bell: A notification message that is triggered to a designated group of people after a user performs a production action within the app. For example, if user A likes user B's video X, user B will receive an in-app notification message similar to "A liked your video X." Similarly, if user C follows user D, D will receive an in-app notification message saying "User C follows you." These notifications are collectively referred to as "bells." Bells have different subcategories depending on the production scenario, such as like bells, follow bells, and comment bells.

[0039] The timeliness of the bell: refers to whether the bell can provide immediate feedback to the user after being triggered.

[0040] In social apps, improving user interaction and enhancing the user experience are crucial to increasing user retention and building strong social connections. Bells are one of the most important ways to do this.

[0041] In an APP with tens of millions of daily active users, the number of bells generated by the system every day will reach tens of millions, and it is impossible to use a database alone. If the system directly uses redis cache as full storage, although it can effectively solve the performance problem, the bell is a message with high timeliness, and its importance will gradually decrease with time. Too many old messages in redis lead to high costs. Therefore, the embodiments of the present disclosure provide a message processing method, device and electronic device. In response to these existing phenomena, a database with persistent storage is introduced, which can reduce system costs while maintaining high timeliness and high stability of the bell.

[0042] Specifically, as shown in FIG1 , an embodiment of the present disclosure provides a message processing method, which specifically includes:

[0043] Step 101: Acquire a target message and determine the priority of the target message.

[0044] Specifically, the bell system obtains the target message and determines the priority of the target message. The priority of the target message can be used as a basis for judging the importance of the target message.

[0045] Optionally, obtaining the target message in the above step 101 may specifically include:

[0046] Obtaining a message to be consumed in a message queue, wherein the message to be consumed is a message written into the message queue by a message producer;

[0047] The target message to be consumed in the messages to be consumed is consumed to obtain the target message after consumption.

[0048] Specifically, as shown in Figure 2, the bell system includes a production service 21, a message queue 22, a bell consumer 23, a first database 24, and a second database 25. The production service 21 is used to produce messages to be consumed, which are then written to the message queue 22. The bell consumer 23 is used to consume bell messages. Both the first database 24 and the second database 25 cache target messages.

[0049] Specifically, as shown in Figure 3, there are many behaviors that trigger messages to be consumed (i.e., bells). Various behaviors within the APP will generate bells, such as: video likes 311, video comments 312, user attention 313, user @ 314, etc. All of these messages will be written to the message queue, and the bell system will subscribe to and consume them one by one. Taking video likes as an example, after the message producer (i.e., the user) likes the video, it will be written to the message queue. This message queue can be defined as a fast message queue 32. Get the message to be consumed in the fast message queue 32, and consume the target message to be consumed in the message to be consumed for the first time 33. The number of threads can be adjusted. Among them, the role of the message queue is to decouple services. At the same time, when the messages are highly concurrent, it can play a role in peak shaving and current limiting, effectively improving the stability of the system.

[0050] Furthermore, as shown in Figure 3, different types of bells have different importance. For example, the comment bell is more important than the like bell. Furthermore, the importance of bells varies for different users. For a user who often doesn't check their bells, or is offline, the real-time nature of their bells becomes less important. Such users' bells can be set as low-priority messages. To prevent fast message queues from backlogging, priority 34, or the bell's priority, can be determined. After the target message is consumed for the first time, the priority of the target message is determined.

[0051] Step 102: Cache the target message in a first database according to the priority of the target message.

[0052] Specifically, in step 102, if the priority of the target message is different, the target message is cached in the first database in different ways. The first database, as a real-time cache database, can be a redis database, which can maintain the timeliness of the bell.

[0053] Step 103: Transfer the target message cached in the first database for a period exceeding a first preset period from the first database to the second database.

[0054] Specifically, in the above step 103, if the target message cache length in the first database exceeds the first preset length, the target message is transferred from the first database to the second database; if the target message cache length in the first database is less than or equal to the first preset length, the target message is not transferred and remains cached in the first database.

[0055] It should be noted that the first preset duration is the time limit for determining whether the target message can be transferred to the second database as persistent data. If the target message is cached in the first database for longer than the first preset duration, it must be transferred to the second database as persistent data. If the target message is cached in the first database for less than or equal to the first preset duration, it must continue to be cached in the first database. The second database, which caches persistent data and can be a Pika, can improve system performance and reduce costs.

[0056] In the above-mentioned embodiment of the present disclosure, by obtaining the target message and determining the priority of the target message, the target message is cached in the first database according to the priority of the target message, and if the cache time of the target message in the first database exceeds the first preset time, the target message is transferred from the first database to the second database, which can be written to the cache in real time and can also store persistent data, thereby ensuring system stability and reducing costs while maintaining efficient message processing.

[0057] Optionally, in step 102, caching the target message in the first database according to the priority of the target message specifically includes:

[0058] If the target message is a high-priority message, caching the target message in the first database;

[0059] If the target message is a low-priority message, the target message is cached in the first database after secondary consumption.

[0060] Specifically, as shown in Figure 3, if the target message is determined to be a high-priority message, the target message after consumption can be directly cached in the first database 35 (i.e., directly written); if the target message is determined to be a low-priority message, the target message needs to be placed in the slow message queue 36 first, and then cached in the first database 35 after secondary consumption 37 (i.e., delayed writing), to avoid the problem of delayed caching of the target message when the fast message queue is accumulated.

[0061] It should be noted that the method for determining the priority can be defined according to specific functions and is not specifically limited here.

[0062] For example, the number of unread bell messages of a user can be used as a factor in determining the priority of target messages. If the number of unread bell messages exceeds 99, the user can be defined as a lazy bell user. When the bell message queue accumulates, the user's bell messages will be delayed and written as low-priority messages. This effectively handles some sudden high-concurrency situations and improves the user experience.

[0063] Optionally, after caching the target message in the first database in step 102, the method may further include:

[0064] Obtaining a first number of target messages cached in the first database;

[0065] If the first number exceeds a first threshold, the target messages are deleted in the order of time in which they are cached in the first database until the first number of target messages cached in the first database is less than or equal to the first threshold.

[0066] Specifically, the first number of target messages cached in the first database is obtained, and the first number is compared with the first threshold. If the first number exceeds the first threshold, the target messages can be deleted in the order of time in which they are cached in the first database, until the first number of target messages remaining cached in the first database is less than or equal to the first threshold. In other words, the earliest target message cached in the first database can be deleted, and then the earliest target message cached in the first database can be selected from the remaining target messages in the first database for deletion, and so on, until the first number is less than or equal to the first threshold. Among them, the first threshold is the threshold of the number of bells that the same user can save in the first database. The first threshold can be set as needed and is not specifically limited here.

[0067] For example: when a bell is triggered and cached in the first database, the length of the current user's bell list needs to be evaluated. Since the distribution of bells has a relatively large characteristic, the more important the user is, the larger the number of bells will be, and they will occupy the vast majority of the total number of bells. The importance of the tail bells is relatively low. The bell system will only store the first threshold (such as 2000) number of bells for each user. Therefore, after writing to the first database (such as redis) in real time, it is necessary to determine whether its length exceeds the deletion threshold (ie, the first threshold). If it exceeds, the deletion operation will be performed to ensure that the amount of data in each user list is not too large. This avoids performance problems caused by excessive cache size for a single user, and also avoids data skew in cache shards, which leads to a decrease in cache hit rate.

[0068] It should be noted that the deletion method is not limited to deletion in the order of time in which the data are cached in the first database, and other deletion methods can also be set as needed, which is not specifically limited again.

[0069] Optionally, in step 103, transferring the target message in the first database that has been cached for longer than a first preset time period from the first database to the second database may specifically include:

[0070] classifying the target messages in the first database to form a plurality of clusters;

[0071] At intervals of a second preset time, detecting a cache time of the target message in each cluster in the first database;

[0072] Target messages in different clusters that have been cached for longer than a first preset time period are transferred from the first database to the second database respectively.

[0073] Specifically, the target messages cached in the first database are categorized to form multiple clusters, each containing at least one target message. At intervals of a second preset duration, a determination is made as to whether any target message in each cluster has been cached for longer than the first preset duration. If so, the target messages in each cluster that have been cached for longer than the first preset duration are transferred as persistent data to the second database, for each cluster. The persistent data is cached in the second database, thereby improving concurrent processing capabilities.

[0074] It should be noted that the first preset time period is a time period for determining whether each cluster contains a target message whose cache time exceeds the first preset time period. The first preset time period can be specifically set as needed and is not specifically limited here.

[0075] Optionally, after transferring the target message cached in the first database for a period exceeding the first preset period from the first database to the second database in step 103, the method may further include:

[0076] Obtaining a second number of target messages cached in the second database;

[0077] If the second number exceeds a second threshold, the target messages are deleted in the order of time in which they are cached in the second database until the second number of target messages cached in the second database is less than or equal to the second threshold.

[0078] Specifically, the second number of target messages (i.e., persistent data) cached in the second database is obtained, and the second number is compared with the second threshold. If the second number exceeds the second threshold, the target messages can be deleted in the order of time when they are cached in the second database until the second number of target messages remaining cached in the second database is less than or equal to the second threshold. In other words, the earliest target message cached in the second database can be deleted, and then the earliest target message cached in the second database can be selected from the remaining target messages in the second database for deletion, and so on, until the second number is less than or equal to the second threshold. Among them, the second threshold is the threshold of the number of bells that the same user can save in the second database. The second threshold can be set as needed and is not specifically limited here.

[0079] It should be noted that the deletion method is not limited to deletion in the order of time when the data are cached in the second database, and other deletion methods can also be set as needed, which is not specifically limited again.

[0080] Optionally, after step 102 caches the target message in the first database according to the priority of the target message, the method further includes:

[0081] detecting the message processing capability of the second database at intervals of a third preset time;

[0082] If the message processing capability is greater than or equal to the preset message processing capability, the target message is transferred from the first database to the second database in the order of time in which it is cached in the first database until the message processing capability of the second database is less than the preset message processing capability.

[0083] Specifically, the message processing capacity of the second database can be detected once every third preset time interval. If the message processing capacity of the second database is less than the preset message processing capacity, the cache time of the target message in each cluster in the first database can be detected every second preset time interval, and the target messages in different clusters whose cache time exceeds the first preset time can be transferred from the first database to the second database respectively. If the message processing capacity of the second database is greater than or equal to the preset message processing capacity, it means that the second database can continue to receive the transfer of persistent data, and the target messages can be transferred from the first database to the second database in the order of time when they are cached in the first database, until the message processing capacity of the second database is less than the preset message processing capacity and the transfer is stopped. This can not only improve the message transfer efficiency, but also avoid system instability caused by high concurrency.

[0084] Among them, the system can detect the cache time of the target message in each cluster in the first database at intervals of the second preset time, and transfer the target messages in different clusters whose cache time exceeds the first preset time from the first database to the second database respectively; on this basis, it can be set to detect the message processing capacity of the second database at intervals of the third preset time, and if the message processing capacity is greater than or equal to the preset message processing capacity, the target message will be transferred from the first database to the second database in the order of the time when it was cached in the first database, until the message processing capacity of the second database is less than the preset message processing capacity.

[0085] For example, the system can detect the cache duration of the target message in each cluster in the first database at intervals of a second preset duration (e.g., 1 hour). If the detection starts at 9:00, the detection will be performed once at 9:00, once at 10:00, once at 11:00, and so on. Based on this, the message processing capacity of the second database can be detected at intervals of a third preset duration (e.g., 1 hour). If the detection starts at 9:30, the detection will be performed once at 9:30, once at 10:30, once at 11:30, and so on. In this way, the message processing capacity detection can be inserted within the time interval of the cache duration detection, thereby improving the transfer efficiency.

[0086] It should be noted that the third preset duration is a time period for determining whether the second database currently has the ability to receive the transferred messages, and this time period can be set as needed. The preset message processing capacity is used to determine whether the second database has reached its message processing capacity limit. If the capacity limit is exceeded, the second database is no longer suitable for receiving transferred messages.

[0087] Specifically, the first database storage of the system can mainly use the following data structures:

[0088] Redis Sorted Set, an ordered queue of the remote dictionary service: can store a user's short-term bell list, that is, cache the target message in real time. Each user can be set to have a separate first keyword key every day, the first member member is the specific content of the bell (that is, the specific content of the target message), and the score score is the trigger timestamp. Here, the key can be defined to include time information (that is, the time when the target message is written to the fast message queue before consumption, or the time when the target message is cached to Redis Sorted Set). When a user is continuously active, some messages can be deleted according to the time information to avoid Redis storing too many messages when a user is continuously active; in addition, the prior art maps the specific content of the bell into a string with a specific meaning in the construction of member, while the embodiment of the present disclosure does not require a mapping relationship, which can save storage space and reduce the number of cache accesses during reading, making it convenient to assemble messages when pulling.

[0089] A Redis Set, a collection of remote dictionary services, stores user state data to be persisted. The second keyword, key, is a hash value derived from user classification. This is used to bucket tasks (i.e., classify target messages into multiple clusters), improving concurrent processing capabilities. The second member, member, is a value related to the user and time. Currently, time can be accurately captured to the hourly level, meaning that within this Redis Set structure, each user can have at most one member per hour. Similarly, the asynchronous persistence period for Redis caches is also set to one hour.

[0090] The second database storage of the system can mainly use the following data structure:

[0091] Pika Hash Map: stores information such as the number of unread messages on the user's bells, the time when the bells were last pulled, etc. Each user has a separate third keyword key, and the third member member contains information on various dimensions (unread message count, time, etc.).

[0092] For example, the system will use distributed locks, start multiple threads to compete with the main thread, and be responsible for traversing the messages to be consumed. After traversing, the messages to be consumed are written to the message queue. After consuming the target messages to be consumed, they are stored in the first database. According to the data structure in the first database (such as redis), the bell data to be persisted can be extracted from the bell list in the first database and written to the second database. This can not only control the speed but also protect the stability of the system. In addition, the message queue is used to ensure the reliability of persistent data. After writing to the second database, it is necessary to check the list length of the second database. If it exceeds the deletion threshold (i.e., the second threshold), it needs to be deleted.

[0093] It should be noted that the settings of the specific contents in the above-mentioned Redis Sorted Set, Redis Set, and Pika Hash Map are only examples and are not limiting.

[0094] Optionally, the user terminal may send a request message for pulling a bell. After receiving the request message, the bell system pulls a bell list from the first database or the second database as needed.

[0095] For example, in this bell system, the second database stores a user's complete historical bell list from an hour ago, while the first database stores the complete bell list for the current day. Therefore, when a user requests a bell list, if it's within the past hour, we directly pull the data from the first database; if it's from an hour ago, we pull the data from the second database. Due to the high timeliness of bells, users rarely request bell information older than an hour. Therefore, we maximize the use of data from the first database, further improving system performance and providing a better user experience.

[0096] To sum up, under the condition of limited storage resources, the above-mentioned embodiment of the present disclosure effectively combines the first database and the second database storage, writes to the cache in real time, persists data asynchronously, and deletes useless bells, which not only maintains the timeliness and stability of the bells, but also minimizes the storage cost. Even in the case of high concurrency or network anomalies, the system can recover quickly and minimize the user's losses.

[0097] As shown in FIG4 , an embodiment of the present disclosure provides a message processing device 400, which includes:

[0098] The processing module 401 is used to obtain a target message and determine the priority of the target message;

[0099] A cache module 402 is configured to cache the target message in a first database according to the priority of the target message;

[0100] The first transfer module 403 is configured to transfer the target message that has been cached in the first database for a period exceeding a first preset period from the first database to the second database.

[0101] In the above-mentioned embodiment of the present disclosure, by obtaining the target message and determining the priority of the target message, the target message is cached in the first database according to the priority of the target message, and if the cache time of the target message in the first database exceeds the first preset time, the target message is transferred from the first database to the second database, which can be written to the cache in real time and can also store persistent data, thereby ensuring system stability and reducing costs while maintaining efficient message processing.

[0102] Optionally, the cache module 402 includes:

[0103] If the target message is a high-priority message, caching the target message in the first database;

[0104] If the target message is a low-priority message, the target message is cached in the first database after secondary consumption.

[0105] Optionally, after caching the target message in the first database, the apparatus further includes:

[0106] A first acquisition module, configured to acquire a first number of target messages cached in the first database;

[0107] The first deletion module is used to delete the target messages in the order of time when they are cached in the first database if the first number exceeds a first threshold, until the first number of target messages cached in the first database is less than or equal to the first threshold.

[0108] Optionally, the cache module 402 includes:

[0109] a classification unit, configured to classify the target messages in the first database into a plurality of clusters;

[0110] A detection unit, configured to detect a cache time of the target message in each cluster in the first database at intervals of a second preset time;

[0111] The transfer unit is used to transfer target messages in different clusters whose cache duration exceeds a first preset duration from the first database to the second database respectively.

[0112] Optionally, after transferring the target message cached in the first database for a period exceeding the first preset period from the first database to the second database, the apparatus further includes:

[0113] A second acquisition module, configured to acquire a second number of target messages cached in the second database;

[0114] The second deletion module is used to delete the target messages in the order of time when they are cached in the second database if the second number exceeds a second threshold, until the second number of target messages cached in the second database is less than or equal to the second threshold.

[0115] Optionally, after caching the target message in the first database according to the priority of the target message, the apparatus further includes:

[0116] A detection module, configured to detect the message processing capability of the second database at intervals of a third preset time length;

[0117] The second transfer module is used to transfer the target message from the first database to the second database in the time order of being cached in the first database if the message processing capacity is greater than or equal to the preset message processing capacity, until the message processing capacity of the second database is less than the preset message processing capacity.

[0118] Optionally, the processing module 401 includes:

[0119] A first acquiring unit is configured to acquire a message to be consumed in a message queue, wherein the message to be consumed is a message written into the message queue by a message producer;

[0120] The second acquiring unit is configured to consume a target message to be consumed among the messages to be consumed, and acquire the target message after consumption.

[0121] To sum up, under the condition of limited storage resources, the above-mentioned embodiment of the present disclosure effectively combines the first database and the second database storage, writes to the cache in real time, persists data asynchronously, and deletes useless bells, which not only maintains the timeliness and stability of the bells, but also minimizes the storage cost. Even in the case of high concurrency or network anomalies, the system can recover quickly and minimize the user's losses.

[0122] It should be noted that the message processing device embodiment is a device corresponding to the above-mentioned message processing method. All implementation methods of the above-mentioned method embodiment are applicable to the device embodiment and can achieve the same technical effects as the above-mentioned method embodiment, which will not be repeated here.

[0123] The present disclosure also provides an electronic device, as shown in FIG5 , including a processor 501 , a communication interface 502 , a memory 503 , and a communication bus 504 , wherein the processor 501 , the communication interface 502 , and the memory 503 communicate with each other via the communication bus 504 .

[0124] The memory 503 is used to store computer programs.

[0125] When the processor 501 is used to execute the program stored in the memory 503, it implements part or all of the steps in a message processing method provided by an embodiment of the present disclosure.

[0126] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.

[0127] The communication interface is used for communication between the above terminal and other devices.

[0128] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.

[0129] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

[0130] In another embodiment provided by the present disclosure, a computer-readable storage medium is further provided. The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the message processing method described in the above embodiment.

[0131] In another embodiment provided by the present disclosure, a computer program product including instructions is further provided, which, when executed on a computer, enables the computer to execute the message processing method described in the above embodiment.

[0132] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0133] The various component embodiments of the present disclosure can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components in the electronic device according to the embodiments of the present disclosure. The present disclosure can also be implemented as a device or apparatus program (e.g., computer program and computer program product) for executing a part or all of the methods described herein. Such a program implementing the present disclosure can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0134] For example, FIG6 shows another electronic device that can implement the method according to the present disclosure. This electronic device conventionally includes a processor 1010 and a computer program product or computer-readable medium in the form of a memory 1020. The memory 1020 can be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. The memory 1020 has a storage space 1030 for program code 1031 for executing any method step in the above method. For example, the storage space 1030 for program code can include individual program codes 1031 for implementing various steps in the above method. These program codes can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards, or floppy disks. Such computer program products are typically portable or fixed storage units as described with reference to FIG7. The storage unit can have storage segments, storage space, etc. arranged similarly to the memory 1020 in the electronic device of FIG6. The program code can be compressed, for example, in a suitable form. Typically, the storage unit includes computer-readable codes 1031 ′, ie, codes that can be read by a processor such as 1010 . When these codes are executed by an electronic device, they cause the electronic device to perform the steps of the method described above.

[0135] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.

[0136] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the scope of protection of the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure are included in the scope of protection of the present disclosure.

Claims

1. A message processing method, characterized in that: The method comprises: Obtaining a target message and determining a priority of the target message; caching the target message in a first database according to the priority of the target message; The target message that has been cached in the first database for a period exceeding a first preset period is transferred from the first database to the second database.

2. The method according to claim 1, characterized in that The step of caching the target message in a first database according to the priority of the target message includes: If the target message is a high-priority message, caching the target message in the first database; If the target message is a low-priority message, the target message is cached in the first database after secondary consumption.

3. The method according to claim 1, characterized in that After caching the target message in the first database, the method further includes: Obtaining a first number of target messages cached in the first database; If the first number exceeds a first threshold, the target messages are deleted in the order of time in which they are cached in the first database until the first number of target messages cached in the first database is less than or equal to the first threshold.

4. The method according to claim 1, wherein The transferring the target message cached in the first database for a period exceeding the first preset period from the first database to the second database includes: classifying the target messages in the first database to form a plurality of clusters; At intervals of a second preset time, detecting a cache time of the target message in each cluster in the first database; Target messages in different clusters that have been cached for longer than a first preset time period are transferred from the first database to the second database respectively.

5. The method according to claim 1, wherein After transferring the target message cached in the first database for a period exceeding the first preset period from the first database to the second database, the method further includes: Obtaining a second number of target messages cached in the second database; If the second number exceeds a second threshold, the target messages are deleted in the order of time in which they are cached in the second database until the second number of target messages cached in the second database is less than or equal to the second threshold.

6. The method according to claim 1, characterized in that After caching the target message in the first database according to the priority of the target message, the method further includes: detecting the message processing capability of the second database at intervals of a third preset time; If the message processing capability is greater than or equal to the preset message processing capability, the target message is transferred from the first database to the second database in the order of time in which it is cached in the first database until the message processing capability of the second database is less than the preset message processing capability.

7. The method according to claim 1, characterized in that The acquiring of the target message includes: Obtaining a message to be consumed in a message queue, wherein the message to be consumed is a message written into the message queue by a message producer; The target message to be consumed in the messages to be consumed is consumed to obtain the target message after consumption.

8. A message processing device, characterized in that: The device comprises: A processing module, configured to obtain a target message and determine a priority of the target message; a cache module, configured to cache the target message in a first database according to the priority of the target message; The first transfer module is configured to transfer target messages that have been cached in the first database for a period exceeding a first preset period from the first database to a second database.

9. An electronic device, characterized in that: include: A processor, a communication interface, a memory, and a communication bus; wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; Memory for storing computer programs; The processor is configured to implement the steps of the message processing method according to any one of claims 1 to 7 when executing the program stored in the memory.

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

11. A computer program product, comprising computer-readable codes, which, when executed on an electronic device, cause the electronic device to execute the message processing method according to any one of claims 1 to 7.