Search

CN-121644657-B - Metadata-based MQTT theme subscription method, system and electronic equipment

CN121644657BCN 121644657 BCN121644657 BCN 121644657BCN-121644657-B

Abstract

The application relates to a metadata-based MQTT topic subscription method, a system and electronic equipment, wherein the metadata-based MQTT topic subscription method is applied to an MQTT proxy, the proxy is matched with a client and physical equipment, the method comprises the steps of obtaining a first mapping relation between metadata and topic modes, receiving information sent by the client, determining a target topic mode from the first mapping relation according to the semantic query command, determining the semantic query command based on the target metadata, storing a second mapping relation between the semantic query command, the client identification and the corresponding target topic mode to subscribe a target topic through the second mapping relation, receiving data published to the target MQTT by the physical equipment, responding to matching of the target topic mode in the target MQTT topic and the second mapping relation, and forwarding the data to the corresponding client.

Inventors

  • FENG ZHIFEI
  • ZHANG JIAXING
  • Deng Haigui

Assignees

  • 杭州映云科技有限公司

Dates

Publication Date
20260508
Application Date
20260203

Claims (9)

  1. 1. A metadata-based MQTT theme subscription method, wherein the method is applied to an MQTT proxy, the proxy cooperating with a client and a physical device, the method comprising: acquiring a first mapping relation between metadata and a theme mode; Receiving a message sent by a client, wherein 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 target metadata; Storing a second mapping relation among the semantic query command, the client identification and the corresponding target theme mode to subscribe to the target theme through the second mapping relation, wherein each mapping in the second mapping relation forms a virtual theme; and receiving data issued by the physical equipment to a target MQTT theme, and forwarding the data to a corresponding client in response to the target MQTT theme being matched with a target theme pattern in the second mapping relation.
  2. 2. The metadata-based MQTT theme subscription method of claim 1, wherein the semantic query command is configured to determine the target theme pattern from the first mapping relationship based on the target metadata in the message according to a preset query language, comprising: Executing the semantic query command, and determining a target theme mode from the first mapping relation according to the semantic query command.
  3. 3. The metadata-based MQTT theme subscription method of claim 1, wherein the forwarding the data to the corresponding client in response to the target MQTT theme pattern matching with the target theme pattern in the second mapping relationship comprises: responding to the target theme mode of the target MQTT theme belonging to the second mapping relation, and determining a corresponding target client identifier from the second mapping relation according to the target theme mode; and forwarding the data to the target client according to the target client identifier.
  4. 4. The metadata-based MQTT theme subscription method of claim 1, wherein the first mapping relation is configured to be obtained by: initializing the first mapping relation, and managing the first mapping relation between the metadata and the theme mode through a preset management API.
  5. 5. The metadata-based MQTT theme subscription method of claim 4, further comprising: responding to the configuration of new physical equipment, and adding new metadata and a new theme mode corresponding to the equipment into the first mapping relation through the preset management API; determining a corresponding semantic query command according to the newly added metadata, and determining a corresponding target theme mode from the first mapping relation according to the semantic query command; and updating the second mapping relation based on the semantic query command and the target theme mode corresponding to the newly added metadata and the client identifier corresponding to the equipment.
  6. 6. The metadata-based MQTT theme subscription method of claim 5, wherein after updating the second mapping relation, the method further comprises: and receiving information released by the new physical equipment, determining a corresponding target client from the updated second mapping relation according to the subject in the information, and automatically forwarding the information to the corresponding target client.
  7. 7. A metadata-based MQTT theme subscription system for cooperation with MQTT proxies, clients and physical devices, the system comprising: the metadata storage module is used for acquiring a first mapping relation between metadata and the theme mode; The subscription module is used for receiving a message sent by a client, wherein 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 target metadata; The theme module is used for storing a second mapping relation among the semantic query command, the client identification and the corresponding target theme mode so as to subscribe to the target theme through the second mapping relation, and each mapping in the second mapping relation forms a virtual theme'; And the message routing module is used for receiving data issued by the physical equipment to the target MQTT theme, and forwarding the data to the corresponding client in response to the matching of the target MQTT theme and the target theme mode in the second mapping relation.
  8. 8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing a metadata-based MQTT theme subscription method as claimed in any one of claims 1 to 6 when the computer program is executed.
  9. 9. A computer readable storage medium having stored thereon a computer program, wherein the program when executed by a processor implements a metadata-based MQTT theme subscription method as claimed in any one of claims 1 to 6.

Description

Metadata-based MQTT theme subscription method, system and electronic equipment Technical Field The application relates to the technical field of communication of the Internet of things, in particular to an MQTT theme subscription method, system and electronic equipment based on metadata. Background Message queue telemetry transport protocol (Message Queuing Telemetry Transport, MQTT) protocols employ a hierarchical topic structure, such as topic structure sensors/building1/floor2/room201/temperature, which is effective in a simple scenario, but is more complex and difficult to manage in a large-scale internet of things system containing thousands or even millions of devices and data points. The existing MQTT topic model has the following technical defects that (1) topics are flooded and management complexity is high. As device and data types grow, the subject tree becomes exceedingly large, difficult to manage and navigate. (2) the subscription mode is inflexible. The client must know the exact subject string (or use wild cards) to subscribe to the desired data. (2) cannot be queried according to data attributes. The data cannot be subscribed to according to the characteristics or metadata of the data. For example, a user cannot easily subscribe to the data of "all temperature sensors located in building 1, manufactured by manufacturer X", because the specific subject matter of all these sensors needs to be known in advance. Therefore, the flexibility of the existing MQTT theme subscription mode is not high, and the management difficulty is high. Disclosure of Invention The embodiment of the application provides a metadata-based MQTT topic subscription method, a metadata-based MQTT topic subscription system and electronic equipment, which at least solve the problems of low flexibility and high management difficulty of topic subscription modes in related technologies. In a first aspect, an embodiment of the present application provides a metadata-based MQTT theme subscription method, where the method is applied to an MQTT proxy, and the proxy cooperates with a client and a physical device, and the method includes: acquiring a first mapping relation between metadata and a theme mode; Receiving a message sent by a client, wherein 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 target metadata; Storing a second mapping relation among the semantic query command, the client identification and the corresponding target theme mode to subscribe to the target theme through the second mapping relation; and receiving data issued by the physical equipment to a target MQTT theme, and forwarding the data to a corresponding client in response to the target MQTT theme being matched with a target theme pattern in the second mapping relation. In an embodiment, the semantic query command is configured to determine, based on target metadata in the message, according to a preset query language, the determining a target topic pattern from the first mapping relationship according to the semantic query command includes: Executing the semantic query command, and determining a target theme mode from the first mapping relation according to the semantic query command. In an embodiment, the forwarding the data to the corresponding client in response to the target MQTT theme pattern matching with the target theme in the second mapping relationship includes: responding to the target theme mode of the target MQTT theme belonging to the second mapping relation, and determining a corresponding target client identifier from the second mapping relation according to the target theme mode; and forwarding the data to the target client according to the target client identifier. In an embodiment, the first mapping is configured to be obtained by: initializing the first mapping relation, and managing the first mapping relation between the metadata and the theme mode through a preset management API. In an embodiment, the method further comprises: responding to the configuration of new physical equipment, and adding new metadata and a new theme mode corresponding to the equipment into the first mapping relation through the preset management API; determining a corresponding semantic query command according to the newly added metadata, and determining a corresponding target theme mode from the first mapping relation according to the semantic query command; and updating the second mapping relation based on the semantic query command and the target theme mode corresponding to the newly added metadata and the client identifier corresponding to the equipment. In an embodiment, after updating the second mapping, the method further comprises: and receiving information released by the new physical equipment, determining a corresponding target client from the updated second mappin