MQTT theme subscription method and system based on metadata and electronic equipment

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

CN121644657AActive Publication Date: 2026-03-10HANGZHOU YINGYUN TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-03
Publication Date
2026-03-10

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 not flexible.

Method used

By introducing metadata storage, a mapping relationship between metadata and topic schema is established. Subscription is performed using semantic query commands, and the required data can be queried and subscribed directly through metadata. The mapping relationship is dynamically updated 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 CN121644657A_ABST
    Figure CN121644657A_ABST
Patent Text Reader

Abstract

The invention relates to a metadata-based MQTT theme subscription method and system and electronic device.The metadata-based MQTT theme subscription method is applied to an MQTT proxy, the proxy is matched with a client and physical device.The method comprises the steps that a first mapping relation between metadata and theme modes is obtained; a message sent by the client is received, the message comprises a semantic query command and a client identifier, a target theme mode is determined from the first mapping relation according to the semantic query command, and the semantic query command is determined based on the target metadata; storing a second mapping relationship among the semantic query command, the client identifier and the corresponding target theme mode so as to subscribe to the target theme through the second mapping relationship; and receiving data published by the physical device to the target MQTT theme, and forwarding the data to the corresponding client in response to matching of the target MQTT theme and the target theme mode in the second mapping relationship.
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 communication, in particular to an MQTT topic subscription method and system based on metadata and an electronic device. BACKGROUND

[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 Internet of Things systems containing thousands or even millions of devices and data points, the topic space management complexity and difficulty are relatively large.

[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 grows, the topic tree becomes exceptionally large, making it difficult to manage and navigate. (2) Subscription method is not flexible. The client must know the exact topic string (or use wildcards) to subscribe to the required data. (2) Unable to query based on data attributes. It is not possible to subscribe to data based on data characteristics or metadata. For example, a user cannot easily subscribe to "all temperature sensors located in building 1 and produced by X manufacturer" data, as the specific topics of all these sensors need to be known in advance.

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

[0005] The embodiments of the present application provide an MQTT topic subscription method, system and electronic device based on metadata to at least solve the problem of low flexibility and high management difficulty of the topic subscription method in related technologies.

[0006] In a first aspect, the embodiments of the present application provide an MQTT topic subscription method based on metadata, which is applied to an MQTT broker. The broker cooperates with a client and a physical device. The method comprises: obtaining a first mapping relationship between metadata and topic patterns; receiving a message sent by a client, the message including a semantic query command and a client identifier, determining a target topic pattern from the first mapping relationship according to the semantic query command, the semantic query command being determined based on target metadata; storing 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; receiving data published by the physical device to a target MQTT topic, and forwarding the data to a corresponding client in response to the target MQTT topic matching a target topic pattern in the second mapping relationship.

[0007] In an embodiment, the semantic query command is configured to be determined based on target metadata in the message according to a preset query language, and determining the target topic pattern from the first mapping relationship according to the semantic query command comprises: executing the semantic query command, and determining the target topic pattern from the first mapping relationship according to the semantic query command.

[0008] In an embodiment, the forwarding the data to the corresponding client in response to the target MQTT topic matching the target topic pattern in the second mapping relationship comprises: determining a corresponding target client identifier from the second mapping relationship according to the target topic pattern in response to the target MQTT topic belonging to the target topic pattern in the second mapping relationship; forwarding the data to the target client according to the target client identifier.

[0009] In an embodiment, the first mapping relationship 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.

[0010] In an embodiment, the method further comprises: adding new metadata corresponding to the device and a new topic pattern to the first mapping relationship through the preset management API in response to a new physical device being configured; determining a corresponding semantic query command according to the new metadata, and determining a corresponding target topic pattern from the first mapping relationship according to the semantic query command; updating the second mapping relationship based on the semantic query command and the target topic pattern corresponding to the new metadata, and a client identifier corresponding to the device.

[0011] In an embodiment, after updating the second mapping relationship, the method further comprises: receiving information published by a new physical device, determining a corresponding target client from the updated second mapping relationship according to a topic in the information, and automatically forwarding the information to the corresponding target client.

[0012] In a second aspect, the embodiments of the present application provide a metadata-based MQTT topic subscription system, which is used in cooperation with an MQTT broker, a client and a physical device, and the system comprises: a metadata storage module, configured to acquire a first mapping relationship between metadata and topic patterns; a subscription module, configured to receive a message sent by a client, the message comprising a semantic query command and a client identifier, determine a target topic pattern from the first mapping relationship according to the semantic query command, and determine the semantic query command based on target metadata; a topic module, configured to store a second mapping relationship between the semantic query command, the client identifier and the corresponding target topic pattern, and subscribe to the target topic through the second mapping relationship; a message routing module, configured to receive data published by the physical device to a target MQTT topic, and forward the data to a corresponding client in response to the target MQTT topic matching the target topic pattern in the second mapping relationship.

[0013] In a third aspect, the embodiments of the present application provide a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the metadata-based MQTT topic subscription method according to the first aspect when executing the computer program.

[0014] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the program is executable on a processor to implement the metadata-based MQTT topic subscription method according to the first aspect.

[0015] The metadata-based MQTT topic subscription method, system and electronic device provided by the embodiments of the present application have at least the following technical effects.

[0016] In summary, by introducing the metadata to store the first mapping relationship between the metadata and the topic pattern, the data subscription is decoupled from the fixed topic hierarchy, which is conducive to reducing the complexity of topic subscription. The topic management method in a large-scale Internet of Things system is changed, without the need to understand the complex exact topic structure, and the required data is directly queried and subscribed through intuitive metadata. This subscription method reduces the difficulty of subscription and management, and improves the flexibility and scalability of topic subscription. After the required topic is queried and subscribed through intuitive metadata, real-time message routing is automatically implemented, the subscription operation is simplified, and the real-time performance of topic subscription is improved.

[0017] Details of one or more embodiments of the present application are presented in the following drawings and description to make other features, objects and advantages of the present application more apparent. BRIEF DESCRIPTION OF DRAWINGS

[0018] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the present application and together with the description serve to explain the present application. In the drawings: Figure 1 is a flow chart of a metadata-based MQTT topic subscription method according to an embodiment of the present application; Figure 2 is a structural block diagram of a metadata-based MQTT topic subscription system according to an embodiment of the present application; Figure 3 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0019] In order to make the objects, technical solutions and advantages of the present application clearer, the present application is described and explained below in connection with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. Based on the embodiments provided by the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the present application.

[0020] Obviously, the drawings in the following description are only some examples or embodiments of the present application, and for those of ordinary skill in the art, the present application can be applied to other similar scenarios without creative labor on the basis of these drawings. In addition, it can be understood that although the efforts made in this development process can be complex and lengthy, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacture or production changes based on the technical content disclosed in the present application are only routine technical means and should not be understood as insufficient disclosure of the present application.

[0021] In the present application, "embodiment" means that the specific features, structures or properties described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears at various places in the specification does not necessarily refer to the same embodiment, nor is it mutually exclusive or alternative to other embodiments. Those of ordinary skill in the art explicitly and implicitly understand that the embodiments described in the present application can be combined with other embodiments without conflict.

[0022] Unless otherwise defined, technical terms and scientific terms used in the present application shall have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. Unless otherwise defined, the terms "one" and "a" or "an" used in this application do not denote a singular noun, but can denote both the singular and plural forms. The terms "comprising", "including", "containing", "have" and any variations thereof used in this application are intended to cover a non-exclusive inclusion. For example, a process, method, system, product or device that includes a list of steps or units (elements) is not limited to the listed steps or units, but can further include other steps or units not listed or inherent to such processes, methods, products or devices. The terms "connected", "connected to", "coupled" and the like used in this application are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. The term "multiple" refers to two or more. The term "and / or" describes the association relationship of the associated objects, which means that there can be three relationships, for example, "A and / or B" can mean that A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects. The terms "first", "second", "third" and the like used in this application are only to distinguish similar objects, and do not represent a specific order of the objects.

[0023] In a first aspect, the embodiments of the present application provide a metadata-based MQTT topic subscription method. The method is applied to an MQTT broker, and the broker cooperates with a client and a physical device. Figure 1 is a flowchart of a metadata-based MQTT topic subscription method according to an embodiment of the present application, as shown in Figure 1 The method comprises the following steps: In step S101, a first mapping relationship between metadata and a topic pattern is obtained.

[0024] Optionally, a metadata storage is maintained inside the MQTT broker, and the metadata storage is used to store the first mapping relationship, so as to associate rich key-value pair metadata (such as device type, manufacturer, physical location, etc.) with an MQTT topic. Through the introduced metadata storage, the data subscription is decoupled from the fixed topic hierarchy, which is conducive to reducing the complexity of topic subscription.

[0025] 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 the metadata and the topic pattern through a preset management API.

[0026] Optionally, the MQTT broker starts and initializes its internal metadata store for storing the first mapping relationship. An administrator or an automated device provisioning system associates and stores rich metadata with a topic pattern through a metadata management API. For example, metadata {"manufacturer" : "acme", "device_type" : "thermostat"} is associated with the topic pattern sensors / acme / + / temperature. The metadata is associated with the topic pattern in a mapping relationship. In this way, by introducing the metadata store, the data subscription is decoupled from the fixed topic hierarchy, which is conducive to reducing the complexity of the topic subscription.

[0027] In step S102, a message sent by a client is received, the message including a semantic query command and a client identifier, and a target topic pattern is determined from the first mapping relationship according to the semantic query command, the semantic query command being determined based on target metadata.

[0028] Optionally, the client subscribes through metadata query instead of subscribing to data through a topic string only. Instead of using a standard SUBSCRIBE command, a query language (for example, a message is published to a reserved topic $subscribe / query) is introduced to submit a semantic query. For example, the query command is "query" : "SELECT WHERE metadata.device_type = 'thermostat' AND metadata.manufacturer = 'acme'", which is used to query and subscribe to information corresponding to metadata of a device type of thermostat and a manufacturer of acme from the first mapping relationship, and a list of topic patterns corresponding to the metadata that meets the condition is taken as the target topic pattern. The semantic query command is generated based on target metadata.

[0029] In this way, the topic management manner in a large-scale Internet of Things system is changed, without the need to understand a complex exact topic structure, and the required data is directly queried and subscribed through intuitive metadata. This subscription manner reduces the difficulty of subscription and management.

[0030] In one example, the semantic query command is configured to be determined based on 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.

[0031] 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. The query subscription is based on metadata attributes, for example, the client can initiate a subscription request of SELECT topics WHERE metadata.deviceType = 'thermostat' AND metadata.location.building = 'building1' to query and subscribe to all topics that satisfy the following two conditions: ① the associated device type is thermostat; ② the physical location of the device is in building1. The list of topic patterns that match the query is the list of target topic patterns, for example ["sensors / acme / + / temperature"].

[0032] In this way, the topic management in a large-scale IoT system is changed, without the need to understand the complex exact topic structure, and the required data is directly queried and subscribed through intuitive metadata. This subscription method reduces the difficulty of subscription and management.

[0033] In step S103, a 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.

[0034] Optionally, an internal and stateful mapping is created. After obtaining the query result, the query command of the client, the client identifier and the list of target topic patterns obtained by querying are associated in a mapping relationship and stored in the second mapping relationship. Each mapping in the second mapping relationship constitutes a "virtual topic", and a metadata query is parsed into a set of specific and actual topic subscription collection. For the client, a single "virtual topic" representing the query is subscribed.

[0035] In this way, the topic management in a large-scale IoT system is changed, without the need to understand the complex exact topic structure, and the required data is directly queried and subscribed through intuitive metadata. This subscription method reduces the difficulty of subscription and management, and improves the flexibility and scalability of topic subscription.

[0036] In step S104, data published by a physical device to a target MQTT topic is received, and in response to the target MQTT topic matching the target topic pattern in the second mapping relationship, the data is forwarded to the corresponding client.

[0037] Optionally, after subscription, real-time message routing is performed. When a device publishes data to a specific topic (for example, 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 matches the sensors / acme / + / temperature pattern, the target MQTT topic is part of the target topic pattern, and the data is forwarded to the corresponding client of the semantic query to realize real-time message routing.

[0038] In this way, after the required topic is queried and subscribed through intuitive metadata, real-time message routing is automatically realized, the subscription operation is simplified, the difficulty of subscription and management is reduced, and the real-time performance and scalability of topic subscription are improved.

[0039] In one example, step S104 includes: 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 according to the target topic pattern. The data is forwarded to the target client according to the target client identifier.

[0040] Optionally, after subscription, real-time message routing is performed. When a device publishes data to a specific topic (for example, 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 sensors / acme / + / temperature topic pattern, the target MQTT topic is part of the target topic pattern, and the data is forwarded to the corresponding client according to the target topic pattern to realize real-time message routing.

[0041] In this way, after the required topic is queried and subscribed through intuitive metadata, real-time message routing is automatically realized, the subscription operation is simplified, the difficulty of subscription and management is reduced, and the real-time performance and scalability of topic subscription are improved.

[0042] In one example, the method further includes: Step S501, in response to a new physical device being configured, adding the corresponding new metadata of the device and the new topic pattern to the first mapping relationship through a preset management API.

[0043] Step S502, determining the corresponding semantic query command according to the new metadata, and determining the corresponding target topic pattern from the first mapping relationship according to the semantic query command.

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

[0045] Optionally, when a new device is configured, its metadata is added to the first mapping relationship in the metadata storage through an API, and the corresponding target topic pattern is queried according to the newly added metadata, and the second mapping relationship is automatically updated. In this way, when a new device is configured, the first mapping relationship and the second mapping relationship are dynamically updated, so that the dynamic and evolving query subscription topic is realized, and the real-time performance, flexibility and scalability of the topic subscription are improved.

[0046] Optionally, when a new device is configured, the semantic query in the second mapping relationship can also be re-evaluated, and if it is found that the newly added topic pattern also matches a certain semantic query, the internal mapping corresponding to the query, i.e., the target topic pattern corresponding to the query in the second mapping relationship, is dynamically updated, and the new topic pattern is added. Among them, the newly added topic pattern matching the semantic query command in the second mapping relationship includes that the query result of the semantic query command in the updated first mapping relationship includes the newly added topic pattern.

[0047] In this way, when a new device is configured and its metadata matches a certain existing query, the first mapping relationship is automatically updated according to the newly added metadata and the newly added topic pattern, and the newly added topic pattern is added to the target topic pattern corresponding to the matched query command to update the second mapping relationship. Thus, the dynamic and evolving query subscription topic is realized, and the real-time performance, flexibility and scalability of the topic subscription are improved.

[0048] 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 according to the topic in the information, and automatically forwarding the information to the corresponding target client.

[0049] Optionally, the information published by the new physical device is received, the corresponding client identifier is determined from the updated second mapping relationship according to the topic in the information, the target client is determined according to the client identifier, and the information is automatically forwarded to the corresponding target client. In this way, when a new device publishes a message, the message is automatically forwarded to the related client according to the updated mapping relationship, and the client can start receiving the data of the new device without any operation, so that seamless data flow is realized.

[0050] In summary, by introducing the metadata storage to store the first mapping relationship between the metadata and the topic pattern, the data subscription is decoupled from the fixed topic hierarchy, which is conducive to reducing the complexity of the topic subscription. Changing the topic management manner in the large-scale Internet of Things system, without understanding the complex exact topic structure, the required data can be directly queried and subscribed through the intuitive metadata. This subscription manner reduces the difficulty of subscription and management, and improves the flexibility and scalability of the topic subscription. When a new device is configured, and the metadata of the new device matches a certain existing query, the first mapping relationship is automatically updated according to the new metadata and the new topic pattern, and the new topic pattern is added to the target topic pattern corresponding to the matched query command, so as to update the second mapping relationship. Thus, the dynamic and evolving query subscription topic is realized, and the real-time performance, flexibility and scalability of the topic subscription are improved. When a new device publishes a message, the message is automatically forwarded to the related client according to the updated mapping relationship, and the client can start receiving the data of the new device without any operation, so as to realize seamless data flow.

[0051] In a second aspect, an embodiment of the present application provides a metadata-based MQTT topic subscription system, which is used in cooperation with an MQTT broker, a client and a physical device. Figure 2 is a structural block diagram of a metadata-based MQTT topic subscription system according to an embodiment of the present application, as shown in Figure 2 The system includes: The metadata storage module 100 is configured to obtain a first mapping relationship between the metadata and the topic pattern.

[0052] The subscription module 200 is configured to receive a message sent by the client, the message including a semantic query command and a client identifier, determine a target topic pattern from the first mapping relationship according to the semantic query command, and determine the semantic query command based on the target metadata.

[0053] The topic module 300 is configured 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.

[0054] The message routing module 400 is configured to receive data published by the physical device to a target MQTT topic, and forward the data to the corresponding client in response to the target MQTT topic matching the target topic pattern in the second mapping relationship.

[0055] In one example, the semantic query command is configured to be determined based on the target metadata in the message according to a preset query language, and the subscription module 200 includes a module configured to execute the semantic query command and determine the target topic pattern from the first mapping relationship according to the semantic query command.

[0056] 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.

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

[0058] 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.

[0059] In one example, the system also includes: 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.

[0060] 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; 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.

[0061] 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.

[0062] 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.

[0063] 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.

[0064] 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).

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

[0066] 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.

[0067] 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.

[0068] 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.

[0069] 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 3As 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.

[0070] 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.

[0071] 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.

[0072] 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.

[0073] 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.

[0074] 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.

[0075] 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.

[0076] 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 cooperating with a client and a physical device, and the method comprises: obtaining a first mapping relationship between metadata and topic patterns; receiving a message sent by the client, the message comprising a semantic query command and a client identifier, determining a target topic pattern from the first mapping relationship according to the semantic query command, the semantic query command being determined based on target metadata; storing 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; 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 pattern in the second mapping relationship.

2. The metadata-based MQTT topic subscription method of claim 1, wherein, The semantic query command is configured to be determined based on target metadata in the message according to a preset query language, and the determining of the target topic pattern from the first mapping relationship according to the semantic query command comprises: executing the semantic query command, and determining the target topic pattern from the first mapping relationship according to the semantic query command.

3. The metadata-based MQTT topic subscription method of claim 1, wherein, The forwarding of the data to the corresponding client in response to the target MQTT topic matching the target topic pattern in the second mapping relationship comprises: determining a corresponding target client identifier from the second mapping relationship according to the target topic pattern in response to the target MQTT topic belonging to the target topic pattern in the second mapping relationship; forwarding the data to the target client according to the target client identifier.

4. The metadata-based MQTT topic subscription method of claim 1, wherein, The first mapping relationship 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.

5. The metadata-based MQTT topic subscription method of claim 4, wherein, The method further comprises: in response to a new physical device being configured, adding new metadata corresponding to the device and a new topic pattern to the first mapping relationship through the preset management API; determining a corresponding semantic query command according to the new metadata, and determining a corresponding target topic pattern from the first mapping relationship according to the semantic query command; updating the second mapping relationship based on the semantic query command and the target topic pattern corresponding to the new metadata, and a client identifier corresponding to the device.

6. The metadata-based MQTT topic subscription method of claim 5, wherein, After updating the second mapping relationship, the method further comprises: receiving information published by a new physical device, determining a corresponding target client from the updated second mapping relationship according to a topic in the information, and automatically forwarding the information to the corresponding target client.

7. A metadata-based MQTT topic subscription system, characterized in that, The system is used in cooperation with an MQTT broker, a client and a physical device, and the system comprises: a metadata storage module for obtaining a first mapping relationship between metadata and topic patterns; a subscription module for receiving a message sent by the client, the message comprising a semantic query command and a client identifier, and determining a target topic pattern from the first mapping relationship according to the semantic query command, the semantic query command being determined based on target metadata; A subject module is configured to store a second mapping relationship between the semantic query command, the client identifier and a corresponding target subject pattern, so as to subscribe to the target subject through the second mapping relationship. A message routing module is configured to receive data published by the physical device to a target MQTT subject, and in response to the target MQTT subject matching a target subject pattern in the second mapping relationship, forward the data to the corresponding client.

8. An electronic device, comprising: A computer program product comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the metadata-based MQTT subject subscription method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the metadata-based MQTT subject subscription method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Subscription publishing method and server

    CN109428922A

  • MQTT-based publishing and subscribing matching method and device and storage medium

    CN109862063A

  • Content publishing method, system and device

    CN112307318A

  • Event management system and method

    CN115550439A

  • Smart city MQTT message management method and system

    CN116233100A