A method for processing downlink messages and acknowledgement messages based on a message queue

By introducing a publish/subscribe pattern for message queues into the IoT system and using device and server identifiers to construct multiple message topics, the problem of low efficiency in downlink message transmission and acknowledgment message reply for custom protocol devices is solved, achieving efficient connection and fast communication for device management.

CN116192942BActive Publication Date: 2026-01-20SICHUAN JINGKING WEIDA SMART TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310166190.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-24
Publication Date
2026-01-20
Estimated Expiration
2043-02-24

AI Technical Summary

Technical Problem

In existing technologies, IoT device management systems cannot efficiently achieve accurate transmission of downlink messages and rapid response of acknowledgment messages when dealing with devices using custom protocols, especially in environments with a large number of devices and servers, resulting in low efficiency in connection management and communication.

Method used

By adopting a publish/subscribe model based on message queues, and through the collaborative work of business servers, message queue servers, and connection servers, multiple message topics are constructed using device identifiers and server identifiers to achieve accurate transmission of downlink messages and rapid response to acknowledgment messages.

Benefits of technology

It improves the accuracy and speed of downlink device control data transmission and the precise response of confirmation data, optimizes the connection management of massive devices, and enhances the system's response speed and processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116192942B_ABST
    Figure CN116192942B_ABST
Patent Text Reader

Abstract

The application discloses a downlink message and acknowledgement message processing method based on a message queue, and the downlink message processing method comprises the following steps: a service server receives a downlink message request, acquires message content and device identification allowed to receive the message content; the service server assembles a downlink message according to the message content, the device identification and service server identification, and finds corresponding connection server identification, constructs a plurality of different message topics according to the connection server identification; the service server sends the downlink message to a message queue server through the plurality of message topics; the message queue server pushes the downlink message to corresponding connection servers according to preset grouping rules and message topic subscription conditions; the connection servers analyze the downlink message, acquire service server identification, device identification and message content, and forward the downlink message to corresponding devices according to the device identification; and the devices receive and process the downlink message. The application effectively realizes accurate distribution and accurate reply of the downlink message.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet of Things device management, and particularly relates to a downlink message and acknowledgement message processing method based on a message queue. BACKGROUND

[0002] In the prior art, for management of a large number of Internet of Things devices, there are usually two implementation methods according to whether the device communication protocol is standardized:

[0003] 1. Standardized device management based on an MQTT protocol

[0004] The MQTT is a communication protocol based on a publish / subscribe mode, and is built on the TCP / IP protocol. The greatest advantage of the MQTT is that it provides real-time and reliable message services for connecting remote devices with very little code and limited bandwidth. Each device subscribes to a TOPIC corresponding to the message to be received, and when the business server needs to send data to the device, the message is sent to the corresponding TOPIC, so that the device can receive the corresponding data. Meanwhile, the MQTT also supports wildcards, thereby realizing broadcast of the message. However, the limitation of this scheme is that the device must support the MQTT protocol. If the device does not support the MQTT protocol, this mode cannot be used.

[0005] 2. Individualized device management based on a self-defined protocol

[0006] At present, many devices do not support the MQTT protocol, but define a TCP-based application layer transmission protocol, and the transmission protocols between different types of devices are also inconsistent. In the individualized device management mode of the self-defined protocol, the system must find the connection server connected by the downlink message in order to send data to the device, that is, the business server must first find the connection server accessed by the device to complete the subsequent process. There are many different implementations of how to find the connection server corresponding to the device, and the usual method is to save the connection server address connected by each device to a database or a global cache, and the business server directly connects to the server to realize data sending by querying the database or the global cache for the connection server address each time data is sent. The query step is complicated, and seriously affects the message sending and processing efficiency. SUMMARY

[0007] Therefore, it is necessary to propose a downlink message and acknowledgement message processing method based on a message queue in view of the above problems.

[0008] The application discloses a downlink message processing method based on a message queue, which is applied to an Internet of Things system. The Internet of Things system comprises a business server, a message queue server, a connection server and devices which are connected in communication.

[0009] The method comprises:

[0010] The business server receives a sending request of a downlink message, and according to the sending request, acquires downlink message content and a device identifier of a specified device receiving the downlink message content;

[0011] The business server assembles a downlink message according to the downlink message content, the device identifier and a business server identifier, and finds a connection server identifier corresponding to the device identifier from a cache, and constructs a plurality of different first message topics according to the connection server identifier;

[0012] The business server sends the downlink message to a message queue server through the plurality of different first message topics respectively;

[0013] The message queue server pushes the downlink message to a corresponding connection server according to a preset grouping rule and a message topic subscription condition of the connection server;

[0014] The connection server receives and parses the downlink message, and obtains a business server identifier, a device identifier and downlink message content in the downlink message, and forwards the downlink message to a corresponding device according to the device identifier;

[0015] The device receives the downlink message and performs business processing on the downlink message.

[0016] Further, the message queue server pushes the downlink message to a corresponding connection server according to a preset grouping rule and a message topic subscription condition of the connection server, and specifically comprises:

[0017] The message queue server divides all connection servers in the same group, and each connection server subscribes to different first message topics according to its own connection server identifier;

[0018] The message queue server pushes the downlink message to a corresponding connection server according to the first message topics subscribed by each connection server.

[0019] Further, the downlink message content specifically comprises downlink message data and a message identifier, and the message identifier is used to track the sending state of the current downlink message data.

[0020] Further, the business server assembles a downlink message according to the downlink message content, the device identifier and a business server identifier, and specifically comprises:

[0021] The service server assembles the downlink message according to the downlink message data, the message identifier, the device identifier, and the service server identifier in the format of "service server identifier: device identifier: message identifier: downlink message data".

[0022] In another aspect, the application also discloses a message queue-based confirmation message processing method applied to an Internet of Things system, wherein the Internet of Things system comprises a service server, a message queue server, a connection server, and a device which are connected in communication with each other.

[0023] The method comprises the following steps.

[0024] The device receives the downlink message in the downlink message processing method, generates confirmation data for replying to the downlink message, and sends the confirmation data and the device identifier to the connection server.

[0025] The connection server obtains the service server identifier and the message identifier in the downlink message according to the downlink message in the downlink message processing method.

[0026] The connection server assembles a confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier, and constructs a plurality of different second message topics according to the service server identifier.

[0027] The connection server sends the confirmation message to the message queue server through the plurality of different second message topics respectively.

[0028] The message queue server pushes the confirmation message to the corresponding service server according to a preset grouping rule and a topic subscription condition of the service server.

[0029] The service server receives and analyzes the confirmation message, obtains the connection server identifier, the device identifier, the message identifier, and the confirmation data in the confirmation message, and processes the confirmation data.

[0030] Further, the message queue server pushes the confirmation message to the corresponding service server according to a preset grouping rule and a message topic subscription condition of the service server, and the specific process comprises the following steps.

[0031] The message queue server divides all the service servers into the same group, and each service server subscribes to different second message topics according to its own service server identifier.

[0032] The message queue server pushes the confirmation message to the corresponding service server according to the second message topics subscribed by each service server.

[0033] Further, the connection server assembles an acknowledgement message according to the acknowledgement data, the device identifier, the message identifier, and the connection server identifier, specifically including:

[0034] The connection server assembles an acknowledgement message according to the acknowledgement data, the device identifier, the message identifier, and the connection server identifier, in the format of "connection server identifier: device identifier: message identifier: acknowledgement data".

[0035] Further, the Internet of Things system further comprises a load balancing server;

[0036] The device sends the acknowledgement data to the connection server, specifically including:

[0037] The device sends the acknowledgement data to the idle connection server through the load balancing server.

[0038] In another aspect, the present application also discloses a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to make the processor execute the following steps of the downlink message processing method:

[0039] The service server receives a sending request of a downlink message, and according to the sending request, obtains downlink message content and a device identifier of a specified device allowed to receive the downlink message content;

[0040] The service server assembles a downlink message according to the downlink message content, the device identifier, and a service server identifier, and finds a connection server identifier corresponding to the device identifier from a cache, and constructs a plurality of different first message topics according to the connection server identifier;

[0041] The service server sends the downlink message to a message queue server through the plurality of different first message topics respectively;

[0042] The message queue server pushes the downlink message to a corresponding connection server according to a preset grouping rule and a message topic subscription condition of the connection server;

[0043] The connection server receives and parses the downlink message, obtains a service server identifier, a device identifier, and downlink message content in the downlink message, and forwards the downlink message to a corresponding device according to the device identifier;

[0044] The device receives the downlink message, and performs service processing on the downlink message;

[0045] And / or executes the following steps of the acknowledgement message processing method:

[0046] The device receives the downlink message, generates confirmation data in reply to the downlink message, and sends the confirmation data and the device identifier to the connection server;

[0047] The connection server obtains the service server identifier and the message identifier in the downlink message according to the downlink message processing method;

[0048] The connection server assembles a confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier, and constructs a plurality of different second message topics according to the service server identifier;

[0049] The connection server sends the confirmation message to the message queue server through the plurality of different second message topics respectively;

[0050] The message queue server pushes the confirmation message to the corresponding service server according to a preset grouping rule and a topic subscription condition of the service server;

[0051] The service server receives and analyzes the confirmation message, obtains the connection server identifier, the device identifier, the message identifier, and the confirmation data in the confirmation message, and performs service processing on the confirmation data.

[0052] In another aspect, the application also discloses a computer readable storage medium storing a computer program, which is executed by a processor to make the processor execute the following downlink message processing method steps:

[0053] The service server receives a sending request of a downlink message, and obtains downlink message content and a device identifier of a specified device allowed to receive the downlink message content according to the sending request;

[0054] The service server assembles a downlink message according to the downlink message content, the device identifier, and a service server identifier, finds a connection server identifier corresponding to the device identifier from a cache, and constructs a plurality of different first message topics according to the connection server identifier;

[0055] The service server sends the downlink message to the message queue server through the plurality of different first message topics respectively;

[0056] The message queue server pushes the downlink message to the corresponding connection server according to a preset grouping rule and a message topic subscription condition of the connection server;

[0057] The connection server receives and parses the downlink message, obtains the service server identifier, the device identifier, and the downlink message content in the downlink message, and forwards the downlink message to the corresponding device according to the device identifier;

[0058] The device receives the downlink message and performs service processing on the downlink message;

[0059] and / or performs the following steps of the confirmation message processing method:

[0060] The device receives the downlink message in the above downlink message processing method, generates confirmation data in reply to the downlink message, and sends the confirmation data and the device identifier to the connection server;

[0061] The connection server obtains the service server identifier and the message identifier in the downlink message according to the downlink message in the above downlink message processing method;

[0062] The connection server assembles a confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier, and constructs a plurality of different second message topics according to the service server identifier;

[0063] The connection server sends the confirmation message to the message queue server through the plurality of different second message topics respectively;

[0064] The message queue server pushes the confirmation message to the corresponding service server according to a preset grouping rule and the topic subscription condition of the service server;

[0065] The service server receives and parses the confirmation message, obtains the connection server identifier, the device identifier, the message identifier, and the confirmation data in the confirmation message, and performs service processing on the confirmation data.

[0066] The present application has the following beneficial effects:

[0067] The present application is based on a message queue and realizes communication between servers by using a message publishing / subscription mode, thereby improving response speed and effectively ensuring that downlink device control and / or management data sent by a service server can accurately and quickly reach the corresponding device through a connection server, so that accurate data delivery is realized. At the same time, the confirmation data of the device for the downlink data can be accurately and quickly distributed to the service server, so that accurate command reply is realized. BRIEF DESCRIPTION OF DRAWINGS

[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description only represent some embodiments of the present application, and for those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0069] Wherein:

[0070] Figure 1 An application environment diagram of the downlink message and the confirmation message processing method in an embodiment;

[0071] Figure 2 A flowchart of the downlink message processing method in an embodiment;

[0072] Figure 3 A flowchart of the confirmation message processing method in an embodiment;

[0073] Figure 4 A structural block diagram of a computer device in an embodiment.

[0074] Legend of the accompanying drawings: service server 100, message queue server 200, connection server 300, device 400. DETAILED DESCRIPTION

[0075] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort fall within the scope of protection of the present application.

[0076] Figure 1 An application environment diagram of the downlink message and the confirmation message processing method in an embodiment, based on message queue. Referring to Figure 1 The downlink message and the confirmation message processing method based on message queue are applied to an Internet of Things system, and the Internet of Things system comprises a service server 100, a message queue server 200, a connection server 300 and a device 400 which are connected in communication.

[0077] Specifically, in the present embodiment, the service server 100 is used to be responsible for processing service data, and can be deployed in a cluster mode. Each service server 100 has the same state and can process data of any device.

[0078] The message queue server 200 can be a conventional message queue server such as Kafka, RabbitMQ, etc., and is used to process a large number of messages and support a certain number of connections and Topic subscriptions.

[0079] The connection server 300 is used to process device connections, and a large number of connection servers can be deployed to implement massive device connection management. Each connection server can manage different device connections and only process data of devices connected to the server.

[0080] In current use, many devices use custom transmission protocols and do not support the MQTT protocol, so they cannot use the standardized device management method based on the MQTT protocol to implement effective data delivery. For devices using custom protocols, in a common Internet of Things system (device + management platform), devices are usually connected to the business server of the management platform through a TCP connection server, and in order to implement massive business data processing, multiple connection servers and business servers are often deployed in the system for business load balancing, that is, there is a many-to-many relationship between the connection server and the business server. At the same time, there are a large number of devices in the system, so how to implement effective connection management and corresponding communication between a large number of devices and servers becomes a problem to be solved.

[0081] In the embodiment, a message queue server is introduced, and a message publishing / subscription mode is used to implement communication, improve response speed, and effectively ensure that the downlink device control and / or management data sent by the business server can accurately and quickly reach the corresponding device through the connection server to implement accurate data delivery. At the same time, the confirmation data of the device to the downlink data can be accurately and quickly distributed to the business server to implement accurate command reply, perfectly solving the problem of ineffective connection management and communication in the Internet of Things system in the prior art. At the same time, the conventional message queue server (such as Kafka, RabbitMQ, etc.) usually only has massive message processing capability, and the number of Topics and connections it supports is limited, and it is impossible to allocate a Topic and / or a connection for each device. Therefore, based on the conventional message queue, a large number of connection servers are deployed to implement massive device connection management, and the connection management capability of the system is further optimized, and massive device connection management is implemented through the cooperation of the connection server and the message queue.

[0082] Specifically, the massive device connection management based on the message queue includes the processes of uplink message reception, downlink message processing, downlink broadcast message processing, and downlink confirmation message processing based on the message queue. The following embodiments describe the downlink message and confirmation message processing method flow based on the message queue.

[0083] As Figure 2As shown, in one embodiment, a message queue-based downlink message processing method is provided, which is applied to an Internet of Things system as shown Figure 1 The method specifically includes the following steps:

[0084] S110, the service server receives a sending request of a downlink message, and according to the sending request, obtains downlink message content and device identification of a specified device allowed to receive the downlink message content;

[0085] S120, the service server assembles a downlink message according to the downlink message content, the device identification, and service server identification, finds a connection server identification corresponding to the device identification from a cache, constructs a plurality of different first message topics according to the connection server identification;

[0086] S130, the service server sends the downlink message to a message queue server through a plurality of different first message topics respectively;

[0087] S140, the message queue server pushes the downlink message to a corresponding connection server according to a preset grouping rule and a message topic subscription condition of the connection server;

[0088] S150, the connection server receives and parses the downlink message, obtains service server identification, device identification, and downlink message content in the downlink message, and forwards the downlink message to a corresponding device according to the device identification;

[0089] S160, the device receives the downlink message and performs service processing on the downlink message.

[0090] In this embodiment, the downlink message content and the request are generated by a management platform, processed by a service server, sent to a message queue server, pushed to a connection server by the message queue server, and reach a device.

[0091] The specific process is as follows: the service server receives a sending request of a downlink message, obtains message content and device identification of a specified device allowed to receive the downlink message content, assembles a downlink message according to the downlink message content, the device identification, and service server identification, finds a connection server identification corresponding to the device identification from a cache, constructs a plurality of different message topics according to the connection server identification, sends the downlink message to a message queue server through a plurality of different message topics respectively, the message queue server pushes the downlink message to a corresponding connection server according to a preset grouping rule and a message topic subscription condition of the connection server, and the connection server receives the downlink message, obtains service server identification, device identification, and downlink message content in the downlink message, and forwards the downlink message to a corresponding device for processing according to the device identification.

[0092] In the embodiment, the device identifier of the specified device allowed to receive the content of the downlink message and the service server identifier of the service server are embedded in the downlink message issued by the service server, so that the source position of the downlink message and the specified receiving device can be quickly and accurately positioned, without excessive global cache query, and the message processing efficiency is greatly improved. Meanwhile, in the embodiment, the connection server identifier of the corresponding management device is found according to the device identifier, and different message topics are constructed by using the connection server identifier to issue the downlink message, so that each connection server only receives the downlink message corresponding to the message topic subscribed by itself, thereby achieving the purpose of accurate issuance of the downlink message.

[0093] Further, in an embodiment, step S140 specifically includes:

[0094] S141, the message queue server divides all connection servers in the same group, and each connection server subscribes to different first message topics according to the connection server identifier of itself;

[0095] S142, the message queue server pushes the downlink message to the corresponding connection server according to the first message topic subscribed by each connection server.

[0096] In the message queue mechanism, the producer sends information to the message queue, and the consumer pulls / acquires information from the message queue. The consumer acquires messages by subscribing to a message topic (abbreviated as: Topic), so it can also be called a subscriber. The subscriber must belong to a certain subscriber group (abbreviated as: group), and the relationship between the subscriber and the subscriber group is individual and group. A subscriber can belong to one or more subscriber groups, and one or more subscribers can exist in a subscriber group. When the producer publishes a message with a specified Topic, multiple subscribers in the same group subscribing to the Topic can receive the message, and only one subscriber can receive the message. While multiple subscribers in different groups subscribing to the Topic can all receive the message. That is, all groups associated with the Topic can receive the message, but only one subscriber in each group can receive the message. Whether the producer or the consumer, in the actual scene, it is composed of various servers. That is, a Topic can be subscribed by different servers in multiple groups, a Topic can be subscribed by different servers in the same group, a Topic cannot be subscribed by a server in a group multiple times, different servers in a group can subscribe to the same Topic, different servers in a group can subscribe to different Topics, and a server in a group cannot subscribe to the same Topic multiple times. Therefore, the Topic and the group form a many-to-many relationship.

[0097] In the embodiment, all the connection servers are divided into the same group, and each connection server in the same group subscribes to a message topic matching the identity of the connection server according to the identity of the connection server, and each connection server only processes the downlink message corresponding to the message topic to which the connection server subscribes, that is, each connection server can receive different downlink messages, thereby realizing accurate positioning of the downlink message to a certain connection server.

[0098] Further, in an embodiment, the downlink message content specifically includes downlink message data and a message identifier, and the message identifier is used to track the sending state of the current downlink message data.

[0099] In the embodiment, the downlink message content can specifically include not only the downlink message data to be sent, but also the message identifier allocated for the specific downlink message data, which is used to track the sending state of the message, help to understand the sending state of the downlink message in real time, and assist in distinguishing and positioning the downlink message in the system.

[0100] Further, in an embodiment, in step S120, the service server assembles the downlink message according to the downlink message content, the device identifier, and the service server identifier, specifically including:

[0101] The service server assembles the downlink message according to the downlink message data, the message identifier, the device identifier, and the service server identifier, in the format of "service server identifier: device identifier: message identifier: downlink message data".

[0102] Specifically, in an embodiment, the downlink message processing method based on the message queue can introduce a message topic of TcpSendOneWithCServerUID type for processing downlink message data, wherein CServerUID is a connection server identifier, which can be replaced by the ID of each connection management service, so that the message topic of this type has multiple ones because the CServerUID of each connection server is different, and the message topic and the connection server are one-to-one corresponding because the message topic TcpSendOneWithCServerUID subscribed by each connection server is different; and a connection server group of SendGroup type is introduced, and all the connection servers subscribing to the message topic TcpSendOneWithCServerUID belong to the group, and the group of this type can have one or more, and one is used in the embodiment.

[0103] The specific composition of the downlink message can include:

[0104] 1) BServerUID, service server identifier, which can be replaced by the ID of each service server, describing which service server sends the current message;

[0105] 2) DeviceUID, device identification, describes which device receives the current message;

[0106] 3) MsgUID, message identification, does not distinguish uplink and downlink messages, and is used to track the sending status of the current message.

[0107] 4) DownMsgData, specific downlink message data in the downlink content generated by the platform, and the data format of different types of devices can be customized;

[0108] The above data can be separated by a colon, that is, assembled into a downlink message in the format of "BServerUID:DeviceUID:MsgUID:DownMsgData".

[0109] The specific downlink message processing process is as follows:

[0110] All connection servers subscribe to the message topic TcpSendOneWithCServerUID in the same group SendGroup. The CServerUID in the message topic TcpSendOneWithCServerUID is the unique identifier of the connection server, which can be replaced by the connection server ID.

[0111] When the management platform sends a downlink message to the device through the business server, the business management server first finds out its unique identifier BServerUID and obtains the platform downlink message data DownMsgData, allocates MsgUID for the downlink message data, and then finds the unique identifier CServerUID of the connection server connected by the device from the global cache according to the unique identifier DeviceUID of the device to be accessed. Then, the downlink message is constructed in the format of "BServerUID:DeviceUID:MsgUID:DownMsgData", and published to the message queue server through the message topic TcpSendOneWithCServerUID.

[0112] Since all connection servers are in the same group SendGroup but subscribe to different message topics, the message topic corresponding to each connection server is different (CServerUID is different), and only the connection server corresponding to the message topic can receive the downlink message carried by the message topic. The business server identifier BServerUID, the device identifier DeviceUID, the message identifier MsgUID, and the downlink data DownMsgData in the downlink message are parsed, and then the downlink data DownMsgData is forwarded to the connected device.

[0113] The device receives the downlink data DownMsgData, analyzes the data according to the corresponding device communication protocol, and then processes the service.

[0114] In addition, as shown in one embodiment, a message queue-based confirmation message processing method is also provided, which is applied to the Internet of Things system as shown in Figure 3 Figure 1 The method specifically includes the following steps:

[0115] S210, the device receives the downlink message in the downlink message processing method, generates confirmation data for replying to the downlink message, and sends the confirmation data and the device identifier to the connection server;

[0116] S220, the connection server obtains the service server identifier and the message identifier in the downlink message according to the downlink message in the downlink message processing method;

[0117] S230, the connection server assembles the confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier, and constructs a plurality of different second message topics according to the service server identifier;

[0118] S240, the connection server sends the confirmation message to the message queue server through a plurality of different second message topics respectively;

[0119] S250, the message queue server pushes the confirmation message to the corresponding service server according to the preset grouping rule and the topic subscription condition of the service server;

[0120] S260, the service server receives and analyzes the confirmation message, obtains the connection server identifier, the device identifier, the message identifier, and the confirmation data in the confirmation message, and processes the confirmation data.

[0121] In this embodiment, the confirmation message is generated by the device. After receiving the downlink message issued by the service server, the device needs to reply to the service server about the processing status of the downlink message. This reply data is the confirmation message (confirmation message for short) of the downlink message. The device sends the confirmation message to the connection server, and the connection server sends the confirmation message to the service management server that previously sent the corresponding downlink message.

[0122] ​The specific process is: the device generates confirmation data and sends it to the connection server, the connection server assembles a confirmation message according to the confirmation data, the device identifier, the message identifier of the original downlink message, and the identifier of the connection server itself, and constructs multiple message topics corresponding to each business server according to the identifier of each business server, and publishes the confirmation message to the message queue server through the multiple message topics, the message queue server pushes the confirmation message to the business management server according to the grouping rule and the message topic subscription of the business server, the business server receives and parses the confirmation message to obtain the connection server identifier, the device identifier, the message identifier and the confirmation data in the confirmation message, and processes the confirmation data.

[0123] In the embodiment, the connection server constructs multiple message topics according to the identifier of each business server, and publishes the confirmation message through the multiple message topics, so that the business server identifier is embedded in the confirmation message, the accurate positioning of the business server can be realized, that is, the accurate reply to the downlink message issued by the previous business server can be realized, at the same time, by embedding the connection server identifier and the device identifier in the confirmation message, the business server can quickly locate the source position of the confirmation data after processing the data, without too much global cache query, which greatly improves the message processing efficiency, in addition, the confirmation message also includes the message identifier of the original downlink message, which is used to specify the downlink message to be confirmed, and the business server can match the confirmation message according to the MsgUID after receiving the message.

[0124] Further, in an embodiment, step S250 specifically includes:

[0125] S251, the message queue server divides all business servers into the same group, and each business server subscribes to different second message topics according to its own business server identifier;

[0126] S252, the message queue server pushes the confirmation message to the corresponding business server according to the second message topic subscribed by each business server.

[0127] In the embodiment, the connection server constructs multiple different message topics according to the identifier of each business server, and publishes the confirmation message through the multiple message topics, when the message queue server divides all business servers into the same group, multiple business servers in the same group subscribe to different message topics, each business server only processes the message topic it subscribes to and processes the corresponding confirmation message, that is, each business server can receive different confirmation messages, so that the accurate positioning of a certain business server can be realized.

[0128] Further, in an embodiment, in step S230, the connection server assembles the confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier, specifically including:

[0129] The connection server assembles the confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier in the format of "connection server identifier: device identifier: message identifier: confirmation data".

[0130] Further, in an embodiment, the Internet of Things system further includes a load balancing server.

[0131] In step S210, the device sends the confirmation data to the connection server, specifically including:

[0132] The device sends the confirmation data to the idle connection server through the load balancing server.

[0133] Specifically, in an embodiment, the message queue-based confirmation message processing method can introduce a message topic Topic of type TcpResponeWithBServerUID for processing the return confirmation data of the downlink message, wherein BServerUID is a business server identifier, which can be replaced by the ID of each business processing service, therefore, the message topic of this type will have multiple and each business server subscribed to TcpResponeWithBServerUID will be different due to different BServerUID, so the message topic and the business server are one-to-one corresponding; and introduce a business server group of type ResponseGroup, all business servers subscribed to the message topic TcpResponeWithBServerUID belong to this group, and the group of this type can have one or more, generally one is enough.

[0134] The specific composition of the confirmation message can include:

[0135] 1) CServerUID, connection server identifier, which can be replaced by the ID of each connection server, describing which connection server sends the current message;

[0136] 2) DeviceUID, device unique identifier, describing which device confirms the current message;

[0137] 3) MsgUID, message identifier, which does not distinguish between uplink and downlink messages, and is used to track the sending state of the current message.

[0138] 4) RespMsgData, specific data in the device confirmation message, and the data format of different types of devices can be customized;

[0139] The above data can be separated by a colon, i.e., assembled into an acknowledgement message in the format of "CServerUID:DeviceUID:MsgUID:RespMsgData".

[0140] The specific acknowledgement message processing flow is as follows:

[0141] All service servers subscribe to the message topic TcpResponeWithBServerUID in the ResponseGroup group. The BServerUID in the message topic TcpResponeWithBServerUID is the unique identifier of the service server, which can be replaced by the service server ID.

[0142] When the device returns an acknowledgement message, it connects to the load balancing server through TCP, and the load balancing server forwards the connection to a relatively idle connection server. After receiving the acknowledgement message sent by the device, the connection server first finds out its own unique identifier CServerUID, then acquires the device unique identifier DeviceUID, and performs packetization and packet assembly according to the device self-defined protocol packet identifier to obtain the device acknowledgement data RespMsgData. According to the previously received downlink message, the message identifier MsgUID and the service server identifier BServerUID are obtained, then an acknowledgement message is constructed in the format of "CServerUID:DeviceUID:MsgUID:RespMsgData", and is published to the message queue server through the message topic TcpResponeWithBServerUID.

[0143] Since all service servers are in the same group ReponseGroup but subscribe to different message topics, the message topic corresponding to each service server is different (BServerUID is different), and only the service server corresponding to each message topic can receive the acknowledgement message carried by the message topic, parse the connection server identifier CServerUID, the device identifier DeviceUID, the message identifier MsgUID (corresponding to the previous downlink message), and the acknowledgement data RespMsgData in the acknowledgement message, and perform service processing on the acknowledgement data DownMsgData.

[0144] Figure 4 An internal structure diagram of a computer device in an embodiment is shown. The computer device can be a terminal or a server. As shown in FIG. 1, the computer device includes a central processing unit (CPU), a memory, a storage device, a keyboard, a mouse, a display screen, and a network interface. Figure 4As shown, the computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system, and can also store a computer program, which, when executed by the processor, can enable the processor to implement the downlink message and acknowledgement message processing method based on the message queue. The computer program can also be stored in the internal memory, and when executed by the processor, the processor can execute the downlink message and acknowledgement message processing method based on the message queue. Those skilled in the art can understand that Figure 4 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.

[0145] In one embodiment, a computer device is provided, including a memory and a processor, the memory stores a computer program, the computer program is executed by the processor to enable the processor to execute the following steps of the downlink message processing method:

[0146] The service server receives a sending request of the downlink message, and according to the sending request, obtains the downlink message content and the device identifier of the specified device allowed to receive the downlink message content;

[0147] The service server assembles the downlink message according to the downlink message content, the device identifier and the service server identifier, and finds the connection server identifier corresponding to the device identifier from the cache, and constructs a plurality of different first message topics according to the connection server identifier;

[0148] The service server sends the downlink message to the message queue server through a plurality of different first message topics respectively;

[0149] The message queue server pushes the downlink message to the corresponding connection server according to the preset grouping rule and the message topic subscription situation of the connection server;

[0150] The connection server receives and parses the downlink message to obtain the service server identifier, the device identifier and the downlink message content in the downlink message, and forwards the downlink message to the corresponding device according to the device identifier;

[0151] The device receives the downlink message and performs service processing on the downlink message;

[0152] And / or execute the following steps of the acknowledgement message processing method:

[0153] The device receives the downlink message in the downlink message processing method, generates confirmation data for replying to the downlink message, and sends the confirmation data and the device identifier to the connection server;

[0154] The connection server obtains the service server identifier and the message identifier in the downlink message according to the downlink message in the downlink message processing method;

[0155] The connection server assembles a confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier, and constructs a plurality of different second message topics according to the service server identifier;

[0156] The connection server sends the confirmation message to the message queue server through the plurality of different second message topics respectively;

[0157] The message queue server pushes the confirmation message to the corresponding service server according to a preset grouping rule and a topic subscription condition of the service server;

[0158] The service server receives and analyzes the confirmation message, obtains the connection server identifier, the device identifier, the message identifier, and the confirmation data in the confirmation message, and performs service processing on the confirmation data.

[0159] In one embodiment, a computer readable storage medium storing a computer program is provided, and the computer program is executed by a processor to make the processor execute the following downlink message processing method steps:

[0160] The service server receives a sending request of a downlink message, and obtains downlink message content and a device identifier of a specified device allowed to receive the downlink message content according to the sending request;

[0161] The service server assembles the downlink message according to the downlink message content, the device identifier, and a service server identifier, finds a connection server identifier corresponding to the device identifier from a cache, and constructs a plurality of different first message topics according to the connection server identifier;

[0162] The service server sends the downlink message to the message queue server through the plurality of different first message topics respectively;

[0163] The message queue server pushes the downlink message to the corresponding connection server according to a preset grouping rule and a message topic subscription condition of the connection server;

[0164] The connection server receives and analyzes the downlink message, obtains the service server identifier, the device identifier, and the downlink message content in the downlink message, and forwards the downlink message to the corresponding device according to the device identifier;

[0165] The device receives a downlink message and processes the downlink message;

[0166] and / or performs the following steps of the confirmation message processing method:

[0167] The device receives the downlink message in the downlink message processing method, generates confirmation data in reply to the downlink message, and sends the confirmation data and the device identifier to the connection server;

[0168] The connection server obtains the service server identifier and the message identifier in the downlink message according to the downlink message in the downlink message processing method;

[0169] The connection server assembles a confirmation message according to the confirmation data, the device identifier, the message identifier, and the connection server identifier, and constructs a plurality of different second message topics according to the service server identifier;

[0170] The connection server sends the confirmation message to the message queue server through the plurality of different second message topics respectively;

[0171] The message queue server pushes the confirmation message to the corresponding service server according to a preset grouping rule and the topic subscription of the service server;

[0172] The service server receives and parses the confirmation message to obtain the connection server identifier, the device identifier, the message identifier, and the confirmation data in the confirmation message, and processes the confirmation data.

[0173] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer readable storage medium, and when the program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0174] The technical features of the above embodiments can be combined in any way. In order to make the description simple, not all possible combinations of the technical features in the above embodiments are described, but as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.

[0175] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.

Claims

1. A downlink message processing method based on a message queue, characterized in that, Applied to an Internet of Things (IoT) system, the IoT system includes: a business server, a message queue server, a connection server, and devices that are interconnected. The method includes: The service server receives a downlink message sending request and, based on the sending request, obtains the downlink message content and the device identifier of a specified device that is allowed to receive the downlink message content; The service server assembles the downlink message based on the downlink message content, device identifier, and service server identifier, and searches the cache for the unique identifier of the connection server corresponding to the device identifier. Based on the unique identifier of the connection server, it constructs several different first message topics. The service server sends the downlink messages to the message queue server through the several different first message topics; The message queue server pushes the downlink messages to the corresponding connected servers according to preset grouping rules and the message topic subscription status of the connected servers, specifically including: The message queue server divides all connected servers into the same group, and each connected server subscribes to a different first message topic based on its own unique connected server identifier. The message queue server pushes the downlink messages to the corresponding connection servers according to the first message topics subscribed to by each connection server. The connection server receives and parses the downlink message to obtain the service server identifier, device identifier, and downlink message content in the downlink message, and forwards the downlink message to the corresponding device according to the device identifier; The device receives the downlink message and performs service processing on the downlink message; The downlink message content specifically includes: downlink message data and a message identifier, wherein the message identifier is used to track the current transmission status of the downlink message data; The service server assembles the downlink message based on the downlink message content, device identifier, and service server identifier, specifically including: The service server assembles the downlink message according to the downlink message data, message identifier, device identifier, and service server identifier, in the format of "service server identifier: device identifier: message identifier: downlink message data".

2. A method for processing acknowledgment messages based on a message queue, characterized in that, Applied to an Internet of Things (IoT) system, the IoT system includes: a business server, a message queue server, a connection server, and devices that are interconnected. The method includes: The device receives and processes the downlink message as described in claim 1, generates confirmation data in response to the downlink message, and sends the confirmation data and the device identifier to the connection server; The connection server obtains the service server identifier and message identifier in the downlink message according to the downlink message as described in claim 1; The connection server assembles a confirmation message based on the confirmation data, device identifier, message identifier, and connection server unique identifier, and constructs several different second message topics based on the business server identifier; The connection server sends the confirmation messages to the message queue server through the several different second message topics respectively; The message queue server pushes the confirmation message to the corresponding business server according to preset grouping rules and the topic subscription status of the business server, specifically including: The message queue server divides all business servers into the same group, and each business server subscribes to different second message topics according to its own business server identifier; The message queue server pushes the confirmation message to the corresponding business server according to the second message topic subscribed to by each business server; The service server receives and parses the confirmation message to obtain the unique identifier of the connection server, the device identifier, the message identifier, and the confirmation data in the confirmation message, and performs business processing on the confirmation data; The connection server assembles a confirmation message based on the confirmation data, device identifier, message identifier, and connection server unique identifier, specifically including: The connection server assembles the confirmation message according to the format "connection server unique identifier: device identifier: message identifier: confirmation data" based on the confirmation data, device identifier, message identifier, and connection server unique identifier.

3. The acknowledgment message processing method based on message queues according to claim 2, characterized in that, The IoT system also includes: a load balancing server; The device sends the confirmation data to the connection server, specifically including: The device sends the confirmation data to an idle connection server via the load balancing server.

4. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the processor performs the downlink message processing method as described in claim 1, and / or performs the acknowledgment message processing method as described in any one of claims 2 to 3.

5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the computer program is executed by the processor, the processor performs the downlink message processing method as described in claim 1, and / or performs the acknowledgment message processing method as described in any one of claims 2 to 3.

Citation Information

Patent Citations

  • Method and device for data circulation in message channel

    CN110401592A

  • Real-time message pushing method, system and device based on message queue and medium

    CN114116259A