A message processing method, apparatus, and electronic device

By using a message broker cluster to share message queues and a lightweight addressing mechanism, the high availability and performance issues of message management in the telecommunications billing field in existing technologies are solved, achieving efficient message processing and system stability.

CN116668529BActive Publication Date: 2026-03-06LINKAGE TECHNOLOGY (NANJING) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-21
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

In existing technologies, message management solutions in the telecommunications billing field rely on the master-agent model, which makes the communication capabilities of processes on the host dependent on a single point of service, unable to guarantee high availability, and the number of topics in the message queue is insufficient, resulting in wasted traffic and decreased processing performance.

Method used

By adopting a message broker cluster mechanism, message brokers share a message queue. Any message broker can retrieve messages from the queue and determine the corresponding business process, achieving lightweight addressing and high-performance message management. This avoids single points of failure and improves the system's high availability and processing efficiency.

Benefits of technology

It achieves message management for millions of processes, reduces the number of message classification channels, improves high-performance management of message links, and ensures high availability and processing efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116668529B_ABST
    Figure CN116668529B_ABST
Patent Text Reader

Abstract

This application provides a message processing method, apparatus, and electronic device, comprising: a message broker cluster obtaining a first message of a first topic from a message queue, the first message being sent to the message queue by a business control terminal, the message broker cluster including at least one message broker; determining that the first message corresponds to a first business process connected to the first message broker, the first business process being a task process connected to the first message broker in the message broker cluster; and controlling the first message broker to send the first message to the first business process in response.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information technology, and more specifically, to a message processing method, apparatus, and electronic device. Background Technology

[0002] Messaging systems are widely used in the field of distributed computing. After a business application is running, it needs to exchange information with other related business applications. The flow path control and distribution mode of information are generally implemented using topic-based message queues.

[0003] In the telecommunications billing field, many business processes require external business instructions during operation, such as shared memory data updates and temporary task triggering. Due to the massive amount of user data in telecommunications billing, business processes need to be organized using a fragmented batch processing approach. When transmitting these instructions, process-level differentiation is necessary to ensure accurate delivery to the target process. In this scenario, the number of topics in a typical message queue publish-subscribe approach is insufficient, and broadcast mode also results in significant bandwidth waste and impacts processing performance.

[0004] In existing technologies, the message management scheme adopted is a master-agent (management-agent) model with agent layering. Each host deploys an agent process to handle messages for all local business processes, while a separate management process, the master, aggregates the agent's proxy information for global message management.

[0005] like Figure 1 The diagram illustrating the message management scheme includes: administrator (admin), users (users), management process (master), and agent processes 1-4. All agent processes establish network connections with the master process. When messages need to be transmitted, the upper-level system administrator / user transmits the message to the master process via an HTTP / HTTPS interface. The master forwards the message to the agent, and the agent locates the business process on its own host to forward the message. Conversely, messages flow in reverse. For multiple hosts to exchange messages, they must first send the message to the master through an agent, and then the message is forwarded to the agent on the target host.

[0006] With this message management scheme, the communication capabilities of processes on the host depend on the local agent process as a single point of service, which makes it impossible to guarantee the high availability of the host. Summary of the Invention

[0007] In view of the above, this application provides a message processing method, apparatus, and electronic device, as follows:

[0008] A message processing method, comprising:

[0009] The message broker cluster obtains the first message of the first topic from the message queue. The first message is sent to the message queue by the business control terminal. The message broker cluster includes at least one message broker.

[0010] It is determined that the first message corresponds to the first business process connected to the first message broker, and the first business process is the task process connected to the first message broker in the message broker cluster;

[0011] The first message broker is controlled to send the first message to the first business process in response.

[0012] Optionally, the above methods also include:

[0013] Retrieve the second message of the second topic from the message queue. The second message is a heartbeat packet initiated by any message broker.

[0014] Analyze the second message to obtain the number of message brokers in the message broker cluster that are running;

[0015] Based on the fact that the number of running message brokers meets the preset number condition, the message broker cluster is executed to obtain the first message of the first topic from the message queue;

[0016] An alarm message is generated if the number of running message brokers does not meet the preset limit.

[0017] Optionally, the above method, after obtaining the second message of the second topic from the message queue, further includes:

[0018] Analyze the second message to obtain the address information of the message broker;

[0019] A first connection request is initiated to the message broker based on the address information;

[0020] Based on the connection confirmation information received from the message broker, a message broker cluster is constructed with the message broker.

[0021] Optionally, the above method, before obtaining the first message of the first topic from the message queue, further includes:

[0022] Obtain business process information uploaded by any message broker in the message broker cluster;

[0023] The connection list of the message broker cluster is updated based on the task process information. The connection list includes the correspondence between message brokers and business processes.

[0024] Optionally, in the above method, determining that the first message corresponds to the first business process of the first message broker connection includes:

[0025] Analyze the first message to obtain the first business process corresponding to the first message;

[0026] Based on the connection list, it is determined that the first service process corresponds to the first message broker.

[0027] Optionally, the above methods also include:

[0028] Receive the second connection request from the second business process;

[0029] Analyzing the connection list yields the message brokers contained in the message broker cluster;

[0030] A second message broker that meets the preset connection conditions is determined from the message brokers included in the message broker cluster;

[0031] Control the second message broker to accept the second business process, so that the second business process obtains messages from the message queue through the second message broker.

[0032] Optionally, in the above method, determining the second message broker that meets the preset connection conditions among the message brokers included in the message broker cluster includes:

[0033] Analyzing the connection list yields the number of business processes connected to each message broker in the message broker cluster.

[0034] Retrieve the process connection quota for each message broker in the message broker cluster;

[0035] Based on the number of business processes connected to each message broker in the message broker cluster and the process connection quota, a second message broker that meets the preset connection conditions is determined.

[0036] Optionally, the above methods also include:

[0037] By analyzing the connection list, the number of business processes connected to each message broker in the message broker cluster can be obtained;

[0038] Based on the condition that the number of business processes connected to at least two message brokers in the message broker cluster is unbalanced, the at least two message brokers are controlled to disconnect at least one business process in order to retain a preset number of business processes connected.

[0039] Receive a second connection request corresponding to a third business process, wherein the third business process is a business process that has been disconnected from the message broker;

[0040] Based on the number of business processes connected to each message broker in the message broker cluster, a third message broker is determined to respond to the second connection request and connect to the third business process, so that the number of business processes connected to the message broker in the message broker cluster does not meet the imbalance condition.

[0041] A message processing apparatus, comprising:

[0042] The module is used to obtain the first message of the first topic from the message queue. The first message is sent to the message queue by the business control terminal. The message broker cluster includes at least one message broker.

[0043] The determination module is used to determine that the first message corresponds to the first business process connected to the first message broker, and the first business process is the task process connected to the first message broker in the message broker cluster;

[0044] The control module is used to control the first message broker to send the first message to the first business process response.

[0045] An electronic device, comprising:

[0046] Memory, processor;

[0047] The memory stores the processing program;

[0048] The processor is used to load and execute the processing program stored in the memory to implement the steps of the message processing method as described in any of the preceding claims.

[0049] In summary, this application provides a message processing method, apparatus, and electronic device, comprising: a message broker cluster obtaining a first message of a first topic from a message queue, the first message being sent to the message queue by a business control terminal, the message broker cluster including at least one message broker; determining that the first message corresponds to a first business process connected to a first message broker, the first business process being a task process connected to the first message broker in the message broker cluster; and controlling the first message broker to send the first message to the first business process in response. In this embodiment, since the message brokers in the message broker cluster share messages in the message queue, any message broker obtaining the first message from the message queue and determining the first business process connected to its corresponding first message broker will control the first message broker to send the first message to the first business process connected to it in response. Lightweight addressing of business process connections is achieved through the interconnection of local process routing and message forwarding via a message broker cluster acting as middleware. Only a limited number of message classification channels are needed to achieve message management for millions of processes, enabling high-performance management of message links for a large number of stateful business processes. Attached Figure Description

[0050] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0051] Figure 1 This is a schematic diagram of a message management scheme in the prior art;

[0052] Figure 2 This is a flowchart of an embodiment 1 of a message processing method provided in this application;

[0053] Figure 3 This is a schematic diagram of a message broker cluster in Embodiment 1 of a message processing method provided in this application;

[0054] Figure 4 This is a flowchart of a message processing method embodiment 2 provided in this application;

[0055] Figure 5 This is a flowchart of an embodiment 3 of a message processing method provided in this application;

[0056] Figure 6 This is a flowchart of embodiment 4 of the message processing method provided in this application;

[0057] Figure 7 This is a flowchart of embodiment 5 of the message processing method provided in this application;

[0058] Figure 8 This is a flowchart of embodiment 6 of a message processing method provided in this application;

[0059] Figure 9 This is a flowchart of embodiment 7 of a message processing method provided in this application;

[0060] Figure 10 This is a schematic diagram of the structure of an embodiment of a message processing device provided in this application. Detailed Implementation

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

[0062] like Figure 2The diagram shown is a flowchart of an embodiment 1 of a message processing method provided in this application. The method is applied to an electronic device that runs any message broker in a message broker cluster. The method includes the following steps:

[0063] Step S201: The message broker cluster obtains the first message of the first topic from the message queue;

[0064] The first message is sent from the business control terminal to the message queue, and the message broker cluster includes at least one message broker.

[0065] A message broker cluster includes one or more message brokers.

[0066] Specifically, if a system contains multiple business hosts, the message broker can be set on each business host. Any number of brokers can be deployed, and it is not necessary to deploy it on every single host. Typically, it is distributed across different business hosts. The purpose of this distribution is to ensure that the failure of any business host does not affect the operation of the system.

[0067] In practice, a message broker cluster set up in a system contains 5-10 message brokers.

[0068] In this message broker cluster, message brokers share messages in the message queue, with no distinction between master and agent nodes.

[0069] The business control terminal sends messages to the message queue through the corresponding business process.

[0070] The message in the first topic is an external business message, specifically a message generated by the business control end, and is unrelated to the message broker itself.

[0071] For example, messages in the first topic are collectively referred to as external business messages, which can be further divided into messages in more specific topics, such as call charges and points statements.

[0072] The message queue contains messages on various topics, specifically first-topic messages generated by the business control terminal and second-topic messages generated by the message broker in the message broker cluster.

[0073] It should be noted that the messages of the second topic will be described in subsequent embodiments, and will not be detailed in this embodiment.

[0074] In this context, any message broker in the message broker cluster can retrieve a message from the message queue, and once a message is retrieved by a message broker, that message will no longer exist in the message queue. Consequently, other message brokers cannot retrieve the same message from the message queue.

[0075] Step S202: Determine that the first message corresponds to the first service process connected to the first message broker;

[0076] Among them, the business process is a process that may be started on each business host. They establish connections with any message broker process and register their identities.

[0077] The first business process is the task process connected to the first message broker in the message broker cluster.

[0078] It should be noted that the message broker is the server side, while the business processes belong to the client side. Each message broker instance will have a large number of business processes connected to it, establishing TCP (Transmission Control Protocol) long connections.

[0079] Since message brokers in the message broker cluster share information, the first message can be obtained by any message broker in the message broker cluster.

[0080] Accordingly, the message broker can determine the corresponding first business process based on the information carried in the first message. If the first business process is connected to the first message broker, then the first message corresponds to the first business process connected to the first message broker.

[0081] Step S203: Control the first message broker to send the first message to the first business process response.

[0082] Once it is determined that the first message is to be processed by the first business process, the first message broker that controls the connection to the first business process sends the first message to the first business process in response to the first message.

[0083] If the first message is obtained by the first message broker, the first message processor directly sends the first message to the first business process; if the first message is obtained by another message broker besides the first message broker, the first message is sent to the first message broker, and then the first message broker sends the first message to the first business process.

[0084] like Figure 3 The diagram shows a message broker cluster, which includes three message brokers 301-303. Message broker 302 is connected to business process 304, and message broker 303 is connected to business process 305. Message broker 301 obtains a business message (first message) from the message queue and synchronizes the business message to message broker 302, which then processes the first message.

[0085] It should be noted that, since the message broker set adds the ability to relay messages during the publish-subscribe process of the message queue, it can receive external messages by accessing the message queue and achieve lightweight addressing of business process connections through the message broker cluster as a middleware to communicate local process routing and message forwarding. Therefore, only a limited number of message classification channels are needed to achieve message management of millions of processes and high-performance management of message links of a large number of stateful business processes.

[0086] In summary, this embodiment provides a message processing method comprising: a message broker cluster obtaining a first message of a first topic from a message queue, wherein the first message is sent to the message queue by a business control terminal, and the message broker cluster includes at least one message broker; determining that the first message corresponds to a first business process connected to a first message broker, wherein the first business process is a task process connected to the first message broker in the message broker cluster; and controlling the first message broker to send the first message to the first business process in response. In this embodiment, since the message brokers in the message broker cluster share messages in the message queue, any message broker obtaining the first message from the message queue and determining that its corresponding first message broker is connected to the first business process will control the first message broker to send the first message to the first business process connected to it in response. By using a message broker cluster as middleware to interconnect local process routing and message forwarding, lightweight addressing of business process connections is achieved. Only a limited number of message classification channels are needed to achieve message management of millions of processes, enabling high-performance management of message links for a large number of stateful business processes.

[0087] like Figure 4 The diagram shown is a flowchart of an embodiment 2 of a message processing method provided in this application. The method includes the following steps:

[0088] Step S401: Retrieve the second message of the second topic from the message queue;

[0089] The second message is a heartbeat packet initiated by any message broker.

[0090] In this process, each message broker in the message broker cluster uploads a heartbeat packet to the message queue, which is then placed into the message queue as a message with a second topic.

[0091] In practice, the message broker uploads a heartbeat packet at an agreed-upon period, and the heartbeat packet contains relevant information about the message broker.

[0092] Each message broker retrieves the second message from the message queue and subscribes to the heartbeats of other message brokers. After a message broker subscribes to the heartbeats of other message brokers, the other message broker uploads the second message and pushes the second message to the message broker.

[0093] Step S402: Analyze the second message to obtain the number of message brokers in the message broker cluster that are in running state;

[0094] If the number of running message brokers meets the preset number condition, proceed to steps S403-405; otherwise, proceed to step S406.

[0095] The second message obtained by each message broker from the message queue is uploaded by each message broker in the message broker cluster.

[0096] In practice, the number of message brokers in the message broker cluster that are running can be analyzed according to the agreed period.

[0097] Specifically, analyzing the second message can determine which message broker generated it. If the message broker can generate a heartbeat packet, it indicates that the message broker is running. If no second message is received from a certain message broker within one or several cycles, it is determined that the message broker has crashed and is no longer running.

[0098] It should be noted that since all business processes in the message broker cluster can connect through any message broker, as long as there is one message broker instance for storage, all business processes can be guaranteed to connect.

[0099] The message broker cluster uses a distributed deployment approach, and the number of message brokers can be arbitrary, with any number deployed on each host (including 0).

[0100] The preset number condition can be non-zero, such as from 1 to any number.

[0101] If there are at least one message broker in the running state, steps S403-405 can be executed to process the first message in the message queue; if there are zero message brokers in the running state, the first message in the message queue cannot be processed, and step S406 is executed.

[0102] Step S403: Based on the fact that the number of message brokers in the running state meets the preset number condition, the message broker cluster obtains the first message of the first topic from the message queue;

[0103] Step S404: Determine that the first message corresponds to the first service process connected to the first message broker;

[0104] Step S405: Control the first message broker to send the first message to the first business process in response;

[0105] Steps S403-405 are the same as the corresponding steps in Example 1, and will not be repeated in this example.

[0106] Step S406: Generate an alarm message based on the fact that the number of message brokers in operation does not meet the preset number condition.

[0107] If the number of running message brokers does not meet the preset limit, specifically if there are no running message brokers in the message broker set, then the first message in the message queue cannot be processed, and an alarm message cannot be generated to notify the user that no message broker is alive and needs maintenance.

[0108] In summary, the message processing method provided in this embodiment further includes: obtaining a second message on a second topic from a message queue, wherein the second message is a heartbeat packet initiated by any message broker; analyzing the second message to obtain the number of message brokers in the message broker cluster that are running; based on the number of message brokers in the running state meeting a preset number condition, executing the step of the message broker cluster obtaining a first message on a first topic from the message queue; and generating an alarm message based on the number of message brokers in the running state not meeting the preset number condition. In this embodiment, the message brokers initiate heartbeat packets as the second message and place them in the message queue, so that each message broker can determine the number of message brokers in the current message broker cluster that are running, thereby ensuring that there are message brokers alive in the message broker cluster, ensuring that the business process can maintain a connection, and providing a foundation for ensuring the business process.

[0109] like Figure 5 The diagram shown is a flowchart of an embodiment 3 of a message processing method provided in this application. The method includes the following steps:

[0110] Step S501: Obtain the second message of the second topic from the message queue;

[0111] Step S501 is the same as the corresponding step in Example 2, and will not be described again in this example.

[0112] Step S502: Analyze the second message to obtain the address information of the message broker;

[0113] It should be noted that this embodiment describes the process of building a message broker cluster, which is generally performed when the system creates or creates a new message broker.

[0114] In this process, the message broker initiates a heartbeat packet and places it into the message queue as the second message of the second topic.

[0115] The second message contains the address information of the node where the message broker is located.

[0116] Specifically, this address information includes IP (Internet Protocol) address, port, etc.

[0117] Specifically, any message broker capable of reading the message queue obtains the second message from the message queue, analyzes the second message, and obtains the address information of the message broker.

[0118] If the message broker that sent the heartbeat packet is not yet a member of the message broker cluster, and the message broker that received the second message has not subscribed to the heartbeat of the message broker, then the message broker that sent the heartbeat packet needs to be added to the message broker cluster.

[0119] Step S503: Initiate a first connection request to the message broker based on the address information;

[0120] Specifically, based on the address information, a first connection request is initiated to the address corresponding to the address information in order to request the establishment of a connection with the message broker.

[0121] Specifically, the first connection request is used to request the establishment of a long connection with the message broker.

[0122] Step S504: Based on the connection confirmation information received from the message broker, construct a message broker cluster with the message broker;

[0123] When the message broker that sends the heartbeat packet receives the first connection request, it can send back a connection confirmation message to establish a connection with the message broker that initiated the first connection request, thus realizing the process of building a message broker cluster with the message broker.

[0124] The constructed message broker cluster is an interconnected network composed of various message brokers.

[0125] Accordingly, in subsequent steps, if a message broker different from the first message broker obtains the first message, it will forward the first message to the first message broker through the long connection between the message broker and the first message broker.

[0126] Step S505: Analyze the second message to obtain the number of message brokers in the message broker cluster that are running;

[0127] If the number of message brokers in operation meets the preset number condition, proceed to steps S506-508; otherwise, proceed to step S509.

[0128] Step S506: Based on the fact that the number of message brokers in the running state meets the preset number condition, the message broker cluster obtains the first message of the first topic from the message queue;

[0129] Step S507: Determine that the first message corresponds to the first service process connected to the first message broker;

[0130] Step S508: Control the first message broker to send the first message to the first business process in response;

[0131] Step S509: Generate an alarm message based on the fact that the number of message brokers in operation does not meet the preset number condition.

[0132] Steps S505-509 are the same as the corresponding steps in Example 2, and will not be repeated in this example.

[0133] In summary, the message processing method provided in this embodiment further includes: analyzing the second message to obtain the address information of the message broker; initiating a first connection request to the message broker based on the address information; and constructing a message broker cluster with the message broker based on the connection confirmation information received from the message broker. In this embodiment, the address information of the message broker is determined based on the second message sent by the message broker, and then a first connection request is initiated to the message broker based on the address information to construct a message broker cluster with the message broker, providing a network foundation for subsequent forwarding of the first message between message brokers.

[0134] like Figure 6 The diagram shown is a flowchart of embodiment 4 of a message processing method provided in this application. The method includes the following steps:

[0135] Step S601: Obtain the business process information uploaded by any message broker in the message broker cluster;

[0136] In this message broker cluster, each message broker uses its connection task process information as the same topic and adds that task process information as a message to the message queue.

[0137] The task processes connected in each message broker are counted as a process connection table, which is then uploaded to the message queue as business process information.

[0138] Among them, the message broker in the message broker cluster can obtain business process information uploaded by any message broker from this message queue.

[0139] One message broker obtains the business process information under this topic and subscribes to this business process information. Subsequently, task process information uploaded by other message brokers will be pushed to this message broker.

[0140] Step S602: Update the connection list of the message broker cluster based on the task process information;

[0141] The connection list includes the correspondence between message brokers and business processes.

[0142] After obtaining the task progress information, the connection list of the message broker cluster stored locally is updated. This connection list contains the business processes connected to each message broker in the message broker cluster.

[0143] The connection list is a process map of the message broker cluster, containing connection information for all task processes and message brokers in the entire system.

[0144] The process map is a collection of lists of processes that each message broker has connected to, which can be used to determine how many processes each other broker has connected to.

[0145] It should be noted that, since each message broker stores the connection list of the message broker cluster, it can communicate local routes with other message brokers, share process connection routes, and form a process map. This provides a confirmation basis for determining the message broker that corresponds to the first business connection of the first message, thus achieving lightweight addressing. Moreover, a single message entry point, such as a message queue topic, can support message forwarding for hundreds of thousands of processes.

[0146] Step S603: The message broker cluster obtains the first message of the first topic from the message queue;

[0147] Step S604: Determine that the first message corresponds to the first service process connected to the first message broker;

[0148] Step S605: Control the first message broker to send the first message to the first business process response.

[0149] Steps S603-605 are the same as the corresponding steps in Example 1, and will not be repeated in this example.

[0150] In summary, the message processing method provided in this embodiment further includes: obtaining business process information uploaded by any message broker in the message broker cluster; and updating the connection list of the message broker cluster based on the task process information, wherein the connection list includes the correspondence between message brokers and business processes. In this embodiment, the connection list of the message broker cluster is constructed based on the connection task process shared by each message broker in the message broker cluster, providing a confirmation basis for subsequently determining the message broker corresponding to the first business connection of the first message, thus realizing lightweight addressing.

[0151] like Figure 7 The diagram shown is a flowchart of embodiment 5 of a message processing method provided in this application. The method includes the following steps:

[0152] Step S701: Obtain the business process information uploaded by any message broker in the message broker cluster;

[0153] Step S702: Update the connection list of the message broker cluster based on the task process information;

[0154] Step S703: The message broker cluster obtains the first message of the first topic from the message queue;

[0155] Step S706 is the same as the corresponding step in Example 4, and will not be described again in this example.

[0156] Step S704: Analyze the first message to obtain the first business process corresponding to the first message;

[0157] The business control end sends messages through a message queue with a fixed topic structure.

[0158] Therefore, the first message of this first topic adopts a fixed data structure.

[0159] Specifically, the data structure includes the process's business logic number, message number, and other business fields.

[0160] After receiving the first message, the message broker cluster uses the business logic number to find that the corresponding business process is the first business process.

[0161] Step S705: Based on the connection list, determine that the first service process corresponds to the first message broker;

[0162] The connection list records the business integration of each message broker connection in the message broker cluster.

[0163] Specifically, query the connection list to determine if the first business process is connected to the first message broker.

[0164] Accordingly, in subsequent steps, the first message broker is controlled to forward the first message to the first service process it is connected to, so that the first service process responds to the first message.

[0165] It should be noted that if the first business process needs to send a message to the business control terminal, it will send the message to the business control terminal through the first message broker.

[0166] Step S706: Control the first message broker to send the first message to the first business process response.

[0167] Step S706 is the same as the corresponding step in Example 4, and will not be described again in this example.

[0168] In summary, this embodiment provides a message processing method comprising: analyzing the first message to obtain a first business process corresponding to the first message; and determining, based on the connection list, that the first business process corresponds to a first message broker. In this embodiment, by analyzing the first message to obtain information representing the corresponding first business process carried in the first message, determining the corresponding first business process, and identifying the first message broker connected to the first business process in the connection list, a lightweight addressing process is achieved.

[0169] like Figure 8 The diagram shown is a flowchart of an embodiment 6 of a message processing method provided in this application. The method includes the following steps:

[0170] Step S801: Obtain the business process information uploaded by any message broker in the message broker cluster;

[0171] Step S802: Update the connection list of the message broker cluster based on the task process information;

[0172] Step S803: The message broker cluster obtains the first message of the first topic from the message queue;

[0173] Step S804: Determine that the first message corresponds to the first service process connected to the first message broker;

[0174] Step S805: Control the first message broker to send the first message to the first business process in response;

[0175] Steps S803-805 are the same as the corresponding steps in Example 4, and will not be repeated in this example.

[0176] Step S806: Receive the second connection request from the second service process;

[0177] The second business process can be a newly added business process or a business process that previously connected to a message broker but whose message broker crashed and is now reconnecting.

[0178] The second business process is not connected to any message broker in the message broker cluster.

[0179] Upon receiving the second connection request from the second business process, a message broker is connected for the second business process.

[0180] The second connection request can be a connection request sent to the message broker cluster through a preset interface.

[0181] Specifically, any message connector in the message broker cluster can act as a server that receives the second connection request.

[0182] In practice, the message broker cluster is configured with a load balancing address. The second business process can initiate a long connection to this load balancing address to request a connection to the message broker.

[0183] Step S807: Analyze the connection list to obtain the message brokers contained in the message broker cluster;

[0184] In this process, the updated connection list from the preceding steps is analyzed to determine the message brokers included in the message broker cluster.

[0185] Specifically, the message broker in the message broker cluster is the currently running message broker that can connect to the second business process.

[0186] Step S808: Determine a second message broker that meets the preset connection conditions among the message brokers included in the message broker cluster;

[0187] Specifically, the preset connection condition is either a low load or a high remaining load quota.

[0188] Since the connection list contains the various message brokers in the message broker cluster, as well as the processes that each message broker connects to, a second message broker is selected based on the information recorded in the connection list.

[0189] Upon receiving the second connection request, in order to achieve load balancing of the message broker cluster, the second business process needs to be connected to a message broker with a lower load.

[0190] Specifically, step S808 includes:

[0191] Step S8081: Analyze the connection list to obtain the number of business processes connected to each message broker in the message broker cluster;

[0192] Step S8082: Obtain the process connection quota for each message broker in the message broker cluster;

[0193] Step S8083: Based on the number of business processes connected to each message broker in the message broker cluster and the process connection quota, determine the second message broker that meets the preset connection conditions.

[0194] The number of business processes connected to each message broker and its process connection quota can be shared globally through long connections between message brokers. In order to ensure load balancing in the message broker cluster, a message broker with more remaining quota is selected as the second message broker, so that each message broker receives message links evenly, thus achieving load balancing among message brokers in the message broker cluster.

[0195] Step S809: Control the second message broker to accept the second business process, so that the second business process obtains messages from the message queue through the second message broker.

[0196] In this process, after the second message broker is determined, the second message broker is controlled to accept the second business process and connect to the second business process, thereby achieving the purpose of connecting the second business process to the message broker cluster. Messages sent to the second business process in the subsequent message queue are obtained through the second message broker.

[0197] Specifically, the second message broker can obtain messages for the first topic sent to the second business process directly from the message queue or through other message brokers.

[0198] In summary, the message processing method provided in this embodiment further includes: receiving a second connection request from a second business process; analyzing the connection list to obtain message brokers included in the message broker cluster; determining a second message broker that meets preset connection conditions among the message brokers included in the message broker cluster; and controlling the second message broker to accept the second business process, so that the second business process obtains messages from the message queue through the second message broker. In this embodiment, when a business process requests to connect to the message broker cluster, a second message broker is selected from the running message brokers in the message broker cluster for connection, and subsequent messages of the business process are relayed by the second message broker.

[0199] like Figure 9 The diagram shown is a flowchart of embodiment 7 of a message processing method provided in this application. The method includes the following steps:

[0200] Step S901: Obtain the business process information uploaded by any message broker in the message broker cluster;

[0201] Step S902: Update the connection list of the message broker cluster based on the task process information;

[0202] Step S903: The message broker cluster obtains the first message of the first topic from the message queue;

[0203] Step S904: Determine that the first message corresponds to the first service process connected to the first message broker;

[0204] Step S905: Control the first message broker to send the first message to the first business process in response;

[0205] Steps S901-905 are the same as the corresponding steps in Example 6, and will not be described again in this example.

[0206] Step S906: Analyze the connection list to obtain the number of business processes connected to each message broker in the message broker cluster;

[0207] This embodiment describes the load balancing process for a message broker cluster.

[0208] Specifically, step S906 is triggered when a specific triggering condition is met.

[0209] The specific triggering conditions may include reaching the agreed period, a large load on a message broker (such as the number of connected business processes reaching the agreed connection limit), the suspension of some business processes, or an increase in the number of message brokers due to the expansion of message broker node instances.

[0210] During the operation of the message broker cluster, the message brokers update their connection lists, which record the number of business processes connected to each message broker in the cluster.

[0211] The optimal operating mode for this message broker cluster is to have the same number of business processes connected to each message broker, thus achieving load balancing across all message brokers.

[0212] However, in actual operation, due to various reasons, the number of business processes connected to one or more message brokers may be large, resulting in a large number of messages in the first topic that the message broker needs to relay. This may cause the business processes connected to it to wait, affecting the message processing speed. In a distributed scenario, due to the massive amount of data that needs to be processed, the data processing speed is very slow.

[0213] Step S907: Based on the fact that the number of business processes connected to at least two message brokers in the message broker cluster meets the imbalance condition, control the at least two message brokers to disconnect at least one business process in order to retain a preset number of business processes connected.

[0214] After determining the number of business processes connected to each message broker in the message broker cluster, the load balance of the message brokers in the message broker cluster is analyzed.

[0215] Specifically, if the difference in the number of business processes connected to any two message processors is greater than a certain threshold, it indicates that the two meet the imbalance condition.

[0216] For example, if one message processor connects to 20 business processes and another message processor connects to 100 business processes, the difference is 80, which is much greater than the threshold of 10. Therefore, the two are determined to meet the imbalance condition.

[0217] Specifically, message brokers that do not meet the load balancing criteria will have their business processes reassigned to meet the load balancing criteria.

[0218] Specifically, disconnect some business processes and then reconnect the disconnected business processes.

[0219] In practice, the minimum number of connections that each message broker can connect to a business process can be preset. Business processes that exceed the minimum number of connections will be disconnected, and then the disconnected business processes can be reconnected to the message broker cluster.

[0220] Specifically, the message broker uses its external HTTP interface to notify the business client corresponding to the business process to trigger connection rebalancing, and the business client then actively disconnects and reconnects.

[0221] This external HTTP interface can also receive external queries, enabling queries on any business process connected to the message broker set.

[0222] Step S908: Receive a second connection request corresponding to a third service process, wherein the third service process is a service process that has been disconnected from the message broker;

[0223] Specifically, it receives a second connection request from the business client corresponding to the third business process, requesting that the third business process be reconnected to the message broker cluster.

[0224] Step S909: Based on the number of business processes connected to each message broker in the message broker cluster, determine that the third message broker responds to the second connection request and connects to the third business process, so that the number of business processes connected to the message broker in the message broker cluster does not meet the imbalance condition.

[0225] In this system, once any message broker in the message broker cluster connects to a business process, it will share that information with other message brokers. Therefore, upon receiving a second connection request, based on the number of business processes connected to each message broker in the message broker cluster, one of the brokers with fewer connections is selected as the third message broker to respond to the second connection request. The third message broker then connects to the third business process, ultimately achieving a balance in the number of business processes connected to each message broker in the message broker cluster.

[0226] In practice, the second connection request can be initiated by the business client to any message broker. The message broker that receives the second connection request can decide whether to accept the connection based on the situation of each message broker in the message broker cluster. If it does not accept the connection, it can forward the second connection request to other message brokers through long connections with other message brokers, forcing the third business process to connect to the message broker that has relatively few business processes connected.

[0227] In summary, the message processing method provided in this embodiment further includes: analyzing the connection list to obtain the number of business processes connected to each message broker in the message broker cluster; based on the fact that the number of business processes connected to at least two message brokers in the message broker cluster meets an imbalance condition, controlling the at least two message brokers to disconnect at least one business process to retain a preset number of business processes connected; receiving a second connection request corresponding to a third business process, wherein the third business process is a business process disconnected from the message broker; and based on the number of business processes connected to each message broker in the message broker cluster, determining that a third message broker responds to the second connection request and connects to the third business process, so that the number of business processes connected to the message brokers in the message broker cluster does not meet the imbalance condition. In this embodiment, when the number of business processes connected to each message broker in the message broker cluster does not meet the imbalance condition, a process of re-sharding and reconnecting the services connected to the message brokers in the message broker cluster is implemented to balance the overall business processes in the message broker cluster. This can automatically balance the number of system connections by rebuilding connections during service scaling, thus achieving overall business process balance in the message broker cluster.

[0228] Corresponding to the message processing method embodiment provided in this application above, this application also provides an apparatus embodiment for applying the message processing method.

[0229] like Figure 10 The diagram shown is a structural schematic of an embodiment of a message processing device provided in this application. The device is applied to an electronic device that runs any message broker in a message broker cluster. The device includes the following structure: an acquisition module 1001, a determination module 1002, and a control module 1003.

[0230] The obtaining module 1001 is used to obtain the first message of the first topic from the message queue. The first message is sent to the message queue by the business control terminal. The message broker cluster includes at least one message broker.

[0231] The determining module 1002 is used to determine that the first message corresponds to the first business process connected to the first message broker, and the first business process is the task process connected to the first message broker in the message broker cluster.

[0232] The control module 1003 is used to control the first message broker to send the first message to the first business process response.

[0233] Optional, also includes:

[0234] The second message acquisition module is used to obtain the second message of the second topic from the message queue. The second message is a heartbeat packet initiated by any message broker.

[0235] The first analysis module is used to analyze the second message and obtain the number of message brokers in the message broker cluster that are running.

[0236] The acquisition module is triggered when the number of running message brokers meets a preset condition.

[0237] The generation module is used to generate alarm information when the number of running message brokers does not meet a preset number condition.

[0238] Optionally, the method further includes:

[0239] The second analysis module is used to analyze the second message after obtaining the second message of the second topic from the message queue, and obtain the address information of the message broker.

[0240] The initiation module is used to initiate a first connection request to the message broker based on the address information;

[0241] The construction module is used to build a message broker cluster with the message broker based on the connection confirmation information received from the message broker.

[0242] Optionally, the method further includes:

[0243] The business process information acquisition module is used to obtain business process information uploaded by any message broker in the message broker cluster before obtaining the first message of the first topic from the message queue.

[0244] The update module is used to update the connection list of the message broker cluster based on the task process information. The connection list includes the correspondence between message brokers and business processes.

[0245] Optional, determine the module, specifically used for:

[0246] Analyze the first message to obtain the first business process corresponding to the first message;

[0247] Based on the connection list, it is determined that the first service process corresponds to the first message broker.

[0248] Optional, also includes:

[0249] The first receiving module receives the second connection request from the second business process;

[0250] The third analysis module is used to analyze the connection list to obtain the message brokers contained in the message broker cluster.

[0251] The determining module is further configured to determine a second message broker that meets preset connection conditions among the message brokers included in the message broker cluster;

[0252] The control module is also used to control the second message broker to accept the second business process, so that the second business process obtains messages from the message queue through the second message broker.

[0253] Optionally, the determining module is specifically used for:

[0254] Analyzing the connection list yields the number of business processes connected to each message broker in the message broker cluster.

[0255] Retrieve the process connection quota for each message broker in the message broker cluster;

[0256] Based on the number of business processes connected to each message broker in the message broker cluster and the process connection quota, a second message broker that meets the preset connection conditions is determined.

[0257] Optional, also includes:

[0258] The fourth analysis module is used to analyze the connection list to obtain the number of business processes connected to each message broker in the message broker cluster;

[0259] The control module is also used to control the at least two message brokers to disconnect at least one business process based on the imbalance condition of the number of business processes connected to at least two message brokers in the message broker cluster, so as to retain a preset number of business processes connected.

[0260] The second receiving module is used to receive a second connection request corresponding to a third business process, wherein the third business process is a business process that has been disconnected from the message broker.

[0261] The determining module is further configured to determine, based on the number of business processes connected to each message broker in the message broker cluster, that a third message broker responds to the second connection request and connects to the third business process, so that the number of business processes connected to the message brokers in the message broker cluster does not meet the imbalance condition.

[0262] It should be noted that the functional explanations of the various structures in the message processing device provided in this embodiment are provided in the foregoing method embodiments, and will not be repeated in this embodiment.

[0263] In summary, the message processing device provided in this embodiment allows message brokers in a message broker cluster to share messages in a message queue. When any message broker obtains a first message from the message queue and determines the first business process connected to its corresponding first message broker, it controls the first message broker to send the first message to the first business process it is connected to for response. By using a message broker cluster as middleware to interconnect local process routing and message forwarding, lightweight addressing of business process connections is achieved. Only a limited number of message classification channels (topics) are needed to achieve message management of millions of processes, enabling high-performance management of message links for a large number of stateful business processes.

[0264] Corresponding to the above-described embodiment of a message processing method provided in this application, this application also provides an electronic device and a readable storage medium corresponding to the message processing method.

[0265] The electronic device includes: a memory and a processor;

[0266] The memory stores the processing program;

[0267] The processor is used to load and execute the processing program stored in the memory to implement the steps of the message processing method as described in any of the preceding claims.

[0268] For details on the message processing method implemented by this electronic device, please refer to the aforementioned message processing method embodiments.

[0269] The readable storage medium stores a computer program that is invoked and executed by a processor to implement the steps of the message processing method as described in any of the preceding claims.

[0270] Specifically, the computer program stored on the readable storage medium executes the message processing method, as described in the aforementioned message processing method embodiments.

[0271] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. The apparatus provided in the embodiments is described simply because it corresponds to the method provided in the embodiments; relevant parts can be found in the method section.

[0272] The above description of the provided embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features provided herein.

Claims

1. A message processing method characterized by, The method comprises the following steps: a message broker cluster obtains a first message of a first topic from a message queue, the first message being sent to the message queue by a business control terminal, the message broker cluster comprising at least one message broker; determining that the first message corresponds to a first business process connected to a first message broker, the first business process being a task process connected to the first message broker in the message broker cluster; controlling the first message broker to send the first message to the first business process response; wherein, before the message broker cluster obtains the first message of the first topic from the message queue, the method further comprises the following steps: obtaining business process information uploaded by any message broker in the message broker cluster; updating a connection list of the message broker cluster based on the task process information, the connection list comprising a corresponding relationship between a message broker and a business process; wherein, the step of controlling the first message broker to send the first message to the first business process response comprises the following steps: if the first message is obtained by the first message broker, the first message processor directly sends the first message to the first business process; if the first message is obtained by a message broker other than the first message broker, the first message is sent to the first message broker, and then the first message is sent to the first business process by the first message broker.

2. The method of claim 1, wherein, The method further comprises the following steps: obtaining a second message of a second topic from the message queue, the second message being a heartbeat packet initiated by any message broker; analyzing the second message to obtain the number of message brokers in the message broker cluster that are in a running state; based on the number of message brokers in the running state satisfying a preset number condition, performing the step of the message broker cluster obtaining the first message of the first topic from the message queue; based on the number of message brokers in the running state not satisfying the preset number condition, generating an alarm information.

3. The method of claim 2, wherein, After the message broker cluster obtains the second message of the second topic from the message queue, the method further comprises the following steps: analyzing the second message to obtain address information of the message broker; initiating a first connection request to the message broker based on the address information; based on receiving connection confirmation information fed back by the message broker, constructing a message broker cluster with the message broker.

4. The method of claim 1, wherein, The step of determining that the first message corresponds to the first business process connected to the first message broker comprises the following steps: analyzing the first message to obtain a first business process corresponding to the first message; based on the connection list, determining that the first business process corresponds to the first message broker.

5. The method of claim 1, wherein, The method further comprises the following steps: receiving a second connection request of a second business process; analyzing the connection list to obtain message brokers contained in the message broker cluster; determining a second message broker satisfying a preset connection condition among the message brokers contained in the message broker cluster; controlling the second message broker to accept the second business process, so that the second business process obtains messages from the message queue through the second message broker.

6. The method of claim 5, wherein, The step of determining a second message broker satisfying a preset connection condition among the message brokers contained in the message broker cluster comprises the following steps: analyzing the connection list to obtain a number of service processes connected by each message broker in the message broker cluster obtaining a process connection quota of each message broker in the message broker cluster determining a second message broker satisfying a preset connection condition based on the number of service processes connected by each message broker in the message broker cluster and the process connection quota.

7. The method of claim 1, wherein, Further comprising: analyzing the connection list to obtain a number of service processes connected by each message broker in the message broker cluster controlling at least two message brokers to disconnect at least one service process to reserve a preset number of service processes based on the number of service processes connected by the at least two message brokers satisfying an unbalanced condition receiving a second connection request corresponding to a third service process, the third service process being the service process disconnected from the message broker determining a third message broker to connect the third service process in response to the second connection request based on the number of service processes connected by each message broker in the message broker cluster, so that the number of service processes connected by the message brokers in the message broker cluster does not satisfy the unbalanced condition.

8. A message processing device, characterized by Comprising: an obtaining module, configured to obtain a first message of a first topic from a message queue by a message broker cluster, the first message being sent to the message queue by a business control end, the message broker cluster comprising at least one message broker a determining module, configured to determine that the first message corresponds to a first service process connected by a first message broker, the first service process being a task process connected by the first message broker in the message broker cluster a control module, configured to control the first message broker to send the first message to the first service process response Before the first message of the first topic is obtained from the message queue, further comprising: obtaining service process information uploaded by any message broker in the message broker cluster updating a connection list of the message broker cluster based on the task process information, the connection list comprising a corresponding relationship between a message broker and a service process The control module is configured to: if the first message is obtained by the first message broker, the first message processor directly sends the first message to the first service process; if the first message is obtained by a message broker other than the first message broker, the first message is sent to the first message broker, and the first message is sent by the first message broker to the first service process.

9. An electronic device, comprising: Comprising: a memory and a processor The memory stores a processing program The processor is configured to load and execute the processing program stored in the memory to implement each step of the message processing method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Method and device for cluster order-preserving processing of queue messages

    CN115373873A