Message processing method and device, platform, computer device and storage medium

CN116893910BActive Publication Date: 2026-11-20SHANGHAI BILIBILI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310891508.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-19
Publication Date
2026-11-20
Estimated Expiration
2043-07-19

AI Technical Summary

Technical Problem

[0004]有鉴于此,现提供一种消息处理方法、装置、平台、计算机设备及存储介质,以解决现有技术在提升消息的吞吐量时,需要对业务系统进行不断的扩展的问题,且扩展的系统会产生数据倾斜的问题

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116893910B_ABST
    Figure CN116893910B_ABST
Patent Text Reader

Abstract

The application discloses a message processing platform, comprising: a producer node configured to generate an event message and send the event message to a target message storage partition corresponding to a type of the event message in a message middleware for storage; an event acquisition module configured to acquire the event message from the target message storage partition; an analysis module configured to analyze the acquired event message to obtain an analysis result and distribute the acquired event message to a corresponding concurrent message storage queue according to the analysis result; each concurrent message storage queue configured to store the event message sent by the analysis module; and each message processing thread configured to acquire the event message from the corresponding concurrent message storage queue and write the acquired event message into a database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technology, and in particular to a message processing method, apparatus, platform, computer equipment, and storage medium. Background Technology

[0002] In high-concurrency business scenarios, to ensure timely processing of business messages, the throughput is often increased by continuously expanding the business system. However, expanding the business system requires significant costs, and even if the system is expanded, data skew can occur due to hotspots within the system.

[0003] Therefore, there is an urgent need to provide a way to improve message throughput and avoid data skew without expanding the business system. Summary of the Invention

[0004] In view of this, a message processing method, apparatus, platform, computer device, and storage medium are provided to solve the problem that existing technologies require continuous expansion of business systems to increase message throughput, and that the expanded systems can cause data skew.

[0005] This application provides a message processing platform, which includes producer nodes and consumer nodes. The consumer node includes a message middleware, an event acquisition module, a parsing module, and a message concurrency processing module. The message middleware includes multiple message storage partitions. The message concurrency processing module includes multiple concurrent message storage queues, multiple message processing threads, a hotspot analysis unit and a hotspot transfer unit, a hotspot queue, and a hotspot thread. Each message processing thread corresponds one-to-one with a concurrent message storage queue, wherein:

[0006] The producer node is used to generate event messages and send the event messages to the target message storage partition in the message middleware corresponding to the type of the event message for storage, according to the type of the event message.

[0007] The event acquisition module is used to acquire event messages from the target message storage partition;

[0008] The parsing module is used to parse the acquired event messages, obtain the parsing results, and distribute the acquired event messages to the corresponding concurrent message storage queues according to the parsing results.

[0009] Each concurrent message storage queue is used to store event messages sent by the parsing module;

[0010] The hotspot analysis unit is used to analyze the event messages stored in each concurrent message storage queue and determine the hot event messages based on the analysis results.

[0011] The hotspot transfer unit is used to transfer the determined hotspot event messages to the hotspot message storage partition in the message middleware;

[0012] The event acquisition module is further configured to acquire hot event messages from the hot event message storage partition and store the hot event messages acquired from the hot event message storage partition into the hot event queue;

[0013] The hotspot thread is used to retrieve hotspot event messages from the hotspot queue and write the hotspot event messages retrieved from the hotspot queue to the database;

[0014] Each message processing thread is responsible for retrieving event messages from the corresponding concurrent message storage queue and writing the retrieved non-hot event messages to the database.

[0015] Optionally, the hotspot analysis unit is also used to analyze the frequency of occurrence and processing time of each event message stored in each concurrent message storage queue, and to determine the hot event messages based on the analysis results.

[0016] Optionally, the message concurrency processing module further includes a redelivery unit, a redelivery queue, and a redelivery thread, wherein:

[0017] The redelivery unit is used to redeliver the failed event message to the redelivery queue when it is detected that the event message has failed to be written to the database.

[0018] The redelivery thread is used to retrieve the event message from the redelivery queue and write the retrieved event message to the database after a preset time has elapsed since the failed event message was redelivered to the redelivery queue.

[0019] Optionally, the consumer node further includes a message processing mode determination module and a message aggregation processing module. The message aggregation processing module includes multiple aggregated message storage queues and multiple message aggregation threads, with each message aggregation thread corresponding one-to-one with an aggregated message storage queue, wherein:

[0020] The message processing mode determination module is used to determine the message processing mode according to preset configuration information. The message processing mode includes concurrent processing mode and aggregate processing mode.

[0021] Each aggregated message storage queue is used to store event messages sent by the parsing module;

[0022] Each message aggregation thread is used to retrieve event messages from the corresponding aggregated message storage queue, perform aggregation processing on the retrieved event messages, and write the aggregated event messages to the database in batches when the number of aggregated event messages reaches a preset number or the aggregation time reaches a preset time.

[0023] Optionally, the producer node is further configured to detect whether the transmission channel between the producer node and the message middleware has failed, and if a failure occurs, to send the generated event message to the event acquisition module.

[0024] Optionally, the message processing platform also includes an acknowledgment character module, wherein:

[0025] The event acquisition module is also used to connect the acquired event messages in an orderly manner through a linked list and add a processing status to each event message;

[0026] The event acquisition module is also used to modify the processing status of the processed event message to "processed" after the event message has been processed.

[0027] The confirmation character module is used to periodically detect the processing status of each event message in the linked list, and when the processing status of all event messages preceding the target event message in the linked list is "processed", the position of the target event message is marked as the confirmation character position.

[0028] This application also provides a message processing method applied to the message processing platform described above, the method comprising:

[0029] Analyze the event messages stored in multiple concurrent message storage queues, and determine the hot event messages based on the analysis results;

[0030] The identified hot event messages are transferred to the hot message storage partition in the message middleware;

[0031] Retrieve hot event messages from the hot event message storage partition and store the hot event messages retrieved from the hot event message storage partition into the hot event queue;

[0032] Retrieve hot event messages from the hot event queue and write the hot event messages retrieved from the hot event queue to the database.

[0033] Optionally, the step of analyzing event messages stored in multiple concurrent message storage queues and determining hot event messages based on the analysis results includes:

[0034] The frequency of occurrence and processing time of each event message stored in each concurrent message storage queue are analyzed to obtain hotspot analysis results;

[0035] Hot topic event messages are determined based on the hot topic analysis results.

[0036] This application also provides a message processing apparatus, including:

[0037] The analysis module is used to analyze event messages stored in multiple concurrent message storage queues and determine hot event messages based on the analysis results.

[0038] The transfer module is used to transfer identified hot event messages to the hot message storage partition in the message middleware;

[0039] The storage module is used to retrieve hot event messages from the hot event message storage partition and store the hot event messages retrieved from the hot event message storage partition into the hot event queue.

[0040] The writing module is used to retrieve hot event messages from the hot event queue and write the hot event messages retrieved from the hot event queue to the database.

[0041] This application also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method.

[0042] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.

[0043] In this embodiment, the message processing platform, while maintaining the original partitions, adds queues to distribute event messages from the same storage partition to different queues upon receipt. Each queue is then bound to an independent processing thread, enabling concurrent processing of event messages and improving message throughput. Furthermore, this embodiment performs real-time analysis of the event messages stored in each queue to identify hot event messages. Once identified, these hot event messages are transferred to a hot event queue, and a hot event thread is simultaneously started to write them to the database. This isolates hot event messages from other event messages, ensuring they are processed correctly and preventing data skew. Attached Figure Description

[0044] Figure 1 This is a schematic diagram illustrating the application environment of an embodiment of the message processing platform of this application.

[0045] Figure 2 This is an architecture diagram of one embodiment of the message processing platform described in this application;

[0046] Figure 3 This is a flowchart of one embodiment of the message processing method described in this application;

[0047] Figure 4 This is a flowchart illustrating the event message processing by the message concurrency processing module of this application;

[0048] Figure 5 This is a flowchart of the event message processing module in this application;

[0049] Figure 6 This is a schematic diagram illustrating the analysis of trending events in this application.

[0050] Figure 7 A flowchart illustrating another embodiment of the message processing method described in this application;

[0051] Figure 8 This is a program block diagram of one embodiment of the message processing apparatus described in this application;

[0052] Figure 9 This is a schematic diagram of the hardware structure of a computer device for executing a message processing method provided in an embodiment of this application. Detailed Implementation

[0053] The advantages of this application are further illustrated below with reference to the accompanying drawings and specific embodiments.

[0054] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0055] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The singular forms “a,” “the,” and “the” used in this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

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

[0057] In the description of this application, it should be understood that the numerical labels before the steps do not indicate the order of the steps, but are only used to facilitate the description of this application and to distinguish each step, and therefore should not be construed as a limitation of this application.

[0058] The following provides an exemplary application environment for this application. Figure 1 The illustration shows an environmental application diagram according to an embodiment of this application.

[0059] The message processing platform 2 includes producer nodes and consumer nodes. The producer nodes generate event messages. The consumer nodes consume the event messages generated by the producer nodes and store them in the database 4.

[0060] Database 4 can be any type of database, such as relational databases like Oracle and MySQL, or non-relational databases like MongoD, Cassandra, Redis, and HBase.

[0061] Message processing platform 2 and database 4 can be connected via a network. The network may include various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, and / or proxy devices. The network may include physical links, such as coaxial cable links, twisted-pair cable links, fiber optic links, and combinations thereof and / or the like. The network may include wireless links, such as cellular links, satellite links, Wi-Fi links, and / or the like.

[0062] The following will provide several embodiments in the above exemplary application environment to illustrate the comment data processing scheme in this application.

[0063] See Figure 2This is an architecture diagram of a message processing platform according to an embodiment of this application. The message processing platform includes a producer node 20 and a consumer node 21. The consumer node 21 includes a message middleware 210, an event acquisition module 211, a parsing module 212, and a message concurrency processing module 212. The message middleware 210 includes multiple message storage partitions. The message concurrency processing module 212 includes multiple concurrent message storage queues 2120, multiple message processing threads 2121, a hotspot analysis unit 2122, a hotspot transfer unit 2123, and a hotspot thread 2124. Each message processing thread 2120 corresponds one-to-one with a concurrent message storage queue 2121.

[0064] Producer node 20, as the producer of event messages, can be various types of devices. For example, it can be a tablet, laptop, desktop computer, rack server, blade server, tower server, or cabinet server (including standalone servers or server clusters composed of multiple servers), etc.

[0065] Producer node 20 is used to generate event messages and send the event messages to the target message storage partition in the message middleware corresponding to the type of the event message for storage, according to the type of the event message.

[0066] Specifically, the event message is a message generated based on a user's behavioral event. For example, the event message can be a like message generated based on a user's like behavior, or a comment message generated based on a user's comment behavior, etc.

[0067] In this embodiment, the event message can be abstracted into the following four types according to the data format:

[0068] 1. SendBytes: Sends a message in byte format;

[0069] 2. SendString: Sends a message of type string.

[0070] 3. SendJSON: Sends a message that is a JSON string.

[0071] 4. SendBatch: Sends byte-type messages in batches.

[0072] Understandably, after the producer node 20 generates an event message, in order to make it easy to write event messages of different data types into the message middleware, it can perform data format conversion on the event message after generating the event message, so as to convert the data format of the event message into the preset data format of the event message.

[0073] The message middleware is a supporting software system that provides synchronous or asynchronous, reliable message transmission for application systems in a network environment, based on queue and message passing technologies. The message middleware can be RabbitMQ, RocketMQ, Kafka, Pulsar, Databus, etc. In this embodiment, Kafka is preferred, and correspondingly, the multiple message storage partitions in the message middleware are multiple topics in the Kafka.

[0074] In one specific implementation, different types of event messages generated by producer node 20 are stored in the message middleware in the target message storage partition corresponding to the type.

[0075] It should be noted that the different types of event messages mentioned above refer to different categories of event messages obtained by classifying the functional types of data objects. For example, the like message and the bullet comment message for video A are two different types of event messages.

[0076] As an example, when the message middleware 210 is Kafka and the message storage partition is a Topic in Kafka, then a like message will be stored in Topic A in Kafka, and a comment message will be stored in Topic B in Kafka.

[0077] Kafka is an open-source stream processing platform developed by the Apache Software Foundation, written in Scala and Java. Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action streams from consumers on a website. These actions (web browsing, searching, and other user actions) are a key element of many social functions on the modern web. A Topic is the name of a category; messages of the same type are sent to the same Topic. Each Topic can have multiple partition log files.

[0078] As an example, when the message middleware 210 is RabbitMQ and the message storage partition is a queue in RabbitMQ, then a like message will be stored in queue A in RabbitMQ, and a comment message will be stored in queue B in RabbitMQ.

[0079] RabbitMQ is an open-source (MPL) message queuing service software, an open-source implementation of the Advanced Message Queuing Protocol (AMQP) provided by LShift, written in Erlang, a language known for its high performance, robustness, and scalability. RabbitMQ handles asynchronous messages from clients. The server places messages to be sent into a queue pool. The receiving end can receive messages from the server according to the forwarding mechanism configured in RabbitMQ. RabbitMQ performs message forwarding, buffering, and persistence operations based on specified forwarding rules.

[0080] The event acquisition module 211 is used to acquire event messages from the target message storage partition.

[0081] Specifically, the target storage partition refers to the storage area where the event message is stored.

[0082] As an example, when the target message storage partition is a target Topic in Kafka, when the event acquisition module 211 retrieves event messages from the target Topic, if the target Topic contains multiple partitions, the event acquisition module 211 will retrieve event messages from multiple partitions within the target Topic. For instance, if the target Topic includes three partitions, the event acquisition module 211 will retrieve event messages from these three partitions.

[0083] As an example, when the target message storage partition is a queue in RabbitMQ, the event acquisition module 211 will retrieve the event messages stored in the target queue.

[0084] The parsing module 212 is used to parse the acquired event messages, obtain the parsing results, and distribute the acquired event messages to the corresponding concurrent message storage queues based on the parsing results.

[0085] Specifically, after the event acquisition module 211 acquires the event message, it calls the parsing module 212 to parse the event message and obtain the parsing result. The parsing result is used to determine which concurrent message storage queue the event message needs to be distributed to.

[0086] In one embodiment, when parsing an event message, the parsing module 212 can determine the parsing method for the event message according to a preset configuration file, and then parse the event message according to the parsing method. For example, if the event message is a video like message, the parsing method for video like messages can be pre-configured in the configuration file to determine the storage queue based on the hash value of the video ID. Thus, when the parsing module 212 parses the like message, it extracts the video ID information from the like message, performs a hash calculation based on the video ID to obtain a hash value, and finally determines the storage queue based on the hash value. For example, when the hash value is 1, the storage queue is determined to be concurrent message storage queue 1; when the hash value is 2, the storage queue is determined to be concurrent message storage queue 2, and so on.

[0087] Each concurrent message storage queue 2120 is used to store event messages sent by the parsing module 212.

[0088] Specifically, after parsing the event messages, the parsing module 212 will distribute each event message to the corresponding concurrent message storage queue 2120 according to different parsing results. In this way, each concurrent message storage queue 2120 can store the event messages that match that concurrent message storage queue.

[0089] It should be noted that the number of concurrent message storage queues 2120 can be set by the user in the configuration information according to the actual situation. When the user needs to increase the message throughput, they only need to increase the number of concurrent message storage queues 2120.

[0090] To facilitate understanding of the concurrent processing flow of event messages obtained from the message middleware by the message concurrency processing module 212 in this application, the following detailed explanation is provided in conjunction with section 4.

[0091] After obtaining event messages from the message middleware (Kafka as an example), the message concurrency processing module will distribute the event messages to different concurrent message storage queues. Figure 4 The memory queue in the memory, and then each message processing thread bound to the concurrent message storage queue ( Figure 4 The Thread in the process will retrieve event messages from it.

[0092] The hotspot analysis unit 2122 is used to analyze the event messages stored in each concurrent message storage queue 2120 and determine the hot event messages based on the analysis results.

[0093] Specifically, when a hot event occurs in the system, such as a large number of users liking the same video, the system will experience severe data skew. To address this issue, this embodiment sets up a hot event analysis unit 2122 in the message processing platform to analyze the event messages stored in each concurrent message storage queue 2120. This allows for the timely detection of hot event messages, enabling subsequent isolation of hot event messages from ordinary event messages and preventing them from affecting the processing of other event messages.

[0094] In one exemplary embodiment, the hotspot analysis unit 2122 is used to analyze the frequency of occurrence and processing time of each event message stored in each concurrent message storage queue, and to determine the hot event messages based on the analysis results.

[0095] Specifically, when analyzing the frequency of occurrence of each event message, the hotspot analysis unit 2122 can do so based on key identifier information in each event message. For example, if the event message is a video like message, then when analyzing the frequency of occurrence of the event message, the number of times like messages with the same video ID appear is counted.

[0096] In one embodiment, when analyzing hot event messages, the hotspot analysis unit 2122 can also determine the frequency of occurrence or processing time of each event message separately.

[0097] The hotspot transfer unit 2123 is used to transfer the determined hotspot event messages to the hotspot message storage partition in the message middleware.

[0098] Specifically, the hotspot message storage partition is a message storage partition used to store hotspot event messages. The hotspot message storage partition can be preset or selected according to the actual situation, and is not limited in this embodiment.

[0099] In this embodiment, after determining which event messages belong to hot event messages, the hotspot analysis unit 2122 can immediately notify the hotspot transfer unit 2123 to transfer the hotspot event messages to the hotspot message storage partition. In one embodiment, the hotspot analysis unit 2122 can also transfer the hotspot event messages to the hotspot message storage partition when a blockage is detected in the concurrent message storage queue.

[0100] In one exemplary embodiment, when transferring determined hot event messages, the hotspot transfer unit 2123 can transfer all hot event messages to the hotspot message storage partition, or it can decide whether to transfer only a portion of the hot event messages to the hotspot message storage partition based on the processing pressure (the amount of resources required for the transfer).

[0101] The event acquisition module 211 is also used to acquire hot event messages from the hot event message storage partition and store the hot event messages acquired from the hot event message storage partition into the hot event queue.

[0102] Specifically, after the hot event messages are transferred, the event acquisition module 211 will promptly transfer the hot event messages to an independent hot event queue to isolate the hot event messages from ordinary event messages and avoid data congestion.

[0103] The hotspot thread 2124 is used to retrieve hotspot event messages from the hotspot queue and write the retrieved hotspot event messages to the database.

[0104] Specifically, after storing the hot event messages in the hot event queue, in order to ensure that the hot event messages can be written to the database in a timely manner, the hot event thread 2124 will be started synchronously to consume the hot event messages from the hot event queue and write the consumed hot event messages to the database.

[0105] Each message processing thread 2121 is used to retrieve event messages from the corresponding concurrent message storage queue and write the retrieved non-hot event messages to the database.

[0106] Specifically, each message processing thread 2121 is bound to a concurrent message storage queue 2120. In this way, each message processing thread 2121 can obtain event messages from its corresponding concurrent message storage queue 2120 and write the obtained non-hot event messages to the database.

[0107] The non-hotspot event messages refer to ordinary event messages.

[0108] In this embodiment, the message processing platform, while maintaining the original partitions, adds queues to distribute event messages from the same storage partition to different queues upon receipt. Each queue is then bound to an independent processing thread, enabling concurrent processing of event messages and improving message throughput. Furthermore, this embodiment performs real-time analysis of the event messages stored in each queue to identify hot event messages. Once identified, these hot event messages are transferred to a hot event queue, and a hot event thread is simultaneously started to write them to the database. This isolates hot event messages from other event messages, ensuring they are processed correctly and preventing data skew.

[0109] In one exemplary embodiment, the message concurrency processing module 212 may further include a redelivery unit, a redelivery queue, and a redelivery thread, wherein:

[0110] The redelivery unit is used to redeliver the failed event message to the redelivery queue when it is detected that the event message has failed to be written to the database.

[0111] Specifically, the redelivery queue is a queue used to store event messages of write failures.

[0112] The redelivery thread is used to retrieve the event message from the redelivery queue and write the retrieved event message to the database after a preset time has elapsed since the failed event message was redelivered to the redelivery queue.

[0113] Specifically, the redelivery thread is a thread used to process the event messages stored in the redelivery queue. The preset time can be pre-set or set and adjusted according to actual conditions, and is not limited in this embodiment. For example, the preset time is 1 minute.

[0114] In this embodiment, when writing an event message to the database fails, the event message is re-delivered, and the re-delivery thread delays the re-writing process for a period of time, thereby maximizing the possibility of writing all event messages to the database.

[0115] In an exemplary embodiment, the consumer node 21 may further include a message processing mode determination module and a message aggregation processing module. The message aggregation processing module includes multiple aggregated message storage queues and multiple message aggregation threads, with each message aggregation thread corresponding one-to-one with an aggregated message storage queue, wherein:

[0116] The message processing mode determination module is used to determine the message processing mode according to preset configuration information. The message processing mode includes concurrent processing mode and aggregate processing mode.

[0117] Specifically, the concurrent processing mode is a mode in which the event message is processed using the message concurrent processing module, and the aggregation processing mode is a mode in which the event message is processed using the message aggregation processing module.

[0118] Each aggregated message storage queue is used to store event messages sent by the parsing module.

[0119] Specifically, the aggregated message storage queue is a queue for storing event messages sent by the parsing module in the aggregated processing mode.

[0120] Each message aggregation thread is used to retrieve event messages from the corresponding aggregated message storage queue, perform aggregation processing on the retrieved event messages, and write the aggregated event messages in batches to the database when the number of aggregated event messages reaches a preset number or the aggregation time reaches a preset time.

[0121] Specifically, the message aggregation thread is a thread responsible for aggregating and processing the event messages stored in the aggregation message storage queue.

[0122] As an example, if the preset quantity is 100 and the preset time is 5 minutes, the message aggregation thread will write the aggregated event messages to the database in batches once when it has aggregated 100 event messages or when the aggregation time reaches 5 minutes.

[0123] In one implementation, when the program closes, the aggregated events can be processed before exiting, and panic protection can be implemented to avoid the possibility of process crash.

[0124] In this embodiment, by adding a message aggregation and processing module, the number of requests to write to the database can be greatly reduced when processing event messages, thereby improving the performance of the message processing platform.

[0125] To facilitate understanding of the aggregation and processing flow of event messages obtained from the message middleware in the message aggregation processing module of this application, the following is combined with... Figure 5 Please provide a detailed explanation.

[0126] After obtaining event messages from the message middleware, the message aggregation processing module parses the event messages and distributes them to different aggregation message storage queues based on the parsing results. Then, each message aggregation thread bound to an aggregation message storage queue retrieves event messages from it and performs aggregation processing on the retrieved event messages. Multiple event messages obtained from the aggregation processing can be placed in one or more data aggregation channels. Finally, when the number of event messages or the aggregation time in each data aggregation channel reaches a preset time, they are written to the database.

[0127] In an exemplary embodiment, the producer node 20 is further configured to detect whether the transmission channel between the producer node 20 and the message middleware has failed, and if a failure occurs, to send the generated event message to the event acquisition module 211.

[0128] Specifically, in order to ensure that event messages generated by producer node 20 can still be processed when the transmission channel between producer node 20 and the message middleware fails, producer node 20 will directly send the generated event messages to event acquisition module 211 through the API interface provided by event acquisition module 211 when it detects a failure in the transmission channel with the message middleware, and use multiple concurrent message storage queues as buffers, thereby ensuring the availability of the message link even when the transmission channel fails.

[0129] In this embodiment, if the transmission channel between the producer node 20 and the message middleware does not fail, the event message will be sent to the target message storage partition in the message middleware corresponding to the type of the event message for storage, according to the type of the event message.

[0130] In this embodiment, when a failure is detected in the transmission channel between the message middleware and the message middleware, the system automatically switches to the HTTP channel, pushes the message directly to the consumer, and places it in the consumer's queue. The system also utilizes an existing multi-level queue as a buffer, thus ensuring the availability of the message link when the main channel fails.

[0131] In one exemplary embodiment, the message processing platform further includes an acknowledgment character (ACK) module, wherein:

[0132] The event acquisition module 211 is also used to connect the acquired event messages in an orderly manner through a linked list and add a processing status to each event message.

[0133] Specifically, in order to maintain the chronological order of the various event messages, the event acquisition module 211 will link the acquired event messages in a linked list according to their generation time, forming the following linked list:

[0134] Event message 1 -> Event message 2 -> Event message 3 -> ... -> Event message N-1 -> Event message N.

[0135] It should be noted that the event message N was generated later than the event N-1.

[0136] The processing status indicates whether the event message has been processed, that is, whether the event message has been successfully written to the database.

[0137] In one embodiment, the processing state may include four states: unprocessed, processing, processed, and processing failed.

[0138] The event acquisition module 211 is also used to modify the processing status of the processed event message to "processed" after the event message has been processed.

[0139] Specifically, after detecting that an event message has been successfully processed, the event acquisition module 211 promptly marks the event message as processed so that it can determine whether each event message has been processed based on the processing status.

[0140] The acknowledgment character module is used to periodically detect the processing status of each event message in the linked list, and when the processing status of all event messages preceding the target event message in the linked list is "processed", the position of the target event message is marked as the acknowledgment character (ACK) position.

[0141] Specifically, the character position (ACK) position is used to record the offset address of the event message successfully retrieved from the message storage partition. This ACK position is used to recover data in the event of a failure.

[0142] In this embodiment, the problem of event loss is solved by linking event messages in an orderly manner using a linked list and adding a processing mark to each event message. When a message is processed, it is marked as processed. The linked list status is checked periodically. Only after all the events before a certain message have been processed is the message set to the acknowledgment character status.

[0143] To facilitate understanding of the event message processing flow of the message processing platform in this application, the following detailed explanation is provided in conjunction with section 7.

[0144] Once an event message is retrieved from the message broker, and the concurrent processing mode for the event message is determined, the event message will be distributed to different queues. Figure 7 In memory queues 1 through N, the process will then be handled by the thread bound to the queue. Figure 7 Threads 1-N retrieve event messages from their respective queues. Furthermore, when a hot event message is detected in a queue, it is transferred to a hot event queue. If writing an event message to the database fails, it is written to a retry queue for re-delivery. When the event message processing mode is determined to be aggregation processing mode, the event messages stored in the queue are aggregated, and after a certain number of aggregations or a certain time interval, the aggregated event messages are processed in batches by threads.

[0145] In one exemplary implementation, see [reference] Figure 3 The method includes:

[0146] Step S30: Analyze the event messages stored in multiple concurrent message storage queues, and determine the hot event messages based on the analysis results;

[0147] In one exemplary embodiment, analyzing event messages stored in multiple concurrent message storage queues and determining hot event messages based on the analysis results includes: analyzing the frequency of occurrence and processing time of each event message stored in each concurrent message storage queue, and determining hot event messages based on the analysis results.

[0148] In a specific scenario, refer to Figure 5 When identifying hot event messages, the system uses key identifier information (such as the key in 5) in each event message to count the number of occurrences and processing time of each event message stored in the concurrent message storage queue. This yields the total number of occurrences and total processing time for each message event. Based on this statistical information, the hot event messages can then be identified.

[0149] Step S31: Transfer the identified hot event messages to the hot message storage partition in the message middleware;

[0150] Step S32: Obtain hot event messages from the hot event message storage partition and store the hot event messages obtained from the hot event message storage partition into the hot event queue;

[0151] Step S33: Obtain hot event messages from the hotspot queue and write the hot event messages obtained from the hotspot queue to the database.

[0152] In one exemplary embodiment, the method further includes:

[0153] When an event message fails to be written to the database, the failed event message is re-delivered to the re-delivery queue.

[0154] After a preset time has elapsed since the failed event message was redelivered to the redelivery queue, the event message is retrieved from the redelivery queue and written to the database.

[0155] In one exemplary embodiment, the method further includes:

[0156] Retrieve event messages from the concurrent message storage queue;

[0157] The acquired event messages are aggregated. When the number of aggregated event messages reaches a preset number or the aggregation time reaches a preset time, the aggregated event messages are written to the database in batches.

[0158] Specifically, in order to reduce the number of requests to write to the database and improve the performance of the message processing platform, when writing event messages stored in the concurrent message storage queue to the database, a separate thread can be used to handle event aggregation. After a certain number or time has been accumulated, the events are packaged in batches and the database is updated all at once.

[0159] See Figure 8 The diagram shown is a program block diagram of an embodiment of the message processing apparatus 50 of this application.

[0160] In this embodiment, the message processing device 50 includes a series of computer program instructions stored in a memory. When these computer program instructions are executed by a processor, the shooting functions of the various embodiments of this application can be implemented. In some embodiments, based on the specific operations implemented by each part of the computer program instructions, the message processing device 50 can be divided into one or more modules. Specifically, the modules that can be divided are as follows:

[0161] Analysis module 51 is used to analyze event messages stored in multiple concurrent message storage queues and determine hot event messages based on the analysis results;

[0162] The transfer module 52 is used to transfer the determined hot event messages to the hot message storage partition in the message middleware;

[0163] Storage module 53 is used to retrieve hot event messages from the hot event message storage partition and store the hot event messages retrieved from the hot event message storage partition into the hot event queue;

[0164] The writing module 54 is used to obtain hot event messages from the hot event queue and write the hot event messages obtained from the hot event queue to the database.

[0165] In one exemplary embodiment, the analysis module 51 is further configured to analyze the frequency of occurrence and processing time of each event message stored in each concurrent message storage queue, and determine hot event messages based on the analysis results.

[0166] Figure 9 This illustration schematically depicts a hardware architecture diagram of a computer device 6 suitable for implementing a message processing method according to an embodiment of this application. In this embodiment, the computer device 6 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. For example, it may be a tablet computer, laptop computer, desktop computer, rack server, blade server, tower server, or cabinet server (including independent servers or server clusters composed of multiple servers), etc. Figure 9As shown, computer device 6 includes, but is not limited to: a memory 120, a processor 121, and a network interface 122 that can communicate with each other via a system bus. Wherein:

[0167] The memory 120 includes at least one type of computer-readable storage medium, which can be volatile or non-volatile. Specifically, the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 120 may be an internal storage module of the computer device 6, such as the hard disk or memory of the computer device 6. In other embodiments, the memory 120 may also be an external storage device of the computer device 6, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device 6. Of course, the memory 120 may also include both the internal storage module and the external storage device of the computer device 6. In this embodiment, the memory 120 is typically used to store the operating system and various application software installed on the computer device 6, such as program code for message processing methods. Furthermore, the memory 120 can also be used to temporarily store various types of data that have been output or will be output.

[0168] In some embodiments, processor 121 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other imaging chip. This processor 121 is typically used to control the overall operation of the computer device 6, such as performing control and processing related to data interaction or communication with the computer device 6. In this embodiment, processor 121 is used to run program code stored in memory 120 or process data.

[0169] Network interface 122 may include a wireless network interface or a wired network interface, which is typically used to establish a communication link between computer device 6 and other computer devices. For example, network interface 122 is used to connect computer device 6 to an external terminal via a network, establishing a data transmission channel and communication link between computer device 6 and the external terminal. The network may be an intranet, the Internet, Global System for Mobile Communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, or other wireless or wired networks.

[0170] It should be pointed out that, Figure 9 Only computer devices with components 120 to 122 are shown; however, it should be understood that it is not required to implement all of the shown components, and more or fewer components may be implemented instead.

[0171] In this embodiment, the message processing method stored in memory 120 can be divided into one or more program modules and executed by one or more processors (processor 121 in this embodiment) to complete this application.

[0172] This application provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the message processing method in the embodiment.

[0173] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as the hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device. Of course, the computer-readable storage medium can also include both the internal storage unit and the external storage device of the computer device. In this embodiment, the computer-readable storage medium is typically used to store the operating system and various application software installed on the computer device, such as the program code of the message processing method in the embodiment. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or will be output.

[0174] 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; that is, they may be located in one place or distributed across at least two network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of this application. Those skilled in the art can understand and implement this without any creative effort.

[0175] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0176] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A message processing platform, the message processing platform comprising producer nodes and consumer nodes, characterized in that, The consumer node includes a message middleware, an event acquisition module, a parsing module, and a message concurrency processing module. The message middleware includes multiple message storage partitions. The message concurrency processing module includes multiple concurrent message storage queues, multiple message processing threads, a hotspot analysis unit and a hotspot transfer unit, a hotspot queue, and a hotspot thread. Each message processing thread corresponds one-to-one with a concurrent message storage queue, wherein: The producer node is used to generate event messages and send the event messages to the target message storage partition in the message middleware corresponding to the type of the event message for storage, according to the type of the event message. The event acquisition module is used to acquire event messages from the target message storage partition; The parsing module is used to parse the acquired event messages, obtain the parsing results, and distribute the acquired event messages to the corresponding concurrent message storage queues according to the parsing results. Each concurrent message storage queue is used to store event messages sent by the parsing module; The hotspot analysis unit is used to analyze the event messages stored in each concurrent message storage queue and determine the hot event messages based on the analysis results. The hotspot transfer unit is used to transfer the determined hotspot event messages to the hotspot message storage partition in the message middleware; The event acquisition module is further configured to acquire hot event messages from the hot event message storage partition and store the hot event messages acquired from the hot event message storage partition into the hot event queue; The hotspot thread is used to retrieve hotspot event messages from the hotspot queue and write the hotspot event messages retrieved from the hotspot queue to the database; Each message processing thread is responsible for retrieving event messages from the corresponding concurrent message storage queue and writing the retrieved non-hot event messages to the database.

2. The message processing platform according to claim 1, characterized in that, The hotspot analysis unit is also used to analyze the frequency of occurrence and processing time of each event message stored in each concurrent message storage queue, and to determine the hotspot event messages based on the analysis results.

3. The message processing platform according to claim 1, characterized in that, The message concurrency processing module further includes a redelivery unit, a redelivery queue, and a redelivery thread, wherein: The redelivery unit is used to redeliver the failed event message to the redelivery queue when it is detected that the event message has failed to be written to the database. The redelivery thread is used to retrieve the event message from the redelivery queue and write the retrieved event message to the database after a preset time has elapsed since the failed event message was redelivered to the redelivery queue.

4. The message processing platform according to any one of claims 1 to 3, characterized in that, The consumer node also includes a message processing mode determination module and a message aggregation processing module. The message aggregation processing module includes multiple aggregated message storage queues and multiple message aggregation threads, with each message aggregation thread corresponding one-to-one with an aggregated message storage queue. The message processing mode determination module is used to determine the message processing mode according to preset configuration information. The message processing mode includes concurrent processing mode and aggregate processing mode. Each aggregated message storage queue is used to store event messages sent by the parsing module; Each message aggregation thread is used to retrieve event messages from the corresponding aggregated message storage queue, perform aggregation processing on the retrieved event messages, and write the aggregated event messages to the database in batches when the number of aggregated event messages reaches a preset number or the aggregation time reaches a preset time.

5. The message processing platform according to claim 1, characterized in that, The producer node is also used to detect whether the transmission channel between the producer node and the message middleware is faulty. If a fault occurs, the generated event message is sent to the event acquisition module.

6. The message processing platform according to claim 5, characterized in that, The message processing platform also includes an acknowledgment character module, in which: The event acquisition module is also used to connect the acquired event messages in an orderly manner through a linked list and add a processing status to each event message; The event acquisition module is also used to modify the processing status of the processed event message to "processed" after the event message has been processed. The confirmation character module is used to periodically detect the processing status of each event message in the linked list, and when the processing status of all event messages preceding the target event message in the linked list is "processed", the position of the target event message is marked as the confirmation character position.

7. A message processing method, applied in the message processing platform according to any one of claims 1 to 6, characterized in that, The method includes: Analyze the event messages stored in multiple concurrent message storage queues, and determine the hot event messages based on the analysis results; The identified hot event messages are transferred to the hot message storage partition in the message middleware; Retrieve hot event messages from the hot event message storage partition and store the hot event messages retrieved from the hot event message storage partition into the hot event queue; Retrieve hot event messages from the hot event queue and write the hot event messages retrieved from the hot event queue to the database.

8. The message processing method according to claim 7, characterized in that, The analysis of event messages stored in multiple concurrent message storage queues, and the determination of hot event messages based on the analysis results, includes: The frequency of occurrence and processing time of each event message stored in each concurrent message storage queue are analyzed to obtain hotspot analysis results; Hot topic event messages are determined based on the hot topic analysis results.

9. A message processing device, characterized in that, For performing the message processing method according to any one of claims 7 to 8, comprising: The analysis module is used to analyze event messages stored in multiple concurrent message storage queues and determine hot event messages based on the analysis results. The transfer module is used to transfer identified hot event messages to the hot message storage partition in the message middleware; The storage module is used to retrieve hot event messages from the hot event message storage partition and store the hot event messages retrieved from the hot event message storage partition into the hot event queue. The writing module is used to retrieve hot event messages from the hot event queue and write the hot event messages retrieved from the hot event queue to the database.

10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method of claim 7 or 8.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the steps of the method of claim 7 or 8.

12. A computer program product comprising computer instructions, characterized in that, When executed by a processor, the computer instructions implement the steps of the method described in claim 7 or 8.

Citation Information

Patent Citations

  • Distributed event bus processing method based on message queue, terminal and medium

    CN112527525A

  • Hotspot data processing method and device, computer equipment and storage medium

    CN115757492A