Retention message expansion method and device based on MQTT protocol

By interfacing with the MQTT middleware through the reserved message group scheduler, reserved messages are extended to message groups, which solves the problem that each topic in the MQTT protocol can only retain one message. This ensures that newly connected devices obtain the latest multiple reserved messages, improving the resource utilization and business adaptability of the devices.

CN121814724APending Publication Date: 2026-04-07CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

The MQTT protocol can only retain one message per topic, which cannot meet the special needs of devices that frequently change their status in a short period of time or need to obtain historical records.

Method used

By interfacing with the MQTT middleware through the reserved message group scheduler, reserved messages can be flexibly configured and stored, and extended into message groups, ensuring that newly connected devices receive the latest multiple reserved messages.

Benefits of technology

Without interfering with the existing system, the problem that each topic in the MQTT protocol can only retain one message was solved, and the ability of the device to obtain the latest multiple retained messages was improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121814724A_ABST
    Figure CN121814724A_ABST
Patent Text Reader

Abstract

The invention provides a reserved message expansion method and device based on an MQTT protocol, relates to the technical field of Internet of Things, and is used for solving the problem that only one reserved message can be reserved under each theme of the MQTT protocol in a non-invasive manner. The method comprises the steps that a reservation message group scheduler receives a first reservation message pushed by MQTT middleware; the first reserved message is a reserved message of a first theme published by a message publisher to MQTT middleware; storing the first retention message; a second reservation message is sent to the MQTT middleware; the second reservation message comprises at least one reservation message of the first theme; the second reservation message is used for receiving the second reservation message from the MQTT middleware by the equipment subscribing to the extended message of the first theme.
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, and in particular to a reserved message extension method and device based on MQTT protocol. BACKGROUND

[0002] The message queuing telemetry transport (MQTT) protocol is widely used in the fields of Internet of Things, smart home, industrial automation and the like which require massive devices to communicate with each other, due to its lightweight, asynchronous communication mechanism, easy scalability, and manageable large connections. The retained message in the MQTT protocol is a special type of message, which functions to retain the message in the broker when the message publisher sends the message, so that the new subscribing device can immediately receive the latest message when subscribing to the topic, thereby ensuring that the newly connected device can immediately obtain the latest required state data or configuration information.

[0003] In the design of the MQTT protocol, in view of the characteristics of the retained message, in order to simplify the consistency management of the message, maintain the lightweight characteristics of the overall protocol, and prevent confusion under the topic due to multiple retained messages, the MQTT protocol explicitly provides that only one message is allowed under each topic, which ensures the efficiency and ease of use of the protocol. Although the design of the protocol can meet the needs of most business scenarios, in some special cases, such as the frequent change of the state of an entity in a short period of time, the new accessers may not only want to obtain the latest state, but also want to obtain the trend of the state change; for example, some new accessers want to obtain the historical record of a topic to make some task decisions, and the like. These special needs make the mechanism of retaining only one message insufficient. SUMMARY

[0004] The retained message extension method and device based on the MQTT protocol provided by the present application solve the problem that only one retained message can be retained under each topic of the MQTT protocol in a non-intrusive manner.

[0005] In a first aspect, the present application provides a retained message extension method based on MQTT protocol, applied to a retained message group scheduler, which comprises: receiving a first retained message pushed by an MQTT middleware; the first retained message is a retained message of a first topic published to the MQTT middleware by a message publisher; storing the first retained message; sending a second reserved message to the MQTT middleware; the second reserved message comprises at least one reserved message of the first topic; the second reserved message is used for the device subscribing to the extended message of the first topic to receive the second reserved message from the MQTT middleware.

[0006] Optionally, the storing the first reserved message comprises: storing the first reserved message in a set data structure; the set data structure comprises: an ID of the reserved message; a topic of the reserved message; content of the reserved message; an order of the reserved message under the topic; a creation time.

[0007] Optionally, before the sending the second reserved message to the MQTT middleware, the method further comprises: querying a target number of reserved messages with the latest creation time from the reserved messages with the first topic; the target number is the number of the extended reserved messages of the first topic; combining the target number of reserved messages into a second reserved message.

[0008] Optionally, before the receiving the first reserved message pushed by the MQTT middleware, the method further comprises: configuring the first topic as a reserved message topic needing extension; configuring the number of the extended reserved messages of the first topic; subscribing to the first topic.

[0009] Optionally, the method further comprises: periodically cleaning the reserved messages with a storage time exceeding a set threshold, and arranging the order values of the reserved messages under the same topic.

[0010] In a second aspect, the application provides a reserved message extension method based on the MQTT protocol, applied to an MQTT middleware, which comprises: pushing a first reserved message to a reserved message group dispatcher; the first reserved message is a reserved message of a first topic published by a message publisher to the MQTT middleware; receiving a second reserved message sent by the message extension device; the second reserved message comprises at least one reserved message of the first topic; the second reserved message is used for sending the second reserved message to the device subscribing to the extended message of the first topic.

[0011] In a third aspect, the application provides a reserved message extension method based on an MQTT protocol, applied to a device end, and the method comprises the following steps: Subscribing to an extended message of a first topic by an MQTT middleware; Receiving a second reserved message sent by the MQTT middleware; the second reserved message comprises at least one reserved message of the first topic; the first reserved message is a reserved message of the first topic published by a message publisher to the MQTT middleware.

[0012] In a fourth aspect, the application provides a reserved message extension device based on an MQTT protocol, applied to a reserved message group scheduler, and the device comprises the following steps: A receiving module, configured to receive a first reserved message pushed by an MQTT middleware; the first reserved message is a reserved message of a first topic published by a message publisher to the MQTT middleware; A processing module, configured to store the first reserved message; A sending module, configured to send a second reserved message to the MQTT middleware; the second reserved message comprises at least one reserved message of the first topic; the second reserved message is used for receiving the second reserved message from the MQTT middleware by a device subscribing to an extended message of the first topic.

[0013] Optionally, the processing module is further configured to store the first reserved message according to a set data structure; The set data structure comprises: An ID of the reserved message; A topic of the reserved message; A content of the reserved message; An order of the reserved message under the topic; A creation time.

[0014] Optionally, the processing module is further configured to query a target number of reserved messages with the latest creation time in the reserved messages of the first topic; the target number is a reserved message number of the first topic extension; Combining the target number of reserved messages into a second reserved message.

[0015] Optionally, the processing module is further configured to configure the first topic as a reserved message topic needing extension; Configure a reserved message number of the first topic extension; Subscribe to the first topic.

[0016] Optionally, the processing module is further configured to periodically clean up the reserved messages with a storage time exceeding a set threshold value, and arrange an order value of the reserved messages under the same topic.

[0017] In a fifth aspect, the application provides a reserved message extension device based on an MQTT protocol, which is applied to an MQTT middleware, and the device comprises: a sending module configured to push a first reserved message to a reserved message group dispatcher; the first reserved message is a reserved message of a first topic published by a message publisher to the MQTT middleware; a receiving module configured to receive a second reserved message sent by the message extension device; the second reserved message comprises at least one reserved message of the first topic; and the second reserved message is used to send the second reserved message to a device subscribing to the extension message of the first topic.

[0018] In a sixth aspect, the application provides a reserved message extension device based on an MQTT protocol, which is applied to a device end, and the device comprises: a processing module configured to subscribe to an extension message of a first topic to the MQTT middleware; a receiving module configured to receive a second reserved message sent by the MQTT middleware; the second reserved message comprises at least one reserved message of the first topic; and the first reserved message is a reserved message of the first topic published by a message publisher to the MQTT middleware.

[0019] In a seventh aspect, the application further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the reserved message extension method based on the MQTT protocol as described above when executing the computer program.

[0020] In an eighth aspect, the application further provides a non-transitory computer readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the reserved message extension method based on the MQTT protocol as described above.

[0021] In a ninth aspect, the application further provides a computer program product comprising a computer program, and the computer program is executed by a processor to implement the reserved message extension method based on the MQTT protocol as described above.

[0022] The reserved message extension method based on the MQTT protocol provided by the embodiments of the application can be connected with the existing MQTT middleware through the reserved message group dispatcher, and can flexibly configure, store and update the related reserved messages and has the message switching function. The reserved messages are extended to the message group, so that the newly connected device can quickly obtain the latest multiple reserved messages under a specific topic. This non-invasive solution which does not interfere with the operation of the existing system and does not modify the original platform system can solve the problem that only one reserved message can be reserved under each topic of the MQTT protocol. BRIEF DESCRIPTION OF DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the application, and all other embodiments obtained by a person of ordinary skill in the art without creative work based on these drawings also belong to the protection scope of the application.

[0024] Figure 1 Flowchart of a reserved message extension method based on an MQTT protocol provided by an embodiment of the application Figure One ; Figure 2 Flowchart of a reserved message extension method based on an MQTT protocol provided by an embodiment of the application Figure Two ; Figure 3 Flowchart of a reserved message extension method based on an MQTT protocol provided by an embodiment of the application Figure Three ; Figure 4 Schematic diagram of an Internet of Things device networking system applicable to an embodiment of the application Figure 5 Schematic diagram of an interaction flow of a reserved message extension method based on an MQTT protocol provided by an embodiment of the application Figure 6 Structure schematic diagram of a reserved message extension device based on an MQTT protocol provided by an embodiment of the application Figure One ; Figure 7 Structure schematic diagram of a reserved message extension device based on an MQTT protocol provided by an embodiment of the application Figure Two ; Figure 8 Structure schematic diagram of a reserved message extension device based on an MQTT protocol provided by an embodiment of the application Figure Three ; Figure 9 Structure schematic diagram of an electronic device provided by an embodiment of the application. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solutions and advantages of the application more clear, the application will be further described in detail below with reference to the drawings. Obviously, the described embodiments are only some of the embodiments of the application, but not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by a person of ordinary skill in the art without creative work also belong to the protection scope of the application.

[0026] All the actions of obtaining signal information or data in this application are carried out in accordance with the corresponding data protection regulations and policies of the country where the device is located, and with the authorization given by the owner of the corresponding device.

[0027] In the embodiments of the present application, a plurality of means two or more. The words "first", "second", etc. are used only for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can it be understood as indicating or implying order.

[0028] Figure 1 A flowchart of a method for extending a reserved message based on an MQTT protocol provided in an embodiment of the present application Figure One , applied to a reserved message group scheduler, as shown in Figure 1 , the method comprises the following steps: Step 110, receiving the first reserved message pushed by the MQTT middleware.

[0029] The first reserved message is a reserved message of the first topic published by the message publisher to the MQTT middleware. The topic of the first reserved message is the first topic, and the first topic is a reserved message topic that needs to be extended in the reserved message group scheduler. The content of the reserved message of the first topic can be customized according to the business rules and is of string type. Since the reserved message group scheduler subscribes to the first topic, the MQTT middleware will push the reserved message of the first topic to the reserved message group scheduler after receiving the reserved message of the first topic published by the message publisher.

[0030] In a possible implementation, before step 110 receives the first reserved message pushed by the MQTT middleware, the following operations are further performed: Configure the first topic as a reserved message topic that needs to be extended; Configure the number of reserved messages extended by the first topic; Subscribe to the first topic.

[0031] The reserved message group scheduler configures the topic of the reserved message that needs to be extended and the number of reserved messages extended under the topic. An example of the configuration of the reserved message is as follows: extendTopic: -name: / task num: 10 -name: / status num: 10 -name: / config num: 10 Wherein, the name represents the subject name of the retained message to be extended, and the num represents the number of retained messages to be extended, i.e. how many retained messages under the subject are retained recently. The above configuration indicates that the retained message subjects with the names of task, status and config are configured as the extended retained message subjects, and each subject retains the latest 10 retained messages. It should be noted that the number of extended retained messages under each subject can be the same or different, and can be configured according to actual needs.

[0032] In addition, the retained message group scheduler subscribes to the subject of the retained message to be extended, so that when the MQTT middleware receives the retained message of the subject, it pushes it to the retained message group scheduler.

[0033] Step 120, store the first retained message.

[0034] The retained message group scheduler synchronizes and stores the retained message received by the MQTT middleware by listening to the subscribed retained message subject.

[0035] Specifically, step 120 stores the first retained message, including: storing the first retained message according to a set data structure.

[0036] Wherein, the set data structure includes: the ID of the retained message, the subject of the retained message, the content of the retained message, the order of the retained message under the subject, and the creation time.

[0037] Exemplarily, the retained message can be stored in a database. Taking a Mysql database as an example, the data structure of the retained message stored in the database is shown in Table 1, including the ID of the retained message, the subject topic of the retained message, the content content of the retained message, the order order of the retained message under the subject, and the creation time create_time.

[0038] Table 1

[0039] The retained message group scheduler inserts the ID, subject, content and creation time of the first retained message into the database, and increments the order value of the first retained message under the first subject.

[0040] Before step 130, the retained message group scheduler queries the target number of retained messages with the latest creation time in the retained messages with the first subject, and combines the target number of retained messages into a second retained message. Wherein, the target number is the number of extended retained messages of the first subject.

[0041] The reserved message group dispatcher queries the list data of the latest num reserved messages with the first topic from the database according to the pre-configured reserved message quantity num of the first topic extension. Taking 3 as an example, the list data format content is a JSON array format string, for example: [ { "topic": " / config", "content"{}, "order":1, "createTime":"2023-05-08 00:00:00" }, { "topic": " / config", "content"{}, "order":2, "createTime":"2023-05-08 01:00:00" }, { "topic": " / config", "content"{}, "order":3, "createTime":"2023-05-08 02:00:00" } ] Step 130, sending the second reserved message to the MQTT middleware.

[0042] The reserved message group dispatcher queries the list data of the latest num reserved messages with the first topic from the database, combines the num reserved messages into a second reserved message, and then sends the second reserved message to the MQTT middleware. The second reserved message includes at least one reserved message of the first topic, and the second reserved message is used for a device subscribing to the extended message of the first topic to receive the second reserved message from the MQTT middleware.

[0043] Specifically, the topic of the second reserved message can be a suffix string " / group" spliced on the basis of the topic of the first reserved message. For example, if the topic of the first reserved message is a first topic ${Topic}, the topic of the second reserved message is configured as ${Topic} / group. If the topic of the first reserved message is " / task", the topic of the second reserved message is " / task / group". The content of the second reserved message is the combination of the latest num reserved messages of the first topic. After a new online device accesses the MQTT middleware, the device subscribes to the reserved message with the topic ${Topic} according to its own business needs. If the device also needs to receive multiple historical reserved messages of the topic, the device further subscribes to a reserved message with the topic ${Topic} / group. After the subscription is completed, the MQTT middleware pushes the reserved message with the topic ${Topic} / group to the device, and the device can receive the latest num reserved messages with the topic ${Topic}.

[0044] In a possible implementation, the reserved message group scheduler periodically cleans up the reserved messages stored for more than a set threshold, and arranges the sequence values of the reserved messages of the same topic, to reduce the storage pressure.

[0045] The method for extending the reserved message based on the MQTT protocol provided in the embodiments of the present application can be applied not only in the business scenarios related to smart home, but also in all Internet of Things business scenarios, industrial Internet scenarios, and the like using the MQTT message middleware, such as obtaining the latest multiple computing tasks allocated by a business platform when a storage and computing base device is powered on, and obtaining multiple historical states of a control device when an IOT central control device is powered on, and has high universality.

[0046] In the embodiments of the present application, the reserved message group scheduler can utilize the idle computing power and storage of a home terminal device (such as an FTTR) with storage and computing capabilities. After a large number of devices are networked by using the method, the device can obtain more comprehensive historical computing data and edge task allocation when the device is reconnected or a new device is added, and can better improve the resource utilization of the device itself. Therefore, the utilization rate of the idle computing power and storage of the end side can be increased for business such as home storage, computing end cloud collaborative scheduling, and the like, and the hardware construction cost of the platform side in the AI+ computing era can be reduced.

[0047] The method for extending the reserved message based on the MQTT protocol provided by the embodiments of the present application can be connected with the existing MQTT middleware through the reserved message group scheduler, and can flexibly configure, store and update the relevant reserved message, and has a message switching function. The reserved message is extended to a message group, so that the newly connected device can quickly obtain the latest multiple reserved messages under a specific topic. The non-invasive solution which does not modify the original platform system can solve the problem that only one reserved message can be reserved under each topic of the MQTT protocol without interfering with the operation of the existing system and modifying the original platform system.

[0048] Based on the same technical concept, Figure 2 The flowchart of the method for extending the reserved message based on the MQTT protocol provided by the embodiments of the present application Figure Two is applied to the MQTT middleware, as shown in the figure, and the method comprises the following steps: Figure 2 Step 210, push a first reserved message to the reserved message group scheduler.

[0049] The first reserved message is a reserved message of a first topic published by a message publisher to the MQTT middleware. The topic of the first reserved message is the first topic, and the first topic is a reserved message topic that needs to be extended and is pre-configured in the reserved message group scheduler. The content of the reserved message of the first topic can be customized as a string type according to the business rules. Since the reserved message group scheduler subscribes to the first topic, the MQTT middleware will push the reserved message of the first topic to the reserved message group scheduler after receiving the reserved message of the first topic published by the message publisher.

[0050] Step 220, receive a second reserved message sent by a message extension device.

[0051] The reserved message group scheduler synchronizes and stores the reserved message received by the MQTT middleware by listening to the subscribed reserved message topic. Then the reserved message group scheduler queries the latest num reserved messages of the first topic from the database, combines the num reserved messages into a second reserved message, and then sends the second reserved message to the MQTT middleware. The second reserved message comprises at least one reserved message of the first topic, and the second reserved message is used for the MQTT middleware to send the second reserved message to the device that subscribes to the extended message of the first topic.

[0052] ​Specifically, the topic of the second retained message can be the topic of the first retained message with the suffix string " / group" appended. For example, if the topic of the first retained message is the first topic ${Topic}, then the topic of the second retained message is configured as ${Topic} / group. The content of the second retained message is a combination of the most recent num retained messages of the first topic. After a newly launched device connects to the MQTT middleware, it subscribes to the retained message with topic ${Topic} according to its own business needs. If it also needs to receive multiple historical retained messages of this topic, it subscribes to a retained message with topic ${Topic} / group. After the subscription is completed, the MQTT middleware pushes the retained message with topic ${Topic} / group to the device, and the device will then receive the most recent num retained messages with topic ${Topic}.

[0053] Based on the same technological concept Figure 3 A flowchart illustrating a reserved message extension method based on the MQTT protocol provided in this application embodiment. Figure Three Applied to the device side, such as Figure 3 As shown, the method includes the following steps: Step 310: Subscribe to extended messages for the first topic from the MQTT middleware.

[0054] Step 320: Receive the second reserved message sent by the MQTT middleware.

[0055] The second reserved message includes at least one reserved message for the first topic, where the first reserved message is a reserved message for the first topic published by the MQTT middleware in the message publishing direction.

[0056] Specifically, the topic of the second retained message can be the topic of the first retained message with the suffix string " / group" appended. For example, if the topic of the first retained message is the first topic ${Topic}, then the topic of the second retained message is configured as ${Topic} / group. The content of the second retained message is a combination of the most recent num retained messages of the first topic. After a newly launched device connects to the MQTT middleware, it subscribes to the retained message of topic ${Topic} according to its own business needs. If it also needs to receive multiple historical retained messages of this topic, it subscribes to the extended message of the first topic from the MQTT middleware, that is, it subscribes to a retained message of topic ${Topic} / group from the MQTT middleware. After the subscription is completed, the MQTT middleware pushes the retained message of topic ${Topic} / group to the device, and the device can then receive the most recent num retained messages of topic ${Topic}. Subsequent business logic processing can be performed as needed.

[0057] For the convenience of understanding, the following takes the Internet of Things device networking system as an example to introduce the interactive process of the method for extending the reserved message based on the MQTT protocol provided by the embodiments of the present application.

[0058] Figure 4 A schematic diagram of the Internet of Things device networking system to which the embodiments of the present application are applicable, Figure 5 An interactive flowchart of the method for extending the reserved message based on the MQTT protocol provided by the embodiments of the present application, which specifically comprises the following steps: (${Topic} in the following description is the topic of the reserved message to be extended, which is a variable and can be replaced by any string): Step 501, the reserved message group scheduler configures the topic ${Topic} of the reserved message to be extended and subscribes to the topic ${Topic}.

[0059] The reserved message group scheduler configures the topic name ${Topic} of the reserved message to be extended and the number num of the extended reserved messages under the topic ${Topic}.

[0060] Step 502, a message publisher publishes a reserved message to the MQTT middleware, and the topic of the reserved message is ${Topic}.

[0061] The message publisher can be a device management platform or other devices.

[0062] Step 503, the MQTT middleware pushes the reserved message with the topic ${Topic} to the reserved message group scheduler.

[0063] Since the reserved message group scheduler has subscribed to the topic ${Topic} in advance, the MQTT middleware will push a copy of the reserved message to the reserved message group scheduler.

[0064] Step 504, the reserved message group scheduler stores the reserved message with the topic ${Topic} in the database.

[0065] The reserved message group scheduler inserts the topic ${Topic} and the content content of the reserved message into the database, and the order value is incremented under the topic.

[0066] Step 505, the reserved message group scheduler queries the latest num reserved messages with the topic ${Topic} from the database.

[0067] The reserved message group scheduler queries the latest num reserved messages with the topic ${Topic} from the database according to the number num of the reserved messages to be extended of the topic ${Topic} configured in step 501.

[0068] Step 506, the reserved message group scheduler publishes a reserved message with a topic of ${Topic} / group to the MQTT middleware.

[0069] The reserved message group scheduler publishes a reserved message with a topic of ${Topic} / group according to the configured ${Topic}, and the message content is the latest num reserved messages with a topic of ${Topic} queried in step 505.

[0070] Step 507, the Internet of Things device end subscribes to the ${Topic} / group topic.

[0071] After the Internet of Things device end accesses the MQTT middleware, in addition to subscribing to the reserved message ${Topic} according to its own business needs, it additionally subscribes to the ${Topic} / group topic.

[0072] Step 508, the Internet of Things device end receives the reserved message with a topic of ${Topic} / group.

[0073] The Internet of Things device end can obtain the related content data in the reserved message with a topic of ${Topic} / group in a timely manner, that is, it has obtained the latest several messages of the original ${Topic} reserved message. Subsequently, related business logic processing can be performed as needed.

[0074] The function design and process design of the reserved message group scheduler of the present application are decoupled from the overall business, and do not invade the original business. If the reserved message group scheduler is removed and the extended reserved message group function is no longer used, the device can still normally obtain the original MQTT related single reserved message.

[0075] The reserved message group scheduler of the present application can dynamically configure the topic on and off for the message to be extended, can publish different business on demand, reduce redundant messages, and can publish new business topic messages in a timely manner.

[0076] The overall process design of the present application is lightweight, and the extended signaling is simple and easy to understand. The new function of the present application has very low modification cost, the original platform side does not need to be modified at all, and the device only needs to consider whether to additionally listen to the topic corresponding to the extended reserved message group (the original topic name plus the suffix group) according to the actual needs of its own business.

[0077] The reserved message extension device based on the MQTT protocol provided by the present application is described below. The reserved message extension device based on the MQTT protocol described below can be correspondingly referred to with the reserved message extension method based on the MQTT protocol described above.

[0078] Figure 6A structure schematic diagram of a reserved message extension device based on an MQTT protocol is provided for an embodiment of the present application, and is applied to a reserved message group scheduler, as shown in the figure, the device 600 comprises: Figure 6 A receiving module 610 is configured to receive a first reserved message pushed by an MQTT middleware; the first reserved message is a reserved message of a first topic published by the MQTT middleware; A processing module 620 is configured to store the first reserved message; A sending module 630 is configured to send a second reserved message to the MQTT middleware; the second reserved message comprises at least one reserved message of the first topic; the second reserved message is used for a device subscribing to an extended message of the first topic to receive the second reserved message from the MQTT middleware.

[0079] Optionally, the processing module 620 is further configured to store the first reserved message according to a set data structure; The set data structure comprises: An ID of the reserved message; A topic of the reserved message; Content of the reserved message; An order of the reserved message under the topic; A creation time.

[0080] Optionally, the processing module 620 is further configured to query a target number of reserved messages with the latest creation time from reserved messages with the first topic as the topic; the target number is a number of extended reserved messages of the first topic; The target number of reserved messages are combined into a second reserved message.

[0081] Optionally, the processing module 620 is further configured to configure the first topic as a reserved message topic needing to be extended; Configure a number of extended reserved messages of the first topic; Subscribe to the first topic.

[0082] Optionally, the processing module 620 is further configured to periodically clean up reserved messages with a storage time exceeding a set threshold value, and arrange order values of reserved messages under the same topic.

[0083] Figure 7 A structure schematic diagram of a reserved message extension device based on an MQTT protocol is provided for an embodiment of the present application, and is applied to an MQTT middleware, as shown in the figure, the device 700 comprises: Figure 7 ​​The sending module 710 is used to push the first reserved message to the reserved message group scheduler; the first reserved message is a reserved message of the first topic published by the message publishing direction to the MQTT middleware; The receiving module 720 is configured to receive a second reserved message sent by the message extension device; the second reserved message includes at least one reserved message for a first topic; the second reserved message is used to send the second reserved message to devices that subscribe to extended messages for the first topic.

[0084] Figure 8 This application provides a schematic diagram of a reserved message extension device based on the MQTT protocol, which is applied to the device side, such as... Figure 8 As shown, the device 800 includes: Processing module 810 is used to subscribe to extended messages of the first topic from the MQTT middleware; The receiving module 820 is used to receive a second reserved message sent by the MQTT middleware; the second reserved message includes at least one reserved message for a first topic; the first reserved message is a reserved message for a first topic published by the message publisher to the MQTT middleware.

[0085] It should be noted that the reserved message extension device based on the MQTT protocol provided in this application embodiment can implement all the method steps implemented in the above-mentioned reserved message extension method embodiment based on the MQTT protocol, and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.

[0086] Figure 9 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 9 As shown, the electronic device may include a processor 910, a communications interface 920, a memory 930, and a communication bus 940. The processor 910, communications interface 920, and memory 930 communicate with each other via the communication bus 940. The processor 910 can call logical instructions in the memory 930 to execute a reserved message extension method based on the MQTT protocol.

[0087] In addition, the logic instructions in the memory 930 described above can be implemented in the form of software function units and sold or used as independent products, and can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that make contributions to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0088] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program can be stored on a non-transitory computer readable storage medium, and the computer program is executed by a processor, so that the computer can execute the MQTT protocol-based reserved message extension method provided by the above-mentioned methods.

[0089] In another aspect, the present application also provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the MQTT protocol-based reserved message extension method provided by the above-mentioned methods.

[0090] The device embodiments described above are only schematic, wherein the units illustrated as separate components can or can not be physically separate, and the components illustrated as units can or can not be physical units, that is, they can be located in one place, or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the embodiment according to actual needs. Those skilled in the art can understand and implement without creative labor.

[0091] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by means of software plus necessary universal hardware platforms, and of course, can also be implemented by hardware. Based on such understanding, the technical solutions described above essentially or the parts that make contributions to the prior art can be embodied in the form of a software product. The computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0092] It should be noted that the above examples are only used to illustrate the technical solutions of the present application, and are not intended to limit the same. Although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that the technical solutions recorded in the foregoing examples can be modified, or some of the technical features can be replaced by equivalent features. Such modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A reserved message extension method based on the MQTT protocol, applied to a reserved message group scheduler, characterized in that, The method includes: Receive the first reserved message pushed by the MQTT middleware; the first reserved message is a reserved message of the first topic published by the message publisher to the MQTT middleware; Store the first reserved message; A second reserved message is sent to the MQTT middleware; the second reserved message includes at least one reserved message for a first topic; the device that subscribes to extended messages for the first topic receives the second reserved message from the MQTT middleware.

2. The reserved message extension method based on the MQTT protocol according to claim 1, characterized in that, The storage of the first reserved message includes: The first reserved message is stored according to the set data structure; The defined data structure includes: Preserve the message ID; Preserve the message subject; Preserve the message content; Preserve the order of messages within the topic; Creation time.

3. The reserved message extension method based on the MQTT protocol according to claim 2, characterized in that, Before sending the second reserved message to the MQTT middleware, the method further includes: Query the reserved messages with the first topic that have the most recent creation time to the target number of reserved messages; the target number is the number of reserved messages extended from the first topic. The target number of reserved messages are combined into a second reserved message.

4. The reserved message extension method based on the MQTT protocol according to claim 1, characterized in that, Before receiving the first reserved message pushed by the MQTT middleware, the method further includes: Configure the first topic as a reserved message topic that needs to be expanded; Configure the number of messages to retain in the first topic extension; Subscribe to the first topic.

5. The method for extending reserved messages based on the MQTT protocol according to claim 1, characterized in that, The method further includes: Regularly clean up retained messages that have been stored for longer than a set threshold, and reorganize the order values ​​of retained messages under the same topic.

6. A reserved message extension method based on the MQTT protocol, applied to MQTT middleware, characterized in that, The method includes: Push the first reserved message to the reserved message group scheduler; the first reserved message is a reserved message of the first topic published by the message publishing direction to the MQTT middleware; The message extension device receives a second reserved message; the second reserved message includes at least one reserved message for a first topic; the second reserved message is used to send the second reserved message to devices that subscribe to extended messages for the first topic.

7. A method for extending reserved messages based on the MQTT protocol, applied to the device side, characterized in that, The method includes: Subscribe to extended messages for the first topic from the MQTT middleware; Receive a second reserved message sent by the MQTT middleware; the second reserved message includes at least one reserved message for a first topic; the first reserved message is a reserved message for a first topic published by the message publisher to the MQTT middleware.

8. A reserved message extension device based on the MQTT protocol, applied to a reserved message group scheduler, characterized in that, The device includes: The receiving module is used to receive the first reserved message pushed by the MQTT middleware; the first reserved message is a reserved message of the first topic published by the message publisher to the MQTT middleware; A processing module is used to store the first reserved message; A sending module is configured to send a second reserved message to the MQTT middleware; the second reserved message includes at least one reserved message for a first topic; the second reserved message is used by devices that subscribe to extended messages for the first topic to receive the second reserved message from the MQTT middleware.

9. A reserved message extension device based on the MQTT protocol, applied to MQTT middleware, characterized in that, The device includes: The sending module is used to push the first reserved message to the reserved message group scheduler; the first reserved message is a reserved message of the first topic published by the message publishing direction to the MQTT middleware; A receiving module is configured to receive a second reserved message sent by the message extension device; the second reserved message includes at least one reserved message on a first topic; the second reserved message is used to send the second reserved message to devices that subscribe to extended messages on the first topic.

10. A reserved message extension device based on the MQTT protocol, applied to the device side, characterized in that, The device includes: The processing module is used to subscribe to extended messages of the first topic from the MQTT middleware; The receiving module is used to receive a second reserved message sent by the MQTT middleware; the second reserved message includes at least one reserved message for a first topic; the first reserved message is a reserved message for a first topic published by the message publisher to the MQTT middleware.