A metadata-based MQTT topic subscription method, system and electronic device

By introducing metadata storage and semantic querying into the MQTT system, the problems of flexibility and management complexity in topic subscription in large-scale IoT systems are solved, enabling efficient and flexible topic subscription and real-time data transmission.

CN121644657BActive Publication Date: 2026-05-08HANGZHOU YINGYUN TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU YINGYUN TECH CO LTD
Filing Date
2026-02-03
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

The existing MQTT topic subscription method is not very flexible in large-scale IoT systems, has high management complexity, cannot be queried based on data attributes, and the subscription method is inflexible.

Method used

By introducing metadata storage, a mapping relationship between metadata and topic schema is established. Subscription is performed using semantic query commands, thereby decoupling metadata and topics and automatically updating the mapping relationship to adapt to device changes.

Benefits of technology

It reduces the complexity and management difficulty of topic subscriptions, improves the flexibility and scalability of subscriptions, and enables real-time message routing and seamless data flow.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121644657B_ABST
    Figure CN121644657B_ABST
Patent Text Reader

Abstract

The application relates to an MQTT topic subscription method, system and electronic equipment based on metadata, wherein the MQTT topic subscription method based on metadata is applied to an MQTT broker, the broker cooperates with a client and a physical device, and the method comprises the following steps: acquiring a first mapping relationship between metadata and a topic mode; receiving a message sent by the client, wherein the message comprises a semantic query command and a client identifier, determining a target topic mode from the first mapping relationship according to the semantic query command, and determining the semantic query command based on target metadata; storing a second mapping relationship among the semantic query command, the client identifier and the corresponding target topic mode, so as to subscribe to the target topic through the second mapping relationship; and receiving data published by the physical device to a target MQTT topic, and forwarding the data to the corresponding client in response to the target MQTT topic matching the target topic mode in the second mapping relationship.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet of Things (IoT) communication technology, and in particular to a metadata-based MQTT topic subscription method, system, and electronic device. Background Technology

[0002] The Message Queuing Telemetry Transport (MQTT) protocol uses a hierarchical topic structure to route messages, such as the topic structure sensors / building1 / floor2 / room201 / temperature. This hierarchical structure is effective in simple scenarios, but in large-scale IoT systems containing tens of thousands or even millions of devices and data points, the complexity and difficulty of topic space management are significant.

[0003] The existing MQTT topic model has the following technical defects: (1) Topic proliferation and high management complexity. As the number of devices and data types increases, the topic tree becomes extremely large and difficult to manage and navigate. (2) Inflexible subscription method. Clients must know the exact topic string (or use wildcards) to subscribe to the required data. (3) Inability to query based on data attributes. It is not possible to subscribe to data based on data characteristics or metadata. For example, users cannot easily subscribe to the data of "all temperature sensors located in Building 1 manufactured by Manufacturer X" because they need to know the specific topic of all these sensors in advance.

[0004] Therefore, the existing MQTT topic subscription method is not very flexible and is difficult to manage. Summary of the Invention

[0005] This application provides a metadata-based MQTT topic subscription method, system, and electronic device to at least solve the problems of low flexibility and high management difficulty in topic subscription methods in related technologies.

[0006] In a first aspect, embodiments of this application provide a metadata-based MQTT topic subscription method, which is applied to an MQTT broker, the broker cooperating with a client and a physical device, and the method includes:

[0007] Obtain the initial mapping relationship between metadata and theme schema;

[0008] Receive a message sent by a client, the message including a semantic query command and a client identifier, determine a target topic pattern from the first mapping relationship based on the semantic query command, the semantic query command being determined based on target metadata;

[0009] Store a second mapping relationship between the semantic query command, the client identifier, and the corresponding target topic pattern, so as to subscribe to the target topic through the second mapping relationship;

[0010] The system receives data published by the physical device to the target MQTT topic, and forwards the data to the corresponding client in response to the target MQTT topic matching the target topic pattern in the second mapping relationship.

[0011] In one embodiment, the semantic query command is configured to determine, based on target metadata in the message, according to a preset query language, the step of determining the target topic pattern from the first mapping relationship according to the semantic query command includes:

[0012] Execute the semantic query command to determine the target topic pattern from the first mapping relationship based on the semantic query command.

[0013] In one embodiment, forwarding the data to the corresponding client in response to a match between the target MQTT topic and the target topic pattern in the second mapping relationship includes:

[0014] In response to the fact that the target MQTT topic belongs to the target topic pattern in the second mapping relationship, the corresponding target client identifier is determined from the second mapping relationship according to the target topic pattern;

[0015] The data is forwarded to the target client based on the target client identifier.

[0016] In one embodiment, the first mapping relationship is configured to be obtained in the following manner:

[0017] Initialize the first mapping relationship and manage the first mapping relationship between metadata and theme mode through the preset management API.

[0018] In one embodiment, the method further includes:

[0019] In response to the configuration of a new physical device, the newly added metadata and new theme mode corresponding to the device are added to the first mapping relationship through the preset management API;

[0020] Based on the newly added metadata, determine the corresponding semantic query command, and based on the semantic query command, determine the corresponding target topic pattern from the first mapping relationship;

[0021] The second mapping relationship is updated based on the semantic query command and target topic pattern corresponding to the newly added metadata, and the client identifier corresponding to the device.

[0022] In one embodiment, after updating the second mapping relationship, the method further includes:

[0023] Upon receiving information published by a new physical device, the system determines the corresponding target client from the updated second mapping relationship based on the topic in the information and automatically forwards the information to the corresponding target client.

[0024] Secondly, embodiments of this application provide a metadata-based MQTT topic subscription system, which works with MQTT brokers, clients, and physical devices. The system includes:

[0025] Metadata storage module: used to obtain the initial mapping relationship between metadata and topic schema;

[0026] Subscription module: Used to receive messages sent by clients, the messages including semantic query commands and client identifiers, and to determine the target topic pattern from the first mapping relationship based on the semantic query commands, the semantic query commands being determined based on target metadata;

[0027] Topic module: Used to store a second mapping relationship between the semantic query command, the client identifier and the corresponding target topic pattern, so as to subscribe to the target topic through the second mapping relationship;

[0028] Message routing module: Used to receive data published by the physical device to the target MQTT topic, and in response to the target MQTT topic matching the target topic pattern in the second mapping relationship, forward the data to the corresponding client.

[0029] Thirdly, embodiments of this application provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements a metadata-based MQTT topic subscription method as described in the first aspect above.

[0030] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a metadata-based MQTT topic subscription method as described in the first aspect above.

[0031] The MQTT topic subscription method, system, and electronic device based on metadata provided in this application have at least the following technical effects.

[0032] In summary, by introducing a metadata store to store the initial mapping relationship between metadata and topic patterns, data subscription is decoupled from fixed topic hierarchies, which helps reduce the complexity of topic subscription. This changes the way topics are managed in large-scale IoT systems, eliminating the need to understand complex, precise topic structures; users can directly query and subscribe to the required data through intuitive metadata. This subscription method reduces the difficulty of subscription and management, and increases the flexibility and scalability of topic subscriptions. After querying and subscribing to the required topics through intuitive metadata, real-time message routing is automatically implemented, simplifying subscription operations and improving the real-time performance of topic subscriptions.

[0033] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description

[0034] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0035] Figure 1 This is a flowchart illustrating a metadata-based MQTT topic subscription method according to an embodiment of this application;

[0036] Figure 2 This is a structural block diagram of an MQTT topic subscription system based on metadata, according to an embodiment of this application.

[0037] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.

[0039] Obviously, the accompanying drawings described below are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar scenarios based on these drawings without any inventive effort. Furthermore, it is understood that although the efforts made in this development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, any changes to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.

[0040] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0041] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms “a,” “an,” “an,” “the,” and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units not listed, or may include other steps or units inherent to these processes, methods, products, or devices. The terms “connected,” “linked,” “coupled,” and similar words used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. The terms "first," "second," and "third" used in this application are merely to distinguish similar objects and do not represent a specific ordering of the objects.

[0042] In a first aspect, embodiments of this application provide a metadata-based MQTT topic subscription method, which is applied to an MQTT broker, and the broker works with clients and physical devices. Figure 1This is a flowchart illustrating a metadata-based MQTT topic subscription method according to an embodiment of this application, such as... Figure 1 As shown, the method includes:

[0043] Step S101: Obtain the first mapping relationship between metadata and topic schema.

[0044] Optionally, a metadata store can be maintained within the MQTT broker. This metadata store stores the initial mapping, associating rich key-value pair metadata (such as device type, manufacturer, physical location, etc.) with MQTT topics. By introducing a metadata store, data subscriptions are decoupled from the fixed topic hierarchy, which helps reduce the complexity of topic subscriptions.

[0045] In one example, the first mapping relationship in step S101 is configured to be obtained by: initializing the first mapping relationship and managing the first mapping relationship between metadata and topic mode through a preset management API.

[0046] Optionally, the MQTT broker starts and initializes its internal metadata store to store the initial mappings. Administrators or automated equipment provisioning systems associate and store rich metadata with topic schemas via the metadata management API. For example, the metadata {"manufacturer":"acme", "device_type":"thermostat"} is associated with the topic schema sensors / acme / + / temperature. Here, the metadata and topic schemas are associated through a mapping relationship. In this way, by introducing metadata storage, data subscriptions are decoupled from fixed topic hierarchies, which helps reduce the complexity of topic subscriptions.

[0047] Step S102: Receive a message sent by the client. The message includes a semantic query command and a client identifier. Determine the target topic pattern from the first mapping relationship based on the semantic query command. The semantic query command is determined based on the target metadata.

[0048] Optionally, clients subscribe via metadata queries, rather than simply by topic strings. Instead of using the standard SUBSCRIBE command, a query language (e.g., publishing a message to a reserved topic `$subscribe / query`) is introduced to submit a semantic query. For example, the query command `"query": "SELECT WHEREmetadata.device_type = 'thermostat' AND metadata.manufacturer = 'acme'"` queries and subscribes to information corresponding to the metadata for device type 'thermostat' and manufacturer 'acme' from the first mapping relationship, using the list of topic patterns corresponding to the matching metadata as the target topic patterns. The semantic query command is generated based on the target metadata.

[0049] This approach changes the way topics are managed in large-scale IoT systems, eliminating the need to understand complex, precise topic structures and allowing users to directly query and subscribe to the required data through intuitive metadata. This subscription method reduces the complexity of subscription and management.

[0050] In one example, the semantic query command is configured to determine the target topic pattern based on the target metadata in the message according to a preset query language. Step S102 includes: executing the semantic query command and determining the target topic pattern from the first mapping relationship according to the semantic query command.

[0051] Optionally, instead of using the standard SUBSCRIBE command, the client introduces a query language (e.g., publishing a message to a reserved topic $subscribe / query) to submit a semantic query. Query subscriptions are based on metadata attributes. For example, a client can initiate a subscription request like SELECT topics WHERE metadata.deviceType = 'thermostat' AND metadata.location.building = 'building1' to query and subscribe to all topics from the first mapping that meet the following two conditions: ① the associated device type is thermostat; ② the physical location of the device is in building 1. A list of all matching query topic patterns is used as the target topic pattern, for example, ["sensors / acme / + / temperature"].

[0052] This approach changes the way topics are managed in large-scale IoT systems, eliminating the need to understand complex, precise topic structures and allowing users to directly query and subscribe to the required data through intuitive metadata. This subscription method reduces the complexity of subscription and management.

[0053] Step S103: Store the second mapping relationship between the semantic query command, the client identifier and the corresponding target topic pattern, so as to subscribe to the target topic through the second mapping relationship.

[0054] Optionally, an internal, stateful mapping can be created. After obtaining the query results, the client's query command, client identifier, and the list of target topic patterns retrieved are associated with a mapping relationship and stored in a second mapping relationship. Each mapping in the second mapping relationship constitutes a "virtual topic," resolving a metadata query into a set of specific, actual topic subscriptions. For the client, this means subscribing to a single "virtual topic" representing the query.

[0055] This approach transforms the way topics are managed in large-scale IoT systems, eliminating the need to understand complex, precise topic structures and allowing users to directly query and subscribe to the required data through intuitive metadata. This subscription method reduces the complexity of subscription and management, while improving the flexibility and scalability of topic subscriptions.

[0056] Step S104: Receive data published by the physical device to the target MQTT topic, and in response to the target MQTT topic matching the target topic pattern in the second mapping relationship, forward the data to the corresponding client.

[0057] Optionally, real-time message routing can be performed after subscription. When a device publishes data to a specific topic (e.g., sensors / acme / thermo-101 / temperature), after the message arrives at the subscription router, it is determined whether the target MQTT topic sensors / acme / thermo-101 / temperature matches the sensor / acme / + / temperature pattern. If the target MQTT topic is part of the above target topic pattern, the data is forwarded to the client corresponding to the semantic query to achieve real-time message routing.

[0058] In this way, after querying and subscribing to the required topics through intuitive metadata, real-time message routing is automatically implemented, simplifying the subscription operation, reducing the difficulty of subscription and management, and improving the real-time performance and scalability of topic subscriptions.

[0059] In one example, step S104 includes:

[0060] In response to the target MQTT topic belonging to the target topic pattern in the second mapping relationship, the corresponding target client identifier is determined from the second mapping relationship based on the target topic pattern. Data is then forwarded to the target client based on the target client identifier.

[0061] Optionally, real-time message routing can be performed after subscription. When a device publishes data to a specific topic (e.g., sensors / acme / thermo-101 / temperature), after the message arrives at the subscription router, it is determined that the target MQTT topic sensors / acme / thermo-101 / temperature belongs to the sensor / acme / + / temperature topic pattern. If the target MQTT topic is part of the above target topic pattern, the corresponding target client identifier is determined from the second mapping relationship according to the target topic pattern, and the data is forwarded to the corresponding client to achieve real-time message routing.

[0062] In this way, after querying and subscribing to the required topics through intuitive metadata, real-time message routing is automatically implemented, simplifying the subscription operation, reducing the difficulty of subscription and management, and improving the real-time performance and scalability of topic subscriptions.

[0063] In one example, the method also includes:

[0064] In step S501, in response to the configuration of a new physical device, the newly added metadata and new theme mode corresponding to the device are added to the first mapping relationship through the preset management API.

[0065] Step S502: Determine the corresponding semantic query command based on the newly added metadata, and determine the corresponding target topic pattern from the first mapping relationship based on the semantic query command.

[0066] Step S503: Update the second mapping relationship based on the semantic query command and target topic pattern corresponding to the newly added metadata, and the client identifier corresponding to the device.

[0067] Optionally, when a new device is configured, its metadata is added to the first mapping relationship in the metadata store via API, and the second mapping relationship is automatically updated based on the target topic pattern corresponding to the newly added metadata. In this way, when a new device is configured, the first and second mapping relationships are dynamically updated, thereby enabling dynamic and evolving query subscriptions to topics and improving the real-time performance, flexibility, and scalability of topic subscriptions.

[0068] Optionally, when a new device is configured, the semantic queries in the second mapping relationship can be re-evaluated. If a newly added topic pattern is found to match a certain semantic query, the internal mapping corresponding to that query is dynamically updated, that is, the target topic pattern corresponding to that query in the second mapping relationship, and the new topic pattern is added. Specifically, the semantic query commands in the second mapping relationship that match the newly added topic pattern include: the query results of the semantic query command in the updated first mapping relationship include the newly added topic pattern.

[0069] In this way, when a new device is configured and its metadata matches an existing query, the first mapping relationship is automatically updated based on the new metadata and the new topic pattern. The new topic pattern is then added to the target topic pattern corresponding to the matched query command to update the second mapping relationship. This enables dynamic and evolving query subscriptions to topics, improving the real-time performance, flexibility, and scalability of topic subscriptions.

[0070] In one example, after step S503, the method further includes: receiving information published by a new physical device, determining the corresponding target client from the updated second mapping relationship based on the topic in the information, and automatically forwarding the information to the corresponding target client.

[0071] Optionally, upon receiving information published by a new physical device, the system determines the corresponding client identifier from the updated second mapping relationship based on the topic in the information, identifies the target client based on the client identifier, and automatically forwards the information to the corresponding target client. In this way, when a new device publishes a message, the message is automatically forwarded to the relevant client according to the updated mapping relationship. The client can start receiving data from the new device without any operation, thus achieving seamless data flow.

[0072] In summary, by introducing a metadata store to store the first mapping relationship between metadata and topic patterns, data subscription is decoupled from a fixed topic hierarchy, which helps reduce the complexity of topic subscription. This changes the way topics are managed in large-scale IoT systems, eliminating the need to understand complex, precise topic structures; users can directly query and subscribe to the required data through intuitive metadata. This subscription method reduces the difficulty of subscription and management, and increases the flexibility and scalability of topic subscriptions. When a new device is configured and its metadata matches an existing query, the first mapping relationship is automatically updated based on the new metadata and the new topic pattern. The new topic pattern is then added to the target topic pattern corresponding to the matched query command to update the second mapping relationship. This enables dynamic and evolving query subscriptions to topics, improving the real-time performance, flexibility, and scalability of topic subscriptions. When a new device publishes a message, the message is automatically forwarded to the relevant clients based on the updated mapping relationship. Clients can begin receiving data from the new device without any operation, thus achieving seamless data flow.

[0073] Secondly, embodiments of this application provide a metadata-based MQTT topic subscription system, which is used to work with MQTT brokers, clients, and physical devices. Figure 2 This is a structural block diagram of a metadata-based MQTT topic subscription system according to an embodiment of this application, such as... Figure 2 As shown, the system includes:

[0074] Metadata storage module 100: Used to obtain the first mapping relationship between metadata and topic schema.

[0075] Subscription module 200: Used to receive messages sent by clients, including semantic query commands and client identifiers. The target topic pattern is determined from the first mapping relationship based on the semantic query commands, which are determined based on the target metadata.

[0076] Topic module 300: Used to store a second mapping relationship between semantic query commands, client identifiers and corresponding target topic patterns, so as to subscribe to the target topic through the second mapping relationship.

[0077] Message routing module 400: Used to receive data published by physical devices to target MQTT topics, and in response to the target MQTT topic matching the target topic pattern in the second mapping relationship, forward the data to the corresponding client.

[0078] In one example, the semantic query command is configured to determine the target topic pattern based on the target metadata in the message according to a preset query language, and the subscribed module 200 includes: for executing the semantic query command, and determining the target topic pattern from the first mapping relationship according to the semantic query command.

[0079] In one example, the message routing module 400 includes: in response to a target MQTT topic belonging to a target topic pattern in a second mapping relationship, determining the corresponding target client identifier from the second mapping relationship based on the target topic pattern.

[0080] Data is forwarded to the target client based on the target client identifier.

[0081] In one example, the first mapping relationship in the metadata storage module 100 is configured to be obtained by: initializing the first mapping relationship and managing the first mapping relationship between metadata and topic patterns through a preset management API.

[0082] In one example, the system also includes:

[0083] New Unit: In response to the configuration of a new physical device, the new metadata and new theme mode corresponding to the device are added to the first mapping relationship through the preset management API.

[0084] Query unit: used to determine the corresponding semantic query command based on the newly added metadata, and to determine the corresponding target topic pattern from the first mapping relationship based on the semantic query command;

[0085] Update unit: used to update the second mapping relationship based on the semantic query command and target topic pattern corresponding to the newly added metadata, and the client identifier corresponding to the device.

[0086] In one example, after the update unit, the system also includes: receiving information published by a new physical device, determining the corresponding target client from the updated second mapping relationship based on the topic in the information, and automatically forwarding the information to the corresponding target client.

[0087] In summary, by introducing a metadata store to store the first mapping relationship between metadata and topic patterns, data subscription is decoupled from a fixed topic hierarchy, which helps reduce the complexity of topic subscription. This changes the way topics are managed in large-scale IoT systems, eliminating the need to understand complex, precise topic structures; users can directly query and subscribe to the required data through intuitive metadata. This subscription system reduces the difficulty of subscription and management, and increases the flexibility and scalability of topic subscriptions. When a new device is configured and its metadata matches an existing query, the first mapping relationship is automatically updated based on the new metadata and the new topic pattern. The new topic pattern is then added to the target topic pattern corresponding to the matched query command to update the second mapping relationship. This enables dynamic and evolving query subscriptions to topics, improving the real-time performance, flexibility, and scalability of topic subscriptions. When a new device publishes a message, the message is automatically forwarded to the relevant clients based on the updated mapping relationship. Clients can begin receiving data from the new device without any operation, thus achieving seamless data flow.

[0088] Thirdly, embodiments of this application provide an electronic device, Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the metadata-based MQTT topic subscription method provided in the first aspect. Figure 3 The electronic device 60 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0089] Electronic device 60 may be in the form of a general-purpose computing device, such as a server device. Components of electronic device 60 may include, but are not limited to: at least one processor 61, at least one memory 62, and a bus 63 connecting different system components (including memory 62 and processor 61).

[0090] Bus 63 includes a data bus, an address bus, and a control bus.

[0091] The memory 62 may include volatile memory, such as random access memory (RAM) 621 and / or cache memory 622, and may further include read-only memory (ROM) 623.

[0092] The memory 62 may also include a program / utility 625 having a set (at least one) of program modules 624, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0093] The processor 61 executes various functional applications and data processing by running computer programs stored in the memory 62, such as the metadata-based MQTT topic subscription method provided in the first aspect of this application.

[0094] Electronic device 60 can also communicate with one or more external devices 64 (e.g., keyboard, pointing device, etc.). This communication can be performed via input / output (I / O) interface 65. Furthermore, the model-generated electronic device 60 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 66. Figure 3 As shown, network adapter 66 communicates with other modules of the model-generated electronic device 60 via bus 63. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the model-generated electronic device 60, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems.

[0095] It should be noted that although several units / modules or sub-units / modules of the electronic device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.

[0096] Fourthly, embodiments of this application provide a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements a metadata-based MQTT topic subscription method provided in the first aspect.

[0097] The readable storage medium may be more specifically adopted, including but not limited to: portable disk, hard disk, random access memory, read-only memory, erasable programmable read-only memory, optical storage device, magnetic storage device, or any suitable combination thereof.

[0098] In a possible implementation, the invention can also be implemented as a program product comprising program code that, when the program product is run on a terminal device, causes the terminal device to perform steps implementing a metadata-based MQTT topic subscription method provided in the first aspect.

[0099] The program code for executing the present invention can be written in any combination of one or more programming languages. The program code can be executed entirely on the user device, partially on the user device, as a standalone software package, partially on the user device and partially on a remote device, or entirely on a remote device.

[0100] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0101] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A metadata-based MQTT topic subscription method, characterized in that, The method is applied to an MQTT broker, which works with clients and physical devices. The method includes: Obtain the initial mapping relationship between metadata and theme schema; Receive a message sent by a client, the message including a semantic query command and a client identifier, determine a target topic pattern from the first mapping relationship based on the semantic query command, the semantic query command being determined based on target metadata; The second mapping relationship between the semantic query command, the client identifier and the corresponding target topic pattern is stored, so as to subscribe to the target topic through the second mapping relationship, and each mapping in the second mapping relationship constitutes a 'virtual topic'; The system receives data published by the physical device to the target MQTT topic, and forwards the data to the corresponding client in response to the target MQTT topic matching the target topic pattern in the second mapping relationship.

2. The MQTT topic subscription method based on metadata according to claim 1, characterized in that, The semantic query command is configured to determine the target topic pattern based on the target metadata in the message according to a preset query language. The step of determining the target topic pattern from the first mapping relationship according to the semantic query command includes: Execute the semantic query command to determine the target topic pattern from the first mapping relationship based on the semantic query command.

3. The MQTT topic subscription method based on metadata according to claim 1, characterized in that, The step of forwarding the data to the corresponding client in response to a match between the target MQTT topic and the target topic pattern in the second mapping relationship includes: In response to the fact that the target MQTT topic belongs to the target topic pattern in the second mapping relationship, the corresponding target client identifier is determined from the second mapping relationship according to the target topic pattern; The data is forwarded to the target client based on the target client identifier.

4. The MQTT topic subscription method based on metadata according to claim 1, characterized in that, The first mapping relationship is configured to be obtained in the following way: Initialize the first mapping relationship and manage the first mapping relationship between metadata and theme mode through the preset management API.

5. The MQTT topic subscription method based on metadata according to claim 4, characterized in that, The method further includes: In response to the configuration of a new physical device, the newly added metadata and new theme mode corresponding to the device are added to the first mapping relationship through the preset management API; Based on the newly added metadata, determine the corresponding semantic query command, and based on the semantic query command, determine the corresponding target topic pattern from the first mapping relationship; The second mapping relationship is updated based on the semantic query command and target topic pattern corresponding to the newly added metadata, and the client identifier corresponding to the device.

6. The MQTT topic subscription method based on metadata according to claim 5, characterized in that, After updating the second mapping, the method further includes: Upon receiving information published by a new physical device, the system determines the corresponding target client from the updated second mapping relationship based on the topic in the information and automatically forwards the information to the corresponding target client.

7. A metadata-based MQTT topic subscription system, characterized in that, The system is used to work with MQTT brokers, clients, and physical devices, and includes: Metadata storage module: used to obtain the initial mapping relationship between metadata and topic schema; Subscription module: Used to receive messages sent by clients, the messages including semantic query commands and client identifiers, and to determine the target topic pattern from the first mapping relationship based on the semantic query commands, the semantic query commands being determined based on target metadata; Topic module: Used to store the second mapping relationship between the semantic query command, the client identifier and the corresponding target topic pattern, so as to subscribe to the target topic through the second mapping relationship. Each mapping in the second mapping relationship constitutes a 'virtual topic'. Message routing module: Used to receive data published by the physical device to the target MQTT topic, and in response to the target MQTT topic matching the target topic pattern in the second mapping relationship, forward the data to the corresponding client.

8. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the computer program, implements a metadata-based MQTT topic subscription method as described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements a metadata-based MQTT topic subscription method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Smart city MQTT message management method and system

    CN116233100A