Message processing method, message queue telemetry transport cluster, apparatus, and device
Patent Information
- Application Number
- CN202210626065.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-02
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-06-02
AI Technical Summary
[0004]相关技术中,针对MQTT集群,当有消息到来时,该消息将被同步写入所有集群中的所有节点,全部写入成功后,消息写入方才可以向MQTT集群写入下一消息,当有多个消息需要写入MQTT集群时,消息的写入速度消耗时间较长,消息写入方向MQTT集群写入消息的效率较低
[0042]本申请实施例提供的的技术方案,通过在消息队列遥测传输集群中设置控制设备、第一主节点与一个或多个第一从节点,通过控制设备获取消息写入方设备写入的第一消息,所述第一消息包括所述消息写入方设备对应的订阅方设备订阅的消息;将所述第一消息发送至所述第一主节点,使所述第一主节点将所述第一消息同步至所述一个或多个第一从节点;向所述消息写入方设备发送所述第一消息已写入完成的第一提示信息,所述第一提示信息用于提示所述消息写入方设备向所述控制设备写入下一消息的方案,相对于相关技术中,当消息队列遥测传输集群中的各个节点全部获取到第一消息后,消息写入方设备才可以写入下一消息的方案,大大节省了多个消息被写入消息队列遥测传输集群的过程的总时长,提高了消息写入的效率。
Smart Images

Figure CN117221316B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, specifically to a message processing method, a message queue telemetry transmission cluster, apparatus, and equipment. Background Technology
[0002] MQTT (Message Queuing Telemetry Transport) is often used as an access protocol for a variety of IoT devices in IoT scenarios due to its simplicity and portability. Specifically, it is a "lightweight" communication protocol based on the publish / subscribe model suitable for IoT, which can provide real-time and reliable messaging services for connecting remote devices with minimal code and limited bandwidth.
[0003] An MQTT Broker (MQTT Message Server) is a single server or cluster of servers running MQTT message server software. The MQTT Broker is responsible for receiving network connections from clients and processing their subscribe / unsubscribe and publish requests. It also forwards published messages to other subscribers.
[0004] In related technologies, for MQTT clusters, when a message arrives, it will be synchronously written to all nodes in the cluster. Only after all messages are successfully written can the message writer write the next message to the MQTT cluster. When multiple messages need to be written to the MQTT cluster, the message writing speed takes a long time, and the efficiency of the message writer in writing messages to the MQTT cluster is low. Summary of the Invention
[0005] This application provides a message processing method, a message queue telemetry transmission cluster, an apparatus, and a device, which can greatly reduce the total writing time of multiple messages to the message queue telemetry transmission cluster and improve the efficiency of message writing.
[0006] On one hand, embodiments of this application provide a message processing method applicable to control devices in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a first master node and one or more first slave nodes, and the method includes:
[0007] Obtain the first message written by the message writer device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0008] The first message is sent to the first master node, so that the first master node synchronizes the first message to the one or more first slave nodes;
[0009] A first notification message indicating that the first message has been written is sent to the message writer device. The first notification message is used to prompt the message writer device to write the next message to the control device.
[0010] On the other hand, embodiments of this application provide a message processing method applicable to the device corresponding to the first master node in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a control device and one or more first slave nodes, and the method includes:
[0011] Receive a first message sent by the control device, the first message including messages subscribed to by the subscriber device corresponding to the message writer device;
[0012] Synchronize the first message to the one or more first slave nodes;
[0013] The system receives the next message sent by the control device and synchronizes the next message to the one or more first slave nodes. The next message is a first prompt message sent by the control device to the message writer device after sending the first message to the device corresponding to the first master node, indicating that the first message has been written. This prompts the message writer device to write the message to the control device.
[0014] On the other hand, embodiments of this application provide a message processing method applicable to a device corresponding to any one of the first slave nodes in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a first master node and a control device, and the method includes:
[0015] A first message synchronization request is sent to the first master node according to a preset period, so that the first master node determines the corresponding first message based on the first message synchronization request.
[0016] Receive the first message determined by the first master node based on the first message synchronization request;
[0017] The first master node sends a second message synchronization request to the first master node according to the preset period, so that the first master node determines the next message of the first message based on the second message synchronization request.
[0018] Receive the next message determined by the first master node;
[0019] The first message is received by the first master node from the control device and by the control device from the message writer device. The next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written. This prompts the message writer device to write the message to the control device.
[0020] On the other hand, embodiments of this application provide a message queue telemetry transmission cluster, including a control device, a first master node, and one or more first slave nodes; wherein:
[0021] The control device is configured to: acquire a first message written by the message writer device, the first message including messages subscribed to by the subscriber device corresponding to the message writer device; and send the first message to the first master node;
[0022] The first master node is used to: synchronize the first message to the one or more first slave nodes;
[0023] The control device is further configured to send a first prompt message indicating that the first message has been written to the message writer device after sending the first message to the first master node. The first prompt message is used to prompt the message writer device to write the next message to the control device.
[0024] The first slave node is configured to: send a first message synchronization request to the first master node according to a preset period, so that the first master node determines the first message based on the first message synchronization request.
[0025] On the other hand, embodiments of this application provide a message processing apparatus suitable for control devices in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a first master node and one or more first slave nodes, and the apparatus includes:
[0026] The acquisition unit is used to acquire a first message written by the message writer device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0027] The sending unit is configured to send the first message to the first master node, so that the first master node synchronizes the first message to the one or more first slave nodes;
[0028] The sending unit is further configured to send a first prompt message to the message writer device indicating that the first message has been written, the first prompt message being used to prompt the message writer device to write the next message to the control device.
[0029] On the other hand, embodiments of this application provide a message processing apparatus applicable to the device corresponding to the first master node in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a control device and one or more first slave nodes, and the apparatus includes:
[0030] The receiving unit is configured to receive a first message sent by the control device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0031] A synchronization unit is configured to synchronize the first message to the one or more first slave nodes;
[0032] The receiving unit is further configured to receive the next message sent by the control device and synchronize the next message to the one or more first slave nodes, wherein the next message is a first prompt message sent by the control device to the message writer device after sending the first message to the device corresponding to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device.
[0033] On the other hand, embodiments of this application provide a message processing apparatus applicable to devices corresponding to any one of the first slave nodes in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a first master node and a control device, and the apparatus includes:
[0034] The sending unit is used to send a first message synchronization request to the first master node according to a preset period, so that the first master node determines the corresponding first message according to the first message synchronization request.
[0035] The receiving unit is configured to receive the first message determined by the first master node based on the first message synchronization request;
[0036] The sending unit is further configured to send a second message synchronization request to the first master node according to the preset period, so that the first master node determines the next message of the first message according to the second message synchronization request;
[0037] The receiving unit is further configured to receive the next message determined by the first master node;
[0038] The first message is received by the first master node from the control device and by the control device from the message writer device. The next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written. This prompts the message writer device to write the message to the control device.
[0039] On the other hand, embodiments of this application provide a computer-readable storage medium storing a computer program adapted for loading by a processor to execute the message processing method as described in any of the above embodiments.
[0040] On the other hand, embodiments of this application provide a computer device, the computer device including a processor and a memory, the memory storing a computer program, and the processor executing the message processing method as described in any of the above embodiments by calling the computer program stored in the memory.
[0041] On the other hand, embodiments of this application provide a computer program product, including computer instructions, which, when executed by a processor, implement the message processing method as described in any of the above embodiments.
[0042] The technical solution provided in this application embodiment, by setting up a control device, a first master node, and one or more first slave nodes in a message queue telemetry transmission cluster, obtains a first message written by a message writer device through the control device. The first message includes messages subscribed to by a subscriber device corresponding to the message writer device. The first message is sent to the first master node, causing the first master node to synchronize the first message to the one or more first slave nodes. A first prompt message indicating that the first message has been written is sent to the message writer device, which prompts the message writer device to write the next message to the control device. Compared with related technologies, where the message writer device can only write the next message after all nodes in the message queue telemetry transmission cluster have obtained the first message, this solution greatly saves the total time of writing multiple messages to the message queue telemetry transmission cluster and improves the efficiency of message writing. Attached Figure Description
[0043] Figure 1 This is a schematic diagram of the structure of a message queue telemetry transmission cluster provided in an embodiment of this application.
[0044] Figure 2a This is a flowchart illustrating a message processing method provided in an embodiment of this application.
[0045] Figure 2b This is a schematic diagram of another message queue telemetry transmission cluster provided in an embodiment of this application.
[0046] Figure 2c This is a schematic diagram illustrating the creation process of a first master node, as provided in an embodiment of this application.
[0047] Figure 3aThis is a flowchart illustrating another message processing method provided in an embodiment of this application.
[0048] Figure 3b This is a schematic diagram of a first message identifier sequence provided in an embodiment of this application.
[0049] Figure 3c This is a schematic diagram of the first node identifier list and the second node identifier list provided in the embodiments of this application.
[0050] Figure 3d This is a schematic diagram of another first message identifier sequence provided in an embodiment of this application.
[0051] Figure 4 This is a flowchart illustrating another message processing method provided in an embodiment of this application.
[0052] Figure 5 A timing flowchart illustrating the message processing method provided in this application embodiment.
[0053] Figure 6 This is a schematic diagram of the structure of the message processing device provided in the embodiments of this application.
[0054] Figure 7 This is a schematic diagram of the structure of the message processing device provided in the embodiments of this application.
[0055] Figure 8 This is a schematic diagram of the structure of the message processing device provided in the embodiments of this application.
[0056] Figure 9 A schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0057] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0058] The embodiments of this application can be applied to various scenarios such as instant messaging and Internet of Things technology.
[0059] This application provides a message processing method, a message queue telemetry transmission cluster, an apparatus, and a device. Specifically, the message processing method of this application can be executed by a computer device, wherein the computer device can be a server. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a distributed system. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0060] First, some of the nouns or terms that appear in the description of the embodiments of this application are explained as follows:
[0061] Single point of failure: refers to a component in a system whose failure at any point will render the entire system inoperable. In other words, a single point of failure will cause the entire system to fail.
[0062] Service instance: An assembly that can provide services to external parties.
[0063] AC: Wireless Access Point Controller, a type of network device;
[0064] MQTT (Message Queuing Telemetry Transport) is a publish / subscribe messaging protocol based on the ISO standard (ISO / IEC PRF 20922). It operates on the TCP / IP protocol suite and is designed for remote devices with limited hardware performance and poor network conditions; therefore, it requires a message broker.
[0065] MQTT is a client-server message publish / subscribe transport protocol. The MQTT protocol is lightweight, simple, open, and easy to implement, making it widely applicable. It is used in many situations, including constrained environments such as machine-to-machine (M2M) communication and the Internet of Things (IoT). It is widely used in sensors communicating via satellite links, medical devices making occasional dial-up calls, smart homes, and some miniaturized devices.
[0066] A cluster is a group of independent computers interconnected by a high-speed network, forming a group and managed as a single system. When a client interacts with a cluster, the cluster behaves like a single server. Cluster configuration is used to improve availability and scalability.
[0067] The Internet of Things (IoT) refers to the use of various information sensors, RFID technology, GPS, infrared sensors, laser scanners, and other devices and technologies to collect real-time data on any object or process that needs to be detected, connected, or interacted with. This data includes information on sound, light, heat, electricity, mechanics, chemistry, biology, location, and other parameters. Through various possible network access methods, it enables ubiquitous connectivity between things and between things and people, achieving intelligent perception, identification, and management of objects and processes. The IoT is an information carrier based on the internet and traditional telecommunications networks, allowing all independently addressable ordinary physical objects to form an interconnected network.
[0068] ZooKeeper is a distributed, open-source distributed application coordination service. It's software that provides consistency services for distributed applications, offering features such as configuration maintenance, domain name service, distributed synchronization, and group services. ZooKeeper's goal is to encapsulate complex and error-prone critical services, providing users with simple, easy-to-use interfaces and a high-performance, stable system. ZooKeeper contains a simple set of primitives, providing interfaces for Java and C.
[0069] Wireless AP (Access Point): A wireless access point is a wireless switch used in wireless networks and is the core of the wireless network. A wireless AP is the access point for mobile computer users to access a wired network, mainly used in broadband homes, buildings, and campuses, with a coverage range of tens to hundreds of meters. Wireless AP (also known as session point or access bridge) is a broad term, encompassing not only simple wireless access points (wireless APs) but also wireless routers (including wireless gateways and wireless bridges) and similar devices.
[0070] AC (Wireless Access Point Controller): A wireless controller is a network device used to centrally control wireless access points (APs). It is the core of a wireless network and is responsible for managing all wireless APs in the network. AP management includes: issuing configurations, modifying relevant configuration parameters, intelligent radio frequency management, and access security control.
[0071] Cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Based on the cloud computing business model, cloud technology encompasses network technology, information technology, integration technology, management platform technology, and application technology. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will require robust system support, which can only be achieved through cloud computing.
[0072] In related technologies, in enterprise-level IoT device management scenarios, a large number of enterprise-level IoT devices, such as WIFI devices, ACs, APs, etc., access backend cloud services through MQTT Brokers. The cloud services can provide subscription services for IoT devices. When the MQTT Broker determines that the messages subscribed to by the IoT devices can be consumed, it can send the messages to the IoT devices for consumption. However, all IoT devices that have subscribed to the same topic will receive the full message, which is not conducive to the expansion of IoT devices.
[0073] For MQTT clusters, when a message subscribed to by an IoT device arrives, the message will be synchronously written to all nodes in the cluster. Only after all messages are successfully written can the message writer, i.e., the backend cloud service, write the next message to the MQTT cluster. When multiple messages need to be written to the MQTT cluster, the message writing speed takes a long time, and the efficiency of the message writer in writing messages to the MQTT cluster is low.
[0074] This application provides a solution whereby the message writer device can write the next message as soon as the first master node in the message queue telemetry transmission cluster obtains the first message. Compared with related technologies, where the message writer device can only write the next message after all nodes in the message queue telemetry transmission cluster have obtained the first message, this greatly saves the total time of writing multiple messages to the message queue telemetry transmission cluster and improves the efficiency of message writing.
[0075] Furthermore, most existing MQTT broker implementations do not support cluster deployment and have a single point of failure. This solution provides a distributed MQTT cluster master-slave replica synchronization scheme, which enables the master and slave nodes to synchronize data asynchronously. This ensures both the efficiency of data writing and consumption and the reliability of messages in the event of cluster failure.
[0076] The following detailed description of the solution is provided in conjunction with specific embodiments.
[0077] Please refer to Figure 1 , Figure 1 This is a schematic diagram of the structure of a message queue telemetry transmission cluster provided in an embodiment of this application. The message queue telemetry transmission cluster 10 includes a control device 11, a first master node 12, and one or more first slave nodes 13.
[0078] Optionally, the first master node 12 and any one of the one or more first slave nodes 13 can be a software module or an MQTT message server, wherein:
[0079] The control device 11 is used to: acquire a first message written by the message writer device, the first message including messages subscribed to by the subscriber device corresponding to the message writer device; and send the first message to the first master node 12.
[0080] The first master node 12 is used to: synchronize the first message to the one or more first slave nodes 13;
[0081] The control device 11 is further configured to send a first prompt message indicating that the first message has been written to the message writer device after sending the first message to the first master node 12. The first prompt message is used to prompt the message writer device to write the next message to the control device.
[0082] The first slave node 13 is used to: send a first message synchronization request to the first master node 12 according to a preset period, so that the first master node 12 determines the first message according to the first message synchronization request.
[0083] Optionally, the message queue telemetry transmission cluster is connected to the message writer device via a network, and the message queue telemetry transmission cluster is connected to the subscriber device via a network. The network connection can be a wired network connection or a wireless network connection.
[0084] Optionally, embodiments of this application provide a message processing method. Figure 2a This is a flowchart illustrating the message processing method, which is applicable to the aforementioned message queue telemetry transmission cluster. Specifically, this message processing method is applicable to the control device in the message queue telemetry transmission cluster, which further includes a first master node and one or more first slave nodes. The method includes the following steps S201-S203:
[0085] S201. Obtain the first message written by the message writer device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0086] Optionally, the message writer device is the subscribed device of the first message (i.e., the message writer device), which may specifically be a server of a third-party service that provides subscription services for the subscriber device;
[0087] In some optional embodiments of this application, see Figure 2b As shown, the aforementioned subscriber devices can be ACs, APs, and other IoT devices. These other IoT devices may include smart home appliances, control devices for managing other electronic devices, etc. The AC can be used to provide access to the message queue telemetry transmission cluster for some APs.
[0088] S202. Send the first message to the first master node, so that the first master node synchronizes the first message to the one or more first slave nodes;
[0089] Optionally, when the first master node synchronizes the first message to the one or more first slave nodes, it may specifically include:
[0090] For each of the one or more first slave nodes, obtain the first message synchronization request of the first slave node;
[0091] The corresponding message to be synchronized is determined based on the first message synchronization request;
[0092] If it is determined that the message to be synchronized contains the first message, then the first message is synchronized to the first slave node.
[0093] S203. Send a first prompt message to the message writer device indicating that the first message has been written. The first prompt message is used to prompt the message writer device to write the next message to the control device.
[0094] That is, after receiving the first prompt message, the message writing device determines that the first message has been written.
[0095] In some optional embodiments of the application, the method further includes the steps S21-S23:
[0096] S21. When a connection interruption with the second master node is detected, send corresponding notification information to the one or more slave nodes. The second master node is the master node in the message queue telemetry transmission cluster before the first master node was created.
[0097] Optionally, the aforementioned control device may be configured with ZooKeeper. When the control device detects that its connection with the second master node is interrupted, or that the second master node experiences other abnormalities, the control device sends corresponding notification information to one or more first slave nodes.
[0098] S22. Receive a master node creation request sent by one or more first slave nodes after obtaining the notification information;
[0099] Specifically, see Figure 2c After each of the aforementioned first slave nodes receives the notification information, it sends a master node creation request to the control device to apply to the ZooKeeper in the control device to create itself as the first master node.
[0100] S23. Create the first master node according to the master node creation request.
[0101] Optionally, the control device sets the fourth slave node corresponding to the earliest received master node creation request as the first master node, and sends feedback information indicating that the fourth slave node has been successfully set as the first master node to the fourth slave node, and stores the indication information that the fourth slave node is the first master node locally.
[0102] After the control device sets the fourth slave node as the first master node, the method further includes: sending a failure message indicating that the master node creation has failed to the first slave node corresponding to the received master node creation request.
[0103] In this scheme, the middleware ZooKeeper can be used for the election of the first master node. When the first node comes online, it can request to ZooKeeper to create itself as a temporary first master node. Subsequent newly online nodes will also attempt to create a first master node from ZooKeeper, but the creation will fail since the first master node already exists. Then, the newly online nodes begin to detect the first master node. When the first master node encounters an anomaly and its session connection with ZooKeeper is lost, all the first slave nodes that were detecting the first master node will be notified. These first slave nodes will then compete to create the first master node, and ultimately, the first slave node whose master node creation request is approved becomes the first master node.
[0104] The solution proposed in this application, by setting up a control device, a first master node, and one or more first slave nodes in a message queue telemetry transmission cluster, obtains a first message written by a message writer device through the control device. The first message includes messages subscribed to by a subscriber device corresponding to the message writer device. The first message is then sent to the first master node, causing the first master node to synchronize the first message to the one or more first slave nodes. A first notification message indicating that the first message has been written is sent to the message writer device, which prompts the message writer device to write the next message to the control device. Compared to related technologies, where the message writer device can only write the next message after all nodes in the message queue telemetry transmission cluster have obtained the first message, this solution significantly reduces the total time for multiple messages to be written to the message queue telemetry transmission cluster, thus improving the efficiency of message writing.
[0105] To provide a more detailed explanation of this solution, this application also provides a message processing method. Figure 3aThis is a flowchart illustrating the message processing method, which is applicable to the device corresponding to the first master node in a message queue telemetry transmission cluster. The device corresponding to the first master node can be the first master node itself or a device on which the first master node is deployed. The message queue telemetry transmission cluster also includes a control device and one or more first slave nodes. The method includes the following steps S301-S302:
[0106] S301. Receive a first message sent by the control device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0107] S302. Synchronize the first message to the one or more first slave nodes;
[0108] S303. Receive the next message sent by the control device and synchronize the next message to the one or more first slave nodes, wherein the next message is a first prompt message sent by the control device to the message writer device after sending the first message to the device corresponding to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device.
[0109] Optionally, in S302, synchronizing the first message to the one or more first slave nodes includes the following S3021-S3023:
[0110] S3021. For each of the one or more first slave nodes, obtain the first message synchronization request of the first slave node;
[0111] The first message synchronization request includes the message identifier of the second message, which is the message that the first slave node has most recently synchronized.
[0112] S3022. Determine the corresponding message to be synchronized based on the first message synchronization request;
[0113] Specifically, determining the corresponding message to be synchronized based on the first message synchronization request includes the following steps S31-S32:
[0114] S31. Obtain a first message identifier sequence, which contains multiple message identifiers. Each message identifier corresponds to a candidate synchronization message. The later the first master node obtains the candidate synchronization message, the closer the message identifier corresponding to the candidate synchronization message is to the end of the first message identifier sequence. That is, if the first master node obtains candidate synchronization message 1 earlier than the first master node obtains candidate synchronization message 2, then the message identifier corresponding to candidate synchronization message 1 is ranked before the message identifier corresponding to candidate synchronization message 2 in the first message identifier sequence. Optionally, the candidate synchronization message is a message received by the first master node from the self-control device and needs to be synchronized from the first master node to the first slave node.
[0115] Optionally, the candidate synchronization message is a message received by the first master node from the self-control device and needs to be synchronized from the first master node to the first slave node.
[0116] The candidate synchronization message is received by the control device from the aforementioned message writer device.
[0117] S32. Determine the message to be synchronized based on the message identifier of the second message and the sequence of the first message identifier.
[0118] Optionally, in S32, determining the message to be synchronized based on the message identifier of the second message and the sequence of the first message identifier includes the following S321-S323:
[0119] S321. A first message identifier that is the same as the message identifier of the second message is found in the first message identifier sequence;
[0120] S322. Obtain a second message identifier sequence located between the first message identifier and the end message identifier at the end of the first message identifier sequence, wherein the end message identifier is included in the second message identifier sequence, and the second message identifier sequence does not include the first message identifier, and the number of message identifiers included in the second message identifier sequence can be one or more.
[0121] S323. The candidate synchronization message corresponding to the second message identifier sequence is taken as the message to be synchronized.
[0122] In some optional embodiments of this application, the first message identifier sequence may be referred to Figure 3b As shown, the "1", "2", "3", "4", "5" and "6" in the first message identifier sequence are multiple message identifiers. That is, the message identifier can be an index value, and the index value increases from the beginning to the end of the first message identifier sequence.
[0123] Optionally, when the message identifier of the second message is "4", the first message identifier in the first message identifier sequence that is the same as "4" is "4", and the second message identifier sequence located between the first message identifier "4" and the ending message identifier "6" at the end of the first message identifier sequence contains message identifiers 5 and 6.
[0124] The first slave node synchronizes the candidate synchronization messages corresponding to each message identifier in the first message identifier sequence in the first master node in the order from beginning to end of the first message identifier sequence.
[0125] S3023. If it is determined that the message to be synchronized includes the first message, then the first message is synchronized to the first slave node.
[0126] Optionally, the message identifiers for each of the aforementioned candidate synchronization messages can be created by the first master node.
[0127] In some other optional embodiments of this application, the first message synchronization request further includes a first topic identifier corresponding to the message identifier of the second message, and obtaining the first message identifier sequence includes:
[0128] The first message identifier sequence is determined based on the first topic identifier and the preset correspondence.
[0129] The first topic identifier is the topic identifier of the topic to which the second message belongs. In this scheme, the topic can be a control command for controlling the subscriber device, a control rule, a setting command for setting the attributes of the subscriber device, etc.
[0130] Optionally, the method further includes the following steps S01-S03:
[0131] S01. Create a message identifier for the first message;
[0132] S02. Add the message identifier of the first message to the first message identifier sequence.
[0133] In some optional embodiments of this application, the first message synchronization request further includes a first node identifier of the first slave node, and the method further includes:
[0134] Based on the first node identifier, determine the first total number of messages in the first master node that need to be synchronized by the first slave node, and the first number of messages that the first slave node has already synchronized from the first master node;
[0135] Among them, the total messages that need to be synchronized by the first slave node are all messages that the first master node receives from the self-control device and that need to be synchronized from the first master node to the first slave node.
[0136] Optionally, when all messages to be synchronized by the first slave node belong to only one topic, the total number of messages to be synchronized by the first slave node is the same as the aforementioned candidate synchronization messages.
[0137] Optionally, when at least two messages among all messages to be synchronized by the first slave node involve different topics, the total number of messages to be synchronized by the first slave node is: all messages to be synchronized by the first slave node, and the candidate synchronization message can be only a message belonging to one of the multiple topics involved in the aforementioned all messages.
[0138] If the difference between the first total number of messages and the first number of messages is not less than a preset difference, then the first node identifier is moved from the first node identifier list to the second node identifier list;
[0139] The first node identifier list stores one or more second node identifiers. For the second slave node corresponding to the second node identifier, the difference between the second total number of messages in the first master node that need to be synchronized by the second slave node and the second message number of messages that the second slave node has synchronized from the first master node is less than a preset difference. The second node identifier list stores one or more third node identifiers. For the third slave node corresponding to the third node identifier, the difference between the third total number of messages in the first master node that need to be synchronized by the third slave node and the third message number of messages that the third slave node has synchronized from the first master node is not less than a preset difference.
[0140] Optionally, such as Figure 3c As shown, "Server 1", "Server 2", and "Server 3" are the second node identifiers in the first node identifier list, and "Server 4" and "Server 5" are the third node identifiers in the second node identifier list.
[0141] By storing multiple first-slave node identifiers corresponding to multiple first-slave nodes in a message queue telemetry transmission cluster in different node identifier lists, it is possible to prevent a situation where, when a new first-slave node is added to the cluster, if it has no messages stored, it needs to synchronize messages from the first master node from scratch, which may take a long time. If new messages arrive at the first master node at this time, waiting for the new first-slave node to complete message synchronization will also take a long time. Therefore, two node identifier lists are designed in the first master node: the first node identifier list stores the node identifiers of first-slave nodes that have caught up with the first master node; the second node identifier list stores the node identifiers of first-slave nodes that have not caught up with the first master node. When consuming messages, the first master node can only consider the synchronization status of the first-slave nodes corresponding to each node identifier in the first node identifier list from synchronizing messages with the first master node. Here, "consumption" in this scheme can refer to message processing or response.
[0142] Optionally, the first message identifier sequence further includes the consumption status of each candidate synchronization message, wherein the consumption status of the candidate synchronization message corresponds to the message identifier of the candidate synchronization message, and the consumption status includes either consumable or non-consumable. The process further includes:
[0143] For each candidate synchronization message, it is detected whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, the consumption status of the candidate synchronization message in the first message identifier sequence is set to consumeable. If no, no processing is performed. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
[0144] For example, see Figure 3d As shown, when the candidate synchronization message corresponding to message identifier "5" in the first message identifier sequence is synchronized by the target slave node in the message queue telemetry transmission cluster, the consumption status corresponding to "5" is changed from "cannot be consumed" to "can be consumed".
[0145] When the consumption status of a candidate synchronization message is "can be consumed", the method further includes: sending the candidate synchronization message to the subscriber device.
[0146] Optionally, the first master node can update the offset of the message identifier corresponding to the consumable message based on the synchronization status of each first slave node in the message queue telemetry transmission cluster for the candidate synchronization message.
[0147] In this application's scheme, only the first master node is responsible for writing and consuming all messages. The first slave node asynchronously synchronizes messages from the first master node using a timed update method, which ensures data reliability and avoids consuming too much time in message synchronization, thus affecting consumption performance.
[0148] Figure 4 This is a flowchart illustrating another message processing method provided in an embodiment of this application. This message processing method is applicable to a device corresponding to any one of one or more first slave nodes in a message queue telemetry transmission cluster. The message queue telemetry transmission cluster further includes a first master node and a control device. The method includes steps S401-S404:
[0149] S401. Send a first message synchronization request to the first master node according to a preset period, so that the first master node determines the corresponding first message according to the first message synchronization request;
[0150] S402: Receive the first message determined by the first master node based on the first message synchronization request;
[0151] S403. Send a second message synchronization request to the first master node according to the preset period, so that the first master node determines the next message of the first message according to the second message synchronization request;
[0152] S404. Receive the next message determined by the first master node;
[0153] Wherein, the first message is received by the first master node from the control device, and by the control device from the message writer device. The next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device.
[0154] Specifically, optionally, when the first master node synchronizes the first message to the one or more first slave nodes, it may specifically include:
[0155] For each of the one or more first slave nodes, obtain the first message synchronization request of the first slave node;
[0156] The corresponding message to be synchronized is determined based on the first message synchronization request;
[0157] If it is determined that the message to be synchronized contains the first message, then the first message is synchronized to the first slave node.
[0158] Optionally, the method further includes:
[0159] S41. If a notification message indicating that the connection between the control device and the second master node has been interrupted is detected by the control device, a master node creation request is sent to the control device.
[0160] S42. Receive feedback information from the control device based on the master node creation request;
[0161] S43. If the feedback information indicates successful creation, then update its own device attributes to the first master node; if the feedback information indicates failure to create, then do not process it; wherein, the second master node is the master node in the message queue telemetry transmission cluster before the first master node was created.
[0162] Optionally, the aforementioned control device may be configured with ZooKeeper. When the control device detects that its connection with the second master node is interrupted, or that the second master node experiences other abnormalities, the control device sends corresponding notification information to one or more first slave nodes.
[0163] Specifically, after each of the aforementioned one or more first slave nodes receives the notification information, it sends a master node creation request to the control device to apply to the zookeeper in the control device to create itself as the first master node.
[0164] Optionally, the control device sets the fourth slave node corresponding to the earliest received master node creation request as the first master node, and the control device sends feedback information indicating that the fourth slave node has been successfully set as the first master node to the fourth slave node, and marks the fourth slave node as the first master node.
[0165] After the control device sets the fourth slave node as the first master node, the method further includes: sending a failure message indicating that the master node creation has failed to the first slave node corresponding to the received master node creation request.
[0166] Optionally, the above method further includes:
[0167] Obtain the query information sent by the first master node;
[0168] Based on the query information, determine whether there is a target message that the first master node has not stored. If there is, the target message is fed back to the first master node. If not, do not process it, or feed back a preset query failure flag.
[0169] This scheme allows the first master node to contain the latest messages in the message queue telemetry transmission cluster.
[0170] The solution of this application, by setting up a control device, a first master node, and one or more first slave nodes in a message queue telemetry transmission cluster, and having any one of the one or more first slave nodes send a first message synchronization request to the first master node at a preset period, so that the first master node determines the corresponding first message based on the first message synchronization request; receiving the first message determined by the first master node based on the first message synchronization request; sending a second message synchronization request to the first master node at the preset period, so that the first master node determines the next message based on the second message synchronization request; and receiving the next message determined by the first master node; wherein, the first message is received by the first master node from the control device, and the control device receives it from the message writer device, and the next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device, this solution greatly saves the total time of the process of writing multiple messages to the message queue telemetry transmission cluster and improves the efficiency of message writing.
[0171] The following section provides a further explanation of this solution using specific message processing sequences; please refer to [link / reference needed]. Figure 5 As shown,
[0172] S1. The message writer device writes message a (which can be the aforementioned first message) to the control device;
[0173] S2. After the control device obtains message a, it writes message a to the first master node;
[0174] S3. The first master node stores message a in the local log and adds the message identifier of message a to the message identifier sequence (which can be the aforementioned first message identifier sequence);
[0175] S4. The first slave node 1 requests replication (i.e., synchronization) from the first master node via message a;
[0176] S5. The first master node sends message a to the first slave node 1;
[0177] S6. The first slave node 1 sends message a message indicating successful replication to the first master node;
[0178] S7. The first master node recorded that message a was successfully copied from the first slave node 1.
[0179] S8. The first slave node 2 requests replication (i.e., synchronization) from the first master node.
[0180] S9. The first master node sends message a to the first slave node 2;
[0181] S10. The first slave node 2 sends message a message indicating successful replication to the first master node;
[0182] S11, The first master node records that message a was successfully copied from the first slave node 2;
[0183] S12. After the first master node confirms that the first slave node 1 and the second slave node 2 have successfully replicated message a, message a is set as a consumable message.
[0184] S13. Send message a to the subscriber device.
[0185] Specifically, after the control device writes message a to the first master node, it can send a first prompt message to the message writer device in step S01, so that the message writer can write the next message of message a, message b, to the first master node in step S02.
[0186] All of the above technical solutions can be combined in any way to form optional embodiments of this application, and will not be described in detail here.
[0187] To facilitate better implementation of the message processing method of this application embodiment, this application embodiment also provides a message processing apparatus, suitable for control equipment in a message queue telemetry transmission cluster. Figure 6 This is a schematic diagram of the message processing device 60. The message queue telemetry transmission cluster further includes a first master node and one or more first slave nodes. The message processing device 60 includes:
[0188] The acquisition unit 61 is used to acquire a first message written by the message writer device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0189] Sending unit 62 is used to send the first message to the first master node, so that the first master node synchronizes the first message to the one or more first slave nodes;
[0190] The sending unit 62 is further configured to send a first prompt message to the message writer device indicating that the first message has been written, the first prompt message being used to prompt the message writer device to write the next message to the control device.
[0191] Optionally, the message processing device 60 described above is further configured to:
[0192] When a connection interruption with the second master node is detected, a corresponding notification message is sent to the one or more first slave nodes. The second master node is the master node in the message queue telemetry transmission cluster before the first master node was created.
[0193] Receive a master node creation request sent by one or more first slave nodes after obtaining the notification information;
[0194] The first master node is created according to the master node creation request.
[0195] Each of the above-mentioned units can be implemented entirely or partially through software, hardware, or a combination thereof. These units can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can invoke and execute the operations corresponding to each unit.
[0196] This application embodiment also provides a message processing device 70, applicable to the device corresponding to the first master node in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a control device and one or more first slave nodes. Figure 7 This is a schematic diagram of the message processing device 70, which includes:
[0197] The receiving unit 71 is configured to receive a first message sent by the control device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0198] Synchronization unit 72 is used to synchronize the first message to the one or more first slave nodes;
[0199] The receiving unit 71 is further configured to receive the next message sent by the control device and synchronize the next message to the one or more first slave nodes, wherein the next message is a first prompt message sent by the control device to the message writer device after sending the first message to the device corresponding to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device.
[0200] Optionally, when synchronizing the first message to the one or more first slave nodes, the synchronization unit 72 is specifically used for:
[0201] For each of the one or more first slave nodes, obtain the first message synchronization request of the first slave node;
[0202] The corresponding message to be synchronized is determined based on the first message synchronization request;
[0203] If it is determined that the message to be synchronized contains the first message, then the first message is synchronized to the first slave node.
[0204] Optionally, the first message synchronization request includes a message identifier for the second message, where the second message is the message most recently synchronized by the first slave node. Optionally, when the synchronization unit 72 determines the corresponding message to be synchronized based on the first message synchronization request, it is specifically used for:
[0205] Obtain a first message identifier sequence, which contains multiple message identifiers. Each message identifier in the multiple message identifiers corresponds to a candidate synchronization message. The later the first master node obtains the candidate synchronization message, the closer the message identifier corresponding to the candidate synchronization message is to the end of the first message identifier sequence.
[0206] The message to be synchronized is determined based on the sequence of the message identifier of the second message and the first message identifier.
[0207] Optionally, when the synchronization unit 72 determines the message to be synchronized based on the sequence of the message identifier of the second message and the first message identifier, it specifically performs the following:
[0208] A first message identifier that is identical to the message identifier of the second message is found in the first message identifier sequence;
[0209] Obtain a second message identifier sequence located between the first message identifier and the end message identifier at the end of the first message identifier sequence, wherein the end message identifier is included in the second message identifier sequence;
[0210] The candidate synchronization message corresponding to the second message identifier sequence is taken as the message to be synchronized.
[0211] Optionally, the first message synchronization request may also include a first topic identifier corresponding to the message identifier of the second message. When the synchronization unit 72 is used to obtain the first message identifier sequence, it is specifically used to: determine the first message identifier sequence according to the first topic identifier and the preset correspondence.
[0212] Optionally, the first message synchronization request further includes the first node identifier of the first slave node, and the device corresponding to the first master node is further used for:
[0213] Based on the first node identifier, determine the first total number of messages in the first master node that need to be synchronized by the first slave node, and the first number of messages that the first slave node has already synchronized from the first master node;
[0214] If the difference between the first total number of messages and the first number of messages is not less than a preset difference, then the first node identifier is moved from the first node identifier list to the second node identifier list;
[0215] The first node identifier list stores one or more second node identifiers. For the second slave node corresponding to the second node identifier, the difference between the second total number of messages in the first master node that need to be synchronized by the second slave node and the second message number of messages that the second slave node has synchronized from the first master node is less than a preset difference. The second node identifier list stores one or more third node identifiers. For the third slave node corresponding to the third node identifier, the difference between the third total number of messages in the first master node that need to be synchronized by the third slave node and the third message number of messages that the third slave node has synchronized from the first master node is not less than a preset difference.
[0216] Optionally, the first message identifier sequence further includes the consumption status of each candidate synchronization message, wherein the consumption status includes either consumable or non-consumable, and the device corresponding to the first master node is further used for:
[0217] For each candidate synchronization message, it is detected whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, the consumption status of the candidate synchronization message in the first message identifier sequence is set to consumeable. If no, no processing is performed. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
[0218] Each of the above-mentioned units can be implemented entirely or partially through software, hardware, or a combination thereof. These units can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can invoke and execute the operations corresponding to each unit.
[0219] This application also provides a message processing apparatus, applicable to the device corresponding to any one of the first slave nodes in a message queue telemetry transmission cluster. Figure 8 This is a schematic diagram of the message processing device 80. The message queue telemetry transmission cluster further includes a first master node and a control device. The message processing device 80 includes:
[0220] The sending unit 81 is used to send a first message synchronization request to the first master node according to a preset period, so that the first master node determines the corresponding first message according to the first message synchronization request.
[0221] Receiving unit 82 is used to receive the first message determined by the first master node according to the first message synchronization request;
[0222] The sending unit 81 is further configured to send a second message synchronization request to the first master node according to the preset period, so that the first master node determines the next message of the first message according to the second message synchronization request;
[0223] The receiving unit 82 is also configured to receive the next message determined by the first master node;
[0224] Wherein, the first message is received by the first master node from the control device, and by the control device from the message writer device. The next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device.
[0225] Optionally, the message processing device 80 is further configured to:
[0226] If a notification message indicating an interruption in the connection between the control device and the second master node is detected, a master node creation request is sent to the control device.
[0227] Receive feedback information from the control device based on the request created by the master node;
[0228] If the feedback information indicates successful creation, then update its own device attributes to the first master node; if the feedback information indicates failure to create, then do not process it.
[0229] The second master node is the master node in the message queue telemetry transmission cluster that was created before the first master node was created.
[0230] Optionally, the message processing device 80 is further configured to:
[0231] Obtain the query information sent by the first master node;
[0232] Based on the query information, determine whether there is a target message that the first master node has not stored. If there is, the target message is fed back to the first master node. If not, do not process it, or feed back a preset query failure flag.
[0233] Each of the above-mentioned units can be implemented entirely or partially through software, hardware, or a combination thereof. These units can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can invoke and execute the operations corresponding to each unit.
[0234] Optionally, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0235] Figure 9 A schematic diagram of the structure of the computer device provided in the embodiments of this application, such as... Figure 9 As shown, the computer device 900 may include: a communication interface 901, a memory 902, a processor 903, and a communication bus 904. The communication interface 901, memory 902, and processor 903 communicate with each other via the communication bus 904. The communication interface 901 is used for data communication between the computer device 900 and external devices. The memory 902 can be used to store software programs and modules, and the processor 903 executes the software programs and modules stored in the memory 902, such as the software programs for the corresponding operations in the aforementioned method embodiments.
[0236] Optionally, the processor 903 can invoke software programs and modules stored in the memory 902 to perform the following operations:
[0237] Obtain the first message written by the message writer device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device;
[0238] The first message is sent to the first master node, so that the first master node synchronizes the first message to the one or more first slave nodes;
[0239] A first notification message indicating that the first message has been written is sent to the message writer device. The first notification message is used to prompt the message writer device to write the next message to the control device.
[0240] Optionally, the processor 903 can invoke software programs and modules stored in the memory 902 to perform the following operations:
[0241] Receive a first message sent by the control device, the first message including messages subscribed to by the subscriber device corresponding to the message writer device;
[0242] Synchronize the first message to the one or more first slave nodes;
[0243] The system receives the next message sent by the control device and synchronizes the next message to the one or more first slave nodes. The next message is a first prompt message sent by the control device to the message writer device after sending the first message to the device corresponding to the first master node, indicating that the first message has been written. This prompts the message writer device to write the message to the control device.
[0244] Optionally, the processor 903 can invoke software programs and modules stored in the memory 902 to perform the following operations:
[0245] A first message synchronization request is sent to the first master node according to a preset period, so that the first master node determines the corresponding first message based on the first message synchronization request.
[0246] Receive the first message determined by the first master node based on the first message synchronization request;
[0247] The first master node sends a second message synchronization request to the first master node according to the preset period, so that the first master node determines the next message of the first message based on the second message synchronization request.
[0248] Receive the next message determined by the first master node;
[0249] The first message is received by the first master node from the control device and by the control device from the message writer device. The next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written. This prompts the message writer device to write the message to the control device.
[0250] This application also provides a computer-readable storage medium for storing a computer program. This computer-readable storage medium can be applied to a computer device, and the computer program causes the computer device to execute the corresponding processes in the methods described in the embodiments of this application; for brevity, these will not be elaborated further here.
[0251] This application also provides a computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the corresponding processes in the methods described in the embodiments of this application. For brevity, these details will not be elaborated further here.
[0252] This application also provides a computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the corresponding processes in the methods described in the embodiments of this application. For the sake of brevity, these details will not be elaborated further here.
[0253] It should be understood that the processor in the embodiments of this application may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method embodiments can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor described above can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0254] It is understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DR RAM). It should be noted that the memory used in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0255] It should be understood that the above-described memory is exemplary and not a limiting description. For example, the memory in the embodiments of this application may also be static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DR RAM), etc. That is to say, the memory in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0256] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0257] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0258] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0259] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0260] In addition, the functional units in the embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0261] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer or a server) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0262] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A message processing method, characterized in that, The method is applicable to control devices in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a first master node and one or more first slave nodes, and includes: Obtain the first message written by the message writer device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device; The first message is sent to the first master node, so that the first master node synchronizes the first message to the one or more first slave nodes; Send a first notification message to the message writer device indicating that the first message has been written, the first notification message being used to instruct the message writer device to write the next message to the control device; When the first master node synchronizes the first message to the one or more first slave nodes, it is specifically configured to: obtain a first message synchronization request from each of the one or more first slave nodes; determine the corresponding message to be synchronized based on the first message synchronization request; and if it is determined that the message to be synchronized contains the first message, synchronize the first message to the first slave node. The first message synchronization request includes the message identifier of the second message, which is the message that the first slave node has recently synchronized. When the first master node determines the corresponding message to be synchronized based on the first message synchronization request, it specifically performs the following steps: obtaining a first message identifier sequence, which includes multiple message identifiers, each of which corresponds to a candidate synchronization message; and determining the message to be synchronized based on the message identifier of the second message and the first message identifier sequence. The first message identifier sequence also includes the consumption status of each candidate synchronization message, wherein the consumption status includes either consumable or non-consumable. The first master node is further configured to: for each candidate synchronization message, detect whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, then set the consumption status of the candidate synchronization message in the first message identifier sequence to consumable; otherwise, do not process it. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
2. The method according to claim 1, characterized in that, The method further includes: When a connection interruption with the second master node is detected, a corresponding notification message is sent to the one or more first slave nodes. The second master node is the master node in the message queue telemetry transmission cluster before the first master node was created. Receive a master node creation request sent by one or more first slave nodes after obtaining the notification information; The first master node is created according to the master node creation request.
3. A message processing method, characterized in that, Applicable to the device corresponding to the first master node in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a control device and one or more first slave nodes, the method includes: Receive a first message sent by the control device, the first message including messages subscribed to by the subscriber device corresponding to the message writer device; Synchronize the first message to the one or more first slave nodes; The control device receives the next message sent by the control device and synchronizes the next message to the one or more first slave nodes. The next message is a first prompt message sent by the control device to the message writer device after the first message is sent to the device corresponding to the first master node, indicating that the first message has been written. This prompts the message writer device to write the message to the control device. The step of synchronizing the first message to the one or more first slave nodes includes: for each of the one or more first slave nodes, obtaining a first message synchronization request from the first slave node; determining the corresponding message to be synchronized based on the first message synchronization request; and if it is determined that the message to be synchronized contains the first message, then synchronizing the first message to the first slave node. The first message synchronization request includes a message identifier of a second message, where the second message is the message most recently synchronized by the first slave node. The step of determining the corresponding message to be synchronized based on the first message synchronization request includes: obtaining a first message identifier sequence, which includes multiple message identifiers, each of which corresponds to a candidate synchronization message; and determining the message to be synchronized based on the message identifier of the second message and the first message identifier sequence. The first message identifier sequence also includes the consumption status of each candidate synchronization message, wherein the consumption status includes either consumable or non-consumable. The process further includes: for each candidate synchronization message, detecting whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, the consumption status of the candidate synchronization message in the first message identifier sequence is set to consumable; otherwise, no processing is performed. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
4. The method according to claim 3, characterized in that, The step of determining the message to be synchronized based on the message identifier of the second message and the sequence of the first message identifier includes: A first message identifier that is identical to the message identifier of the second message is found in the first message identifier sequence; Obtain a second message identifier sequence located between the first message identifier and the end message identifier at the end of the first message identifier sequence, wherein the end message identifier is included in the second message identifier sequence; The candidate synchronization message corresponding to the second message identifier sequence is taken as the message to be synchronized.
5. A message processing method, characterized in that, The method is applicable to a device corresponding to any one of one or more first slave nodes in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a first master node and a control device, and the method includes: A first message synchronization request is sent to the first master node according to a preset period, so that the first master node determines the corresponding first message based on the first message synchronization request. Receive the first message determined by the first master node based on the first message synchronization request; The first master node sends a second message synchronization request to the first master node according to the preset period, so that the first master node determines the next message of the first message based on the second message synchronization request. Receive the next message determined by the first master node; Wherein, the first message is received by the first master node from the control device and by the control device from the message writer device, and the next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device. The first message synchronization request includes the message identifier of the second message, which is the message that the first slave node has recently synchronized. When the first master node determines the corresponding message to be synchronized based on the first message synchronization request, it specifically performs the following steps: obtaining a first message identifier sequence, which includes multiple message identifiers, each of which corresponds to a candidate synchronization message; and determining the message to be synchronized based on the message identifier of the second message and the first message identifier sequence. The first message identifier sequence also includes the consumption status of each candidate synchronization message, wherein the consumption status includes either consumable or non-consumable. The first master node is further configured to: for each candidate synchronization message, detect whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, then set the consumption status of the candidate synchronization message in the first message identifier sequence to consumable; otherwise, do not process it. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
6. The method according to claim 5, characterized in that, The method further includes: If a notification message indicating an interruption in the connection between the control device and the second master node is detected, a master node creation request is sent to the control device. Receive feedback information from the control device based on the request created by the master node; If the feedback information indicates successful creation, then update its own device attributes to the first master node; if the feedback information indicates failure to create, then do not process it. The second master node is the master node in the message queue telemetry transmission cluster that was created before the first master node was created.
7. A message processing device, characterized in that, A control device suitable for a message queue telemetry transmission cluster, the message queue telemetry transmission cluster further comprising a first master node and one or more first slave nodes, the device comprising: The acquisition unit is used to acquire a first message written by the message writer device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device; The sending unit is configured to send the first message to the first master node, so that the first master node synchronizes the first message to the one or more first slave nodes; The sending unit is further configured to send a first prompt message to the message writing device indicating that the first message has been written, the first prompt message being used to prompt the message writing device to write the next message to the control device; When the first master node synchronizes the first message to the one or more first slave nodes, it is specifically configured to: obtain a first message synchronization request from each of the one or more first slave nodes; determine the corresponding message to be synchronized based on the first message synchronization request; and if it is determined that the message to be synchronized contains the first message, synchronize the first message to the first slave node. The first message synchronization request includes the message identifier of the second message, which is the message that the first slave node has recently synchronized. When the first master node determines the corresponding message to be synchronized based on the first message synchronization request, it specifically performs the following steps: obtaining a first message identifier sequence, which includes multiple message identifiers, each of which corresponds to a candidate synchronization message; and determining the message to be synchronized based on the message identifier of the second message and the first message identifier sequence. The first message identifier sequence also includes the consumption status of each candidate synchronization message, wherein the consumption status includes either consumable or non-consumable. The first master node is further configured to: for each candidate synchronization message, detect whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, then set the consumption status of the candidate synchronization message in the first message identifier sequence to consumable; otherwise, do not process it. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
8. A message processing device, characterized in that, A device applicable to the first master node in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a control device and one or more first slave nodes, the device comprising: The receiving unit is configured to receive a first message sent by the control device, wherein the first message includes messages subscribed to by the subscriber device corresponding to the message writer device; A synchronization unit is configured to synchronize the first message to the one or more first slave nodes; The receiving unit is further configured to receive the next message sent by the control device and synchronize the next message to the one or more first slave nodes, wherein the next message is a first prompt message sent by the control device to the message writer device after sending the first message to the device corresponding to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device; When the synchronization unit is used to synchronize the first message to the one or more first slave nodes, it is specifically used to: for each of the one or more first slave nodes, obtain a first message synchronization request from the first slave node; determine the corresponding message to be synchronized according to the first message synchronization request; if it is determined that the message to be synchronized contains the first message, then synchronize the first message to the first slave node. The first message synchronization request includes a message identifier of the second message, where the second message is the message most recently synchronized by the first slave node. When the synchronization unit determines the corresponding message to be synchronized based on the first message synchronization request, it specifically performs the following steps: obtaining a first message identifier sequence, which includes multiple message identifiers, each of which corresponds to a candidate synchronization message; and determining the message to be synchronized based on the message identifier of the second message and the first message identifier sequence. The first message identifier sequence also includes the consumption status of each candidate synchronization message. The consumption status includes either consumable or non-consumable. The device corresponding to the first master node is further configured to: for each candidate synchronization message, detect whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, set the consumption status of the candidate synchronization message in the first message identifier sequence to consumable. If no, do not process it. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
9. A message processing device, characterized in that, A device applicable to any one of the first slave nodes in a message queue telemetry transmission cluster, wherein the message queue telemetry transmission cluster further includes a first master node and a control device, the device comprising: The sending unit is used to send a first message synchronization request to the first master node according to a preset period, so that the first master node determines the corresponding first message according to the first message synchronization request. The receiving unit is configured to receive the first message determined by the first master node based on the first message synchronization request; The sending unit is further configured to send a second message synchronization request to the first master node according to the preset period, so that the first master node determines the next message of the first message according to the second message synchronization request; The receiving unit is further configured to receive the next message determined by the first master node; Wherein, the first message is received by the first master node from the control device and by the control device from the message writer device, and the next message is a first prompt message sent by the control device to the message writer device after sending the first message to the first master node, indicating that the first message has been written, so that the message writer device writes the message to the control device. The first message synchronization request includes the message identifier of the second message, which is the message that the first slave node has recently synchronized. When the first master node determines the corresponding message to be synchronized based on the first message synchronization request, it specifically performs the following steps: obtaining a first message identifier sequence, which includes multiple message identifiers, each of which corresponds to a candidate synchronization message; and determining the message to be synchronized based on the message identifier of the second message and the first message identifier sequence. The first message identifier sequence also includes the consumption status of each candidate synchronization message, wherein the consumption status includes either consumable or non-consumable. The first master node is further configured to: for each candidate synchronization message, detect whether the candidate synchronization message has been synchronized by the target slave node in the message queue telemetry transmission cluster. If yes, then set the consumption status of the candidate synchronization message in the first message identifier sequence to consumable; otherwise, do not process it. The target slave node is all the first slave nodes in the message queue telemetry transmission cluster, or all the first slave nodes whose corresponding node identifiers are located in the first node identifier list.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted for loading by a processor to perform the message processing method of any one of claims 1-2, any one of claims 3-4, or any one of claims 5-6.
11. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program, and the processor executing the message processing method according to any one of claims 1-2, any one of claims 3-4, or any one of claims 5-6 by calling the computer program stored in the memory.
12. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the message processing method of any one of claims 1-2, any one of claims 3-4, or any one of claims 5-6.
Citation Information
Patent Citations
Internet of Things message information transmission method, device and server
CN114553903A
