A subscription publishing method and server
By storing the corresponding relationship between client identifiers and tags in the server, and using topic filters and tag matching mechanisms, the problem of difficulty in maintaining subscription relationships when the subscription client is expanded or migrated is solved, and the scalability and processing capabilities of the subscription client are improved. .
Patent Information
- Application Number
- CN202010708136.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2017-08-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2037-08-29
AI Technical Summary
In the existing technology, the subscription client needs to re-subscribe to the relationship when expanding or migrating, which makes it difficult to maintain the subscription relationship, and the adjustment of the subscription relationship due to regional division is complicated.
By pre-stored in the server the corresponding relationship between client identifiers and tags, and using topic filters and tag matching mechanisms, the attribute information of the subscribing client and the publishing client are matched, avoiding re-subscription and only requiring changes to the client attribute information.
It simplifies the maintenance of subscription relationships when the subscription client is expanding or migrating, improves the scalability and processing capabilities of the subscription client, and implements a more flexible subscription maintenance mechanism.
Smart Images

Figure CN112039942B
Abstract
Description
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is a divisional of a Chinese patent application filed on August 29, 2017, with application number CN201710757780.8 and invention name “A subscription publishing method and server”, all contents of which are incorporated by reference in this application. Technical Field
[0003] The embodiments of the present application relate to the field of communications, and in particular to a subscription publishing method and a server. Background Art
[0004] The Message Queue Telemetry Transport (MQTT) protocol is a message transmission protocol with a publish-subscribe mechanism. The publish-subscribe mechanism is as follows: the subscription client on the subscription terminal with management functions such as mobile phones and notebooks can send a subscription message containing a topic to the server, and the publishing client on the publishing terminal such as the temperature sensor can send a publishing message containing a topic to the server, so that the server can send the publishing message to the subscription client that subscribes to the topic contained in the publishing message. The MQTT protocol is lightweight, open, simple, and standardized, and can be applied to limited environments such as machine-to-machine communication (machine-to-machine, M2M) and the Internet of Things (internet of things, IOT).
[0005] In the IOT environment, the subscription client on the subscription terminal is usually used to manage a large number of publishing terminals through the publishing client on the publishing terminal. A subscription client can subscribe to the messages published by all publishing clients in the IOT environment through a topic containing a wildcard, and perform fan-in processing on all received published messages. The fan-in process is: the subscription client can perform complex operations such as aggregation and statistics on all published messages, and present the operation results to the user in the form of icons or pages, or send the operation results to the next layer of equipment. Obviously, at this time, the pressure of the subscription client to process the published messages is proportional to the number of publishing clients, but the ability of the subscription client to process the published messages is limited. Therefore, when the number of publishing clients reaches a certain scale, a subscription client cannot process all the published messages, and it is necessary to increase the subscription client to process the published messages in parallel with the subscription client. At this time, the subscription client changes from "which published messages can be subscribed" to "which published messages can be processed", so how the subscription client subscribes to the published messages that can be processed becomes the key. The prior art provides two solutions for the subscription client to subscribe to the published messages that can be processed:
[0006] In the first prior art, a subscription client can subscribe to the published messages of each publishing client one by one according to the ability to process published messages. That is, if a subscription client can process several published messages, it will send several subscription topics to the server, and each subscription topic does not contain a wildcard.
[0007] In the second prior art, the subscribing client divides different publishing clients into different regions, so that the publishing client carries the region identifier in the publishing topic. At the same time, the subscribing client determines which regions' publishing messages can be processed according to the subscribing client's ability to process the publishing messages, and adds these region identifiers in the subscription topic.
[0008] There are at least the following problems in the prior art:
[0009] In the prior art, since the subscribing client needs to send subscription topics to the server one by one, when the subscribing client is expanded or migrated, the subscription relationship of the subscribing client needs to be changed, that is, the subscribing client first cancels the subscription and then re-subscribes, which makes it difficult to maintain the subscription relationship on the subscribing client.
[0010] In the second prior art, since the regions are divided by the subscribing clients, when the subscribing clients are expanded or migrated, the subscribing clients need to re-divide the regions and publish subscription messages, which makes it difficult to maintain the subscription relationship on the subscribing clients. Summary of the invention
[0011] The present application provides a subscription publishing method and a server, which solves the problem that it is difficult to maintain the subscription relationship on the subscription client when the subscription client subscribes to the published message that can be processed.
[0012] In order to achieve the above-mentioned purpose, the present application adopts the technical solution provided in the claims.
[0013] In the first aspect of the present application, a subscription publishing method is provided, including: a server can receive a publishing message including a topic name sent by a publishing client, and obtain the identifier of the publishing client according to the received publishing message, and the server can search the subscription tree according to the topic name in the publishing message to obtain the identifier of the subscribing client, and obtain a first tag corresponding to the identifier of the subscribing client according to the identifier of the subscribing client and the first mapping table, and obtain a second tag corresponding to the identifier of the publishing client according to the identifier of the publishing client and the first mapping table, and the server matches the obtained first tag with the second tag, and sends a publishing message to the subscribing client when it is determined that the first tag and the second tag match successfully. Wherein, the subscription tree is a topological structure composed of at least one topic filter, and the identifier of the subscribing client is an identifier corresponding to a topic filter that successfully matches the topic name. Each table entry in the first mapping table includes the identifier of the client and the corresponding tag. The tag is used to indicate at least one attribute information of the client corresponding to the tag.
[0014] The subscription and publishing method provided by the present application is that after receiving the publishing message including the topic name sent by the publishing client and obtaining the identifier of the publishing client according to the publishing message, the server can search the subscription tree according to the topic name, obtain the identifier of the subscribing client corresponding to a topic filter that successfully matches the topic name, and obtain the first tag according to the identifier of the subscribing client and the first mapping table, and obtain the second tag according to the identifier of the publishing client and the first mapping table, and then match the first tag with the second tag, and the server sends the publishing message to the subscribing client when it is determined that the first tag and the second tag match successfully. In the present application, the first mapping table that records the correspondence between the client identifier and the tag is pre-stored in the server, and the server can match the attribute information of the publishing client and the subscribing client when the topic name matches the topic filter successfully, and send the publishing message to the subscribing client when the attribute information of the publishing client and the subscribing client matches successfully. In this way, when the subscribing client migrates and expands, the subscribing client does not need to republish the subscription message, and only needs to change the attribute information of the client, thereby solving the maintenance difficulty caused by the subscribing client maintaining the subscription relationship by itself. Moreover, the attribute information of the client in the present application includes a variety of information about the region. Compared with the prior art that can only match the region, the subscribing client can obtain published messages in more dimensions, that is, realize subscription in more dimensions, and have better scalability.
[0015] In combination with the first aspect, in a possible implementation method, the server obtains a first tag corresponding to the identifier of the subscribing client based on the identifier of the subscribing client and the first mapping table. Specifically, it may include: when the server determines that the subscribing client supports tag matching, the server obtains the first tag based on the identifier of the subscribing client and the first mapping table.
[0016] In combination with the first aspect and the above possible implementation, in another possible implementation, the present application may further include: when the server determines that the subscribing client does not support tag matching, it may send a publishing message to the subscribing client. In this way, since the client's tag is maintained in the server, compared with the second prior art in which the region identifier is carried in the topic, the original subscription publishing mechanism in the prior art that only supports topic matching is retained.
[0017] In combination with the first aspect and the above-mentioned possible implementation methods, in another possible implementation method, before the server searches the subscription tree according to the topic name and obtains the identifier of the subscribing client, it may also include: the server receives a subscription message sent by the subscribing client including at least one topic filter, and obtains the identifier of the subscribing client based on the received subscription message.
[0018] In combination with the first aspect and the above possible implementations, in another possible implementation, each topic filter is divided into multiple layers, each layer is a topic level, and each topic level is stored in a subtree of the subscription tree. The present application may also include: when the server determines that the first topic filter in at least one topic filter supports label matching, the server may associate the first topic filter with the subscription tree, and save the subscription client information in the subtree of the last topic level of the first topic filter stored in the subscription tree. The subscription client information may include: the subscription client identifier and indication information for indicating that the subscription client supports label matching. Among them, the first topic filter is any one of the at least one topic filter.
[0019] In combination with the first aspect and the above possible implementation, in another possible implementation, the subscription message may further include: a first flag bit. The first flag bit includes a first value or a second value, the first value is used to indicate that each topic filter in at least one topic filter supports label matching, and the second value is used to indicate that at least one topic filter includes at least one topic filter that does not support label matching.
[0020] In combination with the first aspect and the above-mentioned possible implementation methods, in another possible implementation method, determining that a first topic filter in at least one topic filter supports tag matching may specifically include: the server may determine that the first topic filter supports tag matching when determining that the first flag bit includes a first value.
[0021] In combination with the first aspect and the above-mentioned possible implementation methods, in another possible implementation method, the subscription message may also include: a second flag bit corresponding to each topic filter in at least one topic filter, each second flag bit may include a third value or a fourth value, the third value is used to indicate that the topic filter corresponding to the second flag bit supports tag matching, and the fourth value is used to indicate that the topic filter corresponding to the second flag bit does not support tag matching.
[0022] In combination with the first aspect and the above-mentioned possible implementation methods, in another possible implementation method, determining that a first topic filter in at least one topic filter supports tag matching may specifically include: the server may determine that the first topic filter supports tag matching when determining that the first flag bit includes a second value and determining that the second flag bit corresponding to the first topic filter includes a third value.
[0023] In combination with the first aspect and the above-mentioned possible implementation methods, in another possible implementation method, the present application may also include: the server may obtain identification information corresponding to the first topic filter based on the identifier of the subscribing client, the first topic filter and the second mapping table, each identification information includes a fifth value or a sixth value, the fifth value is used to indicate that the topic filter corresponding to the identification information supports tag matching, and the sixth value is used to indicate that the topic filter corresponding to the identification information does not support tag matching. At this time, correspondingly, determining that the first topic filter in at least one topic filter supports tag matching may specifically include: the server may determine that the first topic filter supports tag matching when determining that the identification information corresponding to the first topic filter includes the fifth value. Wherein, each table entry in the second mapping table includes the identifier of the client, at least one topic filter corresponding to the identifier of the client, and identification information corresponding to each topic filter in at least one topic filter.
[0024] In combination with the first aspect and the above-mentioned possible implementation methods, in another possible implementation method, determining that the subscription client supports tag matching can specifically include: the server can determine that the subscription client supports tag matching when it is determined that the subtree storing the identifier of the subscription client also stores indication information for indicating that the subscription client supports tag matching.
[0025] In combination with the first aspect and the above-mentioned possible implementations, in another possible implementation, the attribute information includes an attribute name and an attribute value, and the server matches the first tag with the second tag, which may specifically include: the server may compare the attribute value of each attribute information included in the first tag with the attribute value of the corresponding attribute information included in the second tag, and determine whether the attribute value of each attribute information included in the first tag is in accordance with the preset logical relationship with the attribute value of the corresponding attribute information included in the second tag. At this time, correspondingly, determining that the first tag and the second tag are matched successfully may specifically include: the server may determine that the first tag and the second tag are matched successfully when it is determined that the attribute value of each attribute information included in the first tag is in accordance with the preset logical relationship with the attribute value of the corresponding attribute information included in the second tag.
[0026] In combination with the first aspect and the above possible implementation manner, in another possible implementation manner, when the server is running, it can dynamically update the tag corresponding to the identifier of the client through the communication interface for managing the tag.
[0027] In combination with the first aspect and the above-mentioned possible implementation methods, in another possible implementation method, when the support tag matching situation of the topic filter changes, the identification information corresponding to the topic filter in the session management module is dynamically adjusted through the communication interface, and the identification of the corresponding subscription client on the subscription tree is changed accordingly. In this way, by managing the support tag matching situation of the topic filter in the server, the separation of the topic filter and the support tag matching situation in the subscription message is achieved, so that when the topic filter remains unchanged and the support tag matching of the topic filter is changed, the identification information corresponding to the topic filter in the server can be adjusted without the need for the subscription client to first unsubscribe and then resubscribe to the topic filter.
[0028] In combination with the first aspect and the above possible implementation, in another possible implementation, the present application may also include: the server may receive a second subscription message including at least one topic filter sent by the second subscription client, and obtain the identifier of the second subscription client according to the received second subscription message, and obtain the pre-stored persistent message including the topic name. In this way, the server can search the subscription tree according to the topic name included in the persistent message, obtain the identifier of the second subscription client corresponding to the topic filter that successfully matches the topic name of the persistent message, and obtain the identifier of the second publishing client according to the persistent message. And the server can obtain the third tag corresponding to the identifier of the second publishing client according to the identifier of the second publishing client and the first mapping table, and obtain the fourth tag corresponding to the identifier of the second subscription client according to the identifier of the second subscription client and the first mapping table, and the server can match the third tag with the fourth tag, and send the persistent message to the second subscription client when it is determined that the third tag and the fourth tag match successfully. Wherein, the persistent message is a persistent publishing message.
[0029] According to a second aspect of the present application, a server is provided, which may include a module capable of implementing the method in the first aspect and its various embodiments.
[0030] In a third aspect of the present application, a server is provided, the server comprising: a processor, a memory, a communication interface and a communication bus. The memory is used to store computer executable instructions, the processor, the communication interface and the memory are connected via the communication bus, and when the server is running, the processor executes the computer executable instructions stored in the memory, so that the server executes the subscription and publishing method as described in the first aspect or any one of the possible implementations of the first aspect.
[0031] According to a fourth aspect of the present application, a computer storage medium is provided for storing computer software instructions used by the above-mentioned server, wherein the computer software instructions include a program designed for executing the above-mentioned subscription and publishing method. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A simplified schematic diagram of a system architecture to which the embodiments of the present application can be applied is provided for the embodiments of the present application;
[0033] Figure 2 A flowchart of a subscription publishing method provided in an embodiment of the present application;
[0034] Figure 3 A flowchart of another subscription publishing method provided in an embodiment of the present application;
[0035] Figure 4 A schematic diagram of a fixed header format provided in an embodiment of the present application;
[0036] Figure 5 A schematic diagram of a payload format provided in an embodiment of the present application;
[0037] Figure 6 A topological structure diagram of a subscription tree provided in an embodiment of the present application;
[0038] Figure 7 A flowchart of performing topic matching layer by layer provided in an embodiment of the present application;
[0039] Figure 8 A schematic diagram of the composition of a server provided in an embodiment of the present application;
[0040] Fig. 9 A schematic diagram of another server provided in an embodiment of the present application;
[0041] Fig.10 A schematic diagram of the composition of another server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] In order to solve the problem that the subscription relationship on the subscription client is difficult to maintain when the subscription client subscribes to the published message that can be processed, the embodiment of the present application provides a subscription publishing method, the basic principle of which is: the server receives the publishing message including the topic name sent by the publishing client, and obtains the identifier of the publishing client according to the received publishing message, and the server searches the subscription tree according to the topic name to obtain the identifier of the subscription client, and obtains the first label corresponding to the identifier of the subscription client according to the identifier of the subscription client and the first mapping table, and obtains the second label corresponding to the identifier of the publishing client according to the identifier of the publishing client and the first mapping table, and the server can match the first label with the second label, and send the publishing message to the subscription client when it is determined that the first label and the second label match successfully. Wherein, the subscription tree is a topological structure composed of at least one topic filter, the identifier of the subscription client is the identifier corresponding to a topic filter that successfully matches the topic name, and each table entry in the first mapping table contains the identifier of the client and the corresponding label, and the label is used to indicate at least one attribute information of the client corresponding to the label.
[0043] In the present application, a first mapping table recording the correspondence between the client identifier and the tag is pre-stored in the server. When the topic name matches the topic filter successfully, the server can match the attribute information of the publishing client and the subscribing client, and when the attribute information of the publishing client and the subscribing client matches successfully, the server sends a publishing message to the subscribing client. In this way, when the subscribing client migrates or expands, the subscribing client does not need to republish the subscription message, but only needs to change the attribute information of the client, thereby solving the maintenance difficulty caused by the subscribing client maintaining the subscription relationship by itself. Moreover, the attribute information of the client in the present application includes a variety of information including regions. Compared with the prior art that can only match regions, the subscribing client can obtain publishing messages of more dimensions, that is, it can realize subscriptions of more dimensions, and has better scalability.
[0044] To facilitate understanding by those skilled in the art, the present invention describes the basic terms involved in the embodiments of the present invention.
[0045] 1. Topic: A topic is a bridge between a subscribing client and a publishing client. A topic can include a topic name and a topic filter. The topic included in a published message is called a topic name. A topic name cannot contain wildcards and is used to publish a specific topic. A topic included in a subscription message is called a topic filter. A topic filter can contain wildcards and is used to subscribe to multiple topics at the same time. In the MQTT protocol, a topic is a structured, multi-layered structure. Topics are layered using separators ( / ), and each layer is called a topic level. Separators can be located anywhere in a topic, and adjacent separators are used to represent a topic level of an empty string, that is, the content of the topic level is empty. For example, assume that the topic is: myhome / groundfloor / livingroom / temperature, where myhome, groundfloor, livingroom, and temperature are all topic levels.
[0046] Furthermore, the wildcards included in the topic filter may include multi-level wildcards and single-level wildcards.
[0047] (1) Multi-layer wildcard: Indicated by #, it is a wildcard used to match any topic level in the topic name. Multi-layer wildcards can represent multiple topic levels. Multi-layer wildcards are the last character of the topic filter. For example, multi-layer wildcards can be located at a certain topic level. For example, the topic filter is: #. Multi-layer wildcards can also follow the separator. For example, the topic filter is: myhome / groundfloor / #. Then, if there is a topic name as shown in Table 1:
[0048] Table 1
[0049] Theme Name 1 myhome / groundfloor / livingroom / temperature 2 myhome / groundfloor / kitchen / temperature 3 myhome / groundfloor / kitchen / brightness 4 myhome / firstfloor / kitchen / temperature 5 myhome / groundfloor / kitchen / fridge / temperature
[0050] The topic names that successfully match the topic filter are: the topic names with serial numbers 1, 2, 3, and 5, and the topic name that fails to match the topic filter is: the topic name with serial number 4.
[0051] (2) Single-level wildcard: Indicated by +, it is a wildcard used to match a single topic level in a topic name. A single-level wildcard is a wildcard that occupies the entire topic level and can be located at any topic level in the topic filter, including the first subject level and the last subject level. Moreover, a topic filter can contain multiple single-level wildcards, or it can contain both multi-level wildcards and single-level wildcards.
[0052] For example, assuming that the topic filter containing a single layer of wildcards is: myhome / groundfloor / + / temperature, then among the topic names shown in Table 1, the topic names that successfully match the topic filter are: the topic names with serial numbers 1 and 2, and the topic names that fail to match the topic filter are: the topic names with serial numbers 3, 4, and 5.
[0053] 2. Quality of service (QoS): refers to the ability of a network to use various basic technologies to provide better service capabilities for network communications. In the MQTT protocol, three levels of QoS can be provided, namely QoS = 0, 1, and 2.
[0054] 3. Subscription tree: a topological structure composed of at least one topic filter. The subscription tree may include a root node and at least one layer of subtrees, and each layer of subtrees includes at least one subtree. The root node is a logical node, representing the root of all topic filters, and each subtree stores a topic level of the topic filter. The first-level subtree connected to the root node is a subtree storing the first topic level, and the second-level subtree connected to the first-level subtree is a subtree storing the second topic level under the first topic level, and so on, until the last topic level. Starting from a first-level subtree, according to the connection to the last-level subtree, the topic levels stored in each layer of subtrees can form a topic filter. In addition, in each subtree of the last topic level storing a topic filter, the identifier of the subscription client corresponding to the topic filter and the indication information indicating whether the subscription client supports label matching are stored.
[0055] The implementation of the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0056] Figure 1A simplified schematic diagram of a system architecture to which the embodiments of the present application can be applied is provided for the embodiments of the present application, such as Figure 1 As shown, the system architecture may include: at least one publishing terminal 11, a subscription terminal 12 and a server 13. Figure 1 Three publishing terminals are shown as an example.
[0057] Among them, the publishing client running on each publishing terminal in at least one publishing terminal 11 communicates with the server 13 through the MQTT protocol, the server 13 communicates with the subscription client running on the subscription terminal 12 through the MQTT protocol, and at least one publishing client establishes an indirect connection with the subscription client through a topic.
[0058] A publishing client is running on the publishing terminal 11. The publishing client is a client that supports the MQTT protocol and can be used as a message generator. The publishing terminal 11 can be a temperature sensor, a humidity sensor, an electric meter, a water meter, etc. Figure 1 In the figure, the publishing terminal 11 is taken as an example of an electric meter.
[0059] In one possible implementation, the publishing terminal 11 can directly access the server 13. In another possible implementation, the publishing terminal 11 can access the server 13 through an Internet of Things gateway. In this case, the Internet of Things gateway can be used as a bridge to convert the protocol or data format of the messages exchanged between the publishing client running on the publishing terminal 11 and the server 13, or the Internet of Things gateway can also be used as an agent of the publishing terminal 11, so that the publishing client running on the publishing terminal 11 can send publishing messages to the server 13 through the Internet of Things gateway.
[0060] A subscription client is running on the subscription terminal 12, which is a client supporting the MQTT protocol and can be used as a consumer or manager of published messages. The subscription terminal 12 can be a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a laptop, etc. In the embodiment of the present application, the subscription terminal 12 is taken as an example of a mobile phone.
[0061] The server 13 runs the MQTT protocol server, which is the execution subject of the subscription and publishing mechanism. In a specific implementation, multiple servers 13 can form a cluster, and multiple servers 13 can subscribe and publish, that is, a server can act as a subscription client to send a subscription message to another server, and after receiving the publishing message, send a publishing message to the subscription client connected to the server.
[0062] It should be noted that in the embodiment of the present application, the publishing terminal can also serve as a subscription terminal. In this case, the subscription terminal serves as the publishing terminal accordingly. The embodiment of the present application does not limit the specific forms of the publishing terminal and the subscription terminal.
[0063] In addition, in the embodiment of the present application, the server may send a publishing message to the subscribing client running on the subscribing terminal according to the identifier of the subscribing client.
[0064] Figure 2 A flowchart of a subscription publishing method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method may include:
[0065] 201. The publishing client sends a publishing message to the server.
[0066] Among them, when the user name and password of the publishing client running on the publishing terminal are authenticated and the server saves the session of the publishing client and the identifier of the publishing client corresponding to the session, the publishing client can send a publishing message to the server, which can include a topic name.
[0067] Exemplarily, assuming that the publishing terminal is a temperature sensor, the client running on the temperature sensor can include a topic name, such as thermometer / temperature, and a temperature value collected by the temperature sensor in a publishing message, and send the publishing message to the server.
[0068] 202. The server receives a publishing message sent by the publishing client, and obtains an identifier of the publishing client according to the publishing message.
[0069] After the publishing client sends a publishing message to the server, the server can receive the publishing message and, after determining that it has publishing authority, obtain the identifier of the publishing client corresponding to the session according to the session in which the publishing message is received.
[0070] 203. The server searches the subscription tree according to the topic name and obtains the identifier of the subscribing client.
[0071] The identifier of the subscribing client is the identifier corresponding to a topic filter that successfully matches the topic name. After the server obtains the identifier of the publishing client, it can search the subscription tree according to the topic name included in the publishing message, obtain a topic filter that successfully matches the topic name, and obtain the identifier of the subscribing client in the subtree of the last topic level storing the topic filter. The identifier of the subscribing client can be multiple.
[0072] In order to solve the problem that the subscription relationship on the subscribing client is difficult to maintain when implementing on-demand diversion of publishing messages, the subject can be separated from the client's attribute information, and the client's attribute information, that is, the tag, can be pre-stored in the server. After the server obtains the identifier of the subscribing client, the server can send the publishing message to the subscribing client if it is determined that the tag of the publishing client matches the tag of the subscribing client. Specifically, for each of the multiple subscribing client identifiers, the following steps 204-206 can be performed:
[0073] 204. The server obtains a first tag corresponding to the identifier of the subscribing client according to the identifier of the subscribing client and the first mapping table, and obtains a second tag corresponding to the identifier of the publishing client according to the identifier of the publishing client and the first mapping table.
[0074] The tag is used to indicate at least one attribute information of the client corresponding to the tag.
[0075] The server can obtain a first tag corresponding to the identifier of the subscribing client according to the identifier of the subscribing client and the first mapping table, and obtain a second tag corresponding to the identifier of the publishing client according to the identifier of the publishing client and the first mapping table. Each entry in the first mapping table includes the identifier of the client and the corresponding tag, and the identifier of the client can be the identifier of the subscribing client or the identifier of the publishing client.
[0076] It should be noted that in the embodiment of the present application, the tag can be obtained by the server of the server running the MQTT protocol when the client registers with the server, or it can be added by the administrator in the tag management (tagsmanager) module of the server. The embodiment of the present application does not limit the specific way in which the tags are stored in the server. And in the embodiment of the present application, when the server is running, it can dynamically update the tag corresponding to the client's identifier through the communication interface of the management tag, so that there is no need to change the subscription relationship, and the on-demand diversion of the published message can be realized. Compared with the client in the prior art that needs to change the subscription relationship again when expanding or migrating, it solves the problem that the subscription relationship on the subscribing client is difficult to maintain.
[0077] 205. The server matches the first tag with the second tag.
[0078] Among them, after the server obtains the first tag and the second tag, the first tag can be matched with the second tag, that is, at least one attribute information of the publishing client and at least one attribute information of the subscribing client can be matched. In an embodiment of the present application, the number of types of attribute information of the publishing client and the number of types of attribute information of the subscribing client are the same, and the server can match the attribute information of the same type. Only when all types of attribute information are matched successfully can it be determined that the first tag and the second tag are matched successfully. If the first tag and the second tag match successfully, the following step 206 can be executed. If the first tag and the second tag fail to match, the server can determine whether there is a next subscribing client. If there is a next subscribing client, steps 204-205 can be repeated.
[0079] 206. The server sends a publish message to the subscribing client.
[0080] It should be noted that, for the identifier corresponding to a topic filter that successfully matches the topic name, after the server executes steps 204 to 206, the server can continue to obtain other topic filters that can successfully match the topic name. Every time a successfully matched topic filter is obtained, the identifiers of multiple subscribing clients can be obtained in the subtree of the last topic level where the topic filter is stored. At this time, steps 204 to 206 can be repeated for the identifiers of the multiple subscribing clients until the server obtains the last topic filter that matches the topic name and sends a publish message to the last subscribing client.
[0081] The subscription and publishing method provided in the embodiment of the present application is that after receiving the publishing message including the topic name sent by the publishing client and obtaining the identifier of the publishing client according to the publishing message, the server searches the subscription tree according to the topic name in the publishing message to obtain the identifier of the subscribing client corresponding to a topic filter that successfully matches the topic name, and after obtaining the first tag according to the identifier of the subscribing client and the first mapping table, and obtaining the second tag according to the identifier of the publishing client and the first mapping table, the server can match the first tag and the second tag, and send the publishing message to the subscribing client when it is determined that the first tag and the second tag match successfully. In the present application, the first mapping table that records the correspondence between the client identifier and the tag is pre-stored in the server, and the server can match the attribute information of the publishing client and the subscribing client when the topic name matches the topic filter successfully, and send the publishing message to the subscribing client when the attribute information of the publishing client and the subscribing client matches successfully. In this way, when the subscribing client migrates and expands, the subscribing client does not need to republish the subscription message, and only needs to change the attribute information of the client, thereby solving the maintenance difficulty caused by the subscribing client maintaining the subscription relationship by itself. Moreover, the attribute information of the client in the present application includes a variety of information about the region. Compared with the prior art that can only match the region, the subscribing client can obtain published messages in more dimensions, that is, realize subscription in more dimensions, and have better scalability.
[0082] Figure 3 A flowchart of another subscription publishing method provided in an embodiment of the present application, such as Figure 3 As shown, the method may include:
[0083] 301. The subscription client sends a subscription message to the server.
[0084] In which, when the access control list (ACL) module of the server authenticates the user name and password of the subscription client running on the subscription terminal and saves the session of the subscription client and the identifier of the subscription client corresponding to the session in the session management module, the subscription client can send a subscription message to the server, and the subscription message includes at least one topic filter.
[0085] For example, assuming that the subscription terminal is a mobile phone and needs to subscribe to the temperature of the temperature sensor and the electricity consumption of the electric meter, the client running on the mobile phone can include two topic filters, such as thermometer / + and ammeters / #, in the subscription message and send the subscription message to the server.
[0086] Of course, in a specific implementation, multiple subscription clients may send subscription messages to the server, and each subscription message includes at least one topic filter. For example, assuming that 8 subscription clients send subscription messages to the server, as shown in the second column of Table 2, the topic filters included in the subscription message.
[0087] Table 2
[0088]
[0089]
[0090] It should be noted that in order to achieve on-demand diversion of published messages while retaining the existing mechanism that only supports topic matching, it is possible to indicate whether the topic filter in the subscription message supports tag matching. In the embodiment of the present application, the following two methods can be used to indicate whether the topic filter supports tag matching.
[0091] Method 1: Use the flag in the subscription message to indicate whether the topic filter supports tag matching.
[0092] Exemplarily, the subscription client can set the reserved field (reserved) of the subscription message to a flag to indicate whether the topic filter included in the subscription message supports tag matching. In the embodiment of the present application, the subscription message includes a header and a payload, wherein the header includes a fixed header and a variable header, and the variable header is related to the message type (the message type includes a subscription message, a publishing message, etc.), and for all subscription messages, the format of the variable header is fixed. Figure 4 This is a diagram of the format of a fixed header, such as Figure 4 As shown, the fixed header includes two bytes, wherein the 4th to 7th bits of byte 1 are the MQTT control packet type, byte 2 is the remaining length, and the 0th to 3rd bits of byte 1 are reserved fields. The subscribing client can set any one of the reserved fields to a first flag bit, and the first flag bit can include a first value or a second value. The first value is used to indicate that each topic filter in at least one topic filter supports tag matching, and the second value is used to indicate that at least one topic filter includes at least one topic filter that does not support tag matching.
[0093] Figure 5 This is a schematic diagram of the payload format, such as Figure 5 As shown, the payload includes at least one topic filter. Figure 5A topic filter is shown as an example, where byte 1 to byte N represent a topic filter, wherein byte 1 represents the most significant bit (MSB), byte 2 represents the least significant bit (LSB), byte 3 to byte N represent the hierarchical structure of the topic filter, bits 0 and 1 in byte N+1 represent the QoS identifier corresponding to the topic filter, bits 2 to 7 of byte N+1 are reserved fields, and the subscription client can set any one of the reserved fields to the second flag bit, the second flag bit may include a third value or a fourth value, the third value is used to indicate that the topic filter corresponding to the second flag bit supports label matching, and the fourth value is used to indicate that the topic filter corresponding to the second flag bit does not support label matching.
[0094] It should be noted that, in the embodiment of the present application, the value of value can be: 0 or 1. In one possible implementation, the value of the first value is 1, and the value of the second value is 0. In another possible implementation, the value of the first value is 0, and the value of the second value is 1. Also, in one possible implementation, the value of the third value is 1, and the value of the fourth value is 0. In another possible implementation, the value of the third value is 0, and the value of the fourth value is 1. It should be noted that the specific value of value can be set according to the needs of the actual application scenario, and the embodiment of the present application does not make specific restrictions here. In the embodiment of the present application, the value of the first value is 1, the value of the second value is 0, the value of the third value is 1, and the value of the fourth value is 0 as an example for explanation.
[0095] Mode 2: storing the topic filter and identification information corresponding to the topic filter in the server through a communication interface for managing the topic filter.
[0096] Exemplarily, in an embodiment of the present application, the topic filter and the identification information corresponding to the topic filter can be stored in the server in advance through the communication interface for managing the topic filter. The identification information may include the fifth value or the sixth value. The fifth value is used to indicate that the topic filter corresponding to the identification information supports tag matching, and the sixth value is used to indicate that the topic filter corresponding to the identification information does not support tag matching.
[0097] 302. The server receives a subscription message sent by the subscription client, and obtains an identifier of the subscription client according to the subscription message.
[0098] Among them, after the subscription client sends a subscription message to the server, the ACL module of the server can obtain the identifier of the subscription client corresponding to the session according to the session that receives the subscription message after determining that the subscription client has the subscription authority, and instruct the subscription service module to process the subscription message.
[0099] Exemplarily, it is assumed that the identifier of the subscribing client obtained by the server according to the session is C1, as shown in the first column of Table 2.
[0100] 303. When determining that a first topic filter in at least one topic filter supports tag matching, the server associates the first topic filter with the subscription tree, and saves information of the subscription client in a subtree of the last topic level storing the first topic filter in the subscription tree.
[0101] Wherein, the first topic filter is any one of at least one topic filter, and the information of the subscription client includes the identifier of the subscription client and the indication information for indicating that the subscription client supports tag matching. After the subscription service module of the server receives the indication from the ACL module, the subscription service module can determine whether each topic filter in at least one topic filter included in the subscription message supports tag matching. For any topic filter, such as the first topic filter, the server can send an indication to the first subscription processing module included in the subscription service module when determining that the first topic filter supports tag matching. The first subscription processing module can associate the first topic filter with the subscription tree after receiving the indication, and save the identifier of the subscription client and the indication information for indicating that the subscription client supports tag matching in the subtree of the last topic level where the first topic filter is stored. The server can send an indication to the second subscription processing module when determining that the first topic filter does not support tag matching. After receiving the indication, the second subscription processing module can associate the first topic filter with the subscription tree, and save the identifier of the subscription client and the indication information for indicating that the subscription client does not support tag matching in the subtree of the last topic level where the first topic filter is stored.
[0102] It should be noted that before the server receives any subscription message, a subscription tree containing only the root node is pre-stored, so that each time a subscription message is received, the topic filter contained in the subscription message can be associated with the subscription tree.
[0103] Furthermore, in the embodiment of the present application, the following three methods may be used to determine whether the first topic filter supports tag matching.
[0104] In method 1, when the server determines that the first flag bit includes the first value, it determines that the first topic filter supports tag matching.
[0105] Exemplarily, according to the method of indicating whether the topic filter supports tag matching in method 1 in step 402, the subscription service module can determine whether the first flag bit includes the first value or the second value. If the first flag bit includes the first value, it indicates that at least one topic filter included in the subscription message supports tag matching. At this time, the first subscription processing module can associate at least one topic filter to the subscription tree one by one, and save the identifier of the subscription client and the indication information for indicating that the subscription client supports tag matching in the subtree storing the last topic level of each topic filter. If the first flag bit includes the second value, it indicates that at least one topic filter includes at least one topic filter that does not support tag matching. At this time, the following method 2 can be used to determine whether the first topic filter supports tag matching.
[0106] Mode 2: When the server determines that the first flag bit includes the second value and determines that the second flag bit corresponding to the first topic filter includes the third value, the server determines that the first topic filter supports tag matching.
[0107] Exemplarily, if the first flag bit includes the second value, the subscription service module can determine whether the second flag bit corresponding to the first topic filter includes the third value. If the second flag bit includes the third value, it is determined that the first topic filter supports tag matching, and if the second flag bit includes the fourth value, it is determined that the first topic filter does not support tag matching.
[0108] It should be noted that the first flag bit and the second flag bit may be preset on which bits of the reserved field respectively, and the specific positions of the first flag bit and the second flag bit may be configured in the server.
[0109] In addition, the process of associating the first topic filter to the subscription tree is as follows: according to the hierarchical situation of the first topic filter, determine whether the first topic level of the subscription tree contains the first topic level of the first topic filter; if not, connect the first topic level to the root node, and then sequentially connect the second topic level, ..., and the last topic level of the first topic filter; if included, determine whether the second topic level connected under the first topic level of the subscription tree contains the second topic level of the first topic filter; if not, connect the second topic level to the first topic level of the subscription tree; and then sequentially connect the third topic level, ..., and the last topic level of the first topic filter; if included, continue to determine whether the third topic level connected under the second topic level of the subscription tree contains the third topic level of the first topic filter, until the last topic filter of the first topic filter is connected to the subscription tree.
[0110] Exemplarily, as shown in Table 2 in step 301, assuming that the subscription message received by the server for the first time is sent by a subscription client identified as C1, the topic filters included in the subscription message are thermometer / + and ammeters / #, and the first flag bit of the subscription message is 1, then the server can first connect the first topic level thermometer of the topic filter thermometer / + to the root node, and connect the second topic level + to the first topic level thermometer, and then connect the first topic level ammeters of the topic filter ammeters / # to the root node, and connect the second topic level # to the first topic level ammeters, and save C1 and indication information indicating that C1 supports tag matching in the second topic level + and # respectively. For ease of distinction, C1 supports tag matching as C1' and C1 does not support tag matching as C1. The other identifiers are similar. Assuming that the first flag bit of the subscription message of the subscription client identified as C2 received by the server is 0 and the second flag bit is 1, the server can associate the second topic level 5678 of the topic filter ammeters / 5678 to ammeters in the subscription tree, and save C2' in the second topic level 567890. Assuming that the first flag bit of the subscription message of the subscription client identified as C3 received by the server is 0 and the second flag bit is 0, the server can associate the second topic level 1234 of the topic filter thermometer / 1234 to the first topic level thermometer in the subscription tree, and save C3 in the second topic level 1234. Assume that the first flag bit of the subscription message of the subscription client identified as C6 received by the server is 0, the second flag bit corresponding to the topic filter thermometer / 1234 is 1, and the second flag bit corresponding to the topic filter ammeters / 5678 is 0, then the server can save C6' in the second topic level 123456 under the first topic level thermometer in the subscription tree, and save C6 in the second topic level 567890 under the first topic level ammeters in the subscription tree. Assume that the first flag bit of the subscription message of the subscription client identified as C8 received by the server is 0, the second flag bit corresponding to the topic filter thermometer / + is 0, and the second flag bit corresponding to the topic filter ammeters / + is 0, then the server can save C8 in the second topic level + under the first topic level thermometer in the subscription tree, connect the second topic level + with the first topic level ammeters in the subscription tree, and save C8 in the second topic level + under the first topic level ammeters in the subscription tree.Assume that the first flag bit of the subscription messages received by the server from the subscription client identified as C4, the subscription client identified as C5, and the subscription client identified as C7 are all 1, then the server can save C4' and C7' in the second topic level + under the first topic level thermometer in the subscription tree, and save C5' in the second topic level # under the first topic level ammeters in the subscription tree. The final subscription tree is as follows. Figure 6 shown, and in Figure 6 In this table, thermometer is used as the temperature sensor and ammeters is used as the electrical meter.
[0111] Mode 3: When the server determines that the identification information corresponding to the first topic filter includes the fifth value, it determines that the first topic filter supports tag matching.
[0112] Exemplarily, according to the method of indicating whether the topic filter supports tag matching in method 2 in step 402, the subscription service module can obtain the identification information corresponding to the first topic filter according to the identification of the subscription client, the first topic filter and the second mapping table stored in the session management module. Each table entry in the second mapping table includes the identification of the client, at least one topic filter corresponding to the identification of the client, and the identification information corresponding to each topic filter in the at least one topic filter.
[0113] For example, as shown in Table 3, which is a second mapping table stored in the session management module, the fifth value included in the identification information is 1, and the sixth value is 0 as an example.
[0114] Table 3
[0115]
[0116] Assuming that the identifier of the subscription client is C1 and the first topic filter is ammeters / #, the identification information corresponding to the first topic filter ammeters / # obtained by the subscription server module is 1. At this time, the subscription service module determines that the first topic filter supports tag matching.
[0117] It should be noted that when the support for tag matching of the topic filter changes, the identification information corresponding to the topic filter in the session management module can be dynamically adjusted through the communication interface, and the corresponding indication information on the subscription tree can be changed accordingly. Specifically, in the case where the first topic filter changes from supporting tag matching to not supporting tag matching, the identification information corresponding to the first topic filter can be adjusted from the fifth value to the sixth value, and the indication information in the subtree of the last topic level storing the first topic filter that indicates that the subscription client supports tag matching is replaced with the indication information for indicating that the subscription client does not support tag matching. In the case where the first topic filter changes from not supporting tag matching to supporting tag matching, the identification information corresponding to the first topic filter can be adjusted from the sixth value to the fifth value, and the indication information in the subtree of the last topic level storing the first topic filter that indicates that the subscription client does not support tag matching is replaced with the indication information for indicating that the subscription client supports tag matching. In this way, by managing the topic filter support tag matching situation in the server, the separation of the topic filter and the support tag matching situation in the subscription message is achieved, so that when the topic filter remains unchanged and the topic filter support tag matching is changed, the identification information corresponding to the topic filter in the server can be adjusted without the subscription client having to unsubscribe and then re-subscribe to the topic filter.
[0118] 304. The publishing client sends a publishing message to the server.
[0119] The published message includes a topic name and a QoS identifier, and may include a persistence identifier, or may not include a persistence identifier, and the persistence identifier is used to instruct the server to store the published message.
[0120] 305. The server receives the publishing message sent by the publishing client, and obtains the identifier of the publishing client according to the publishing message.
[0121] Among them, after receiving the publishing message sent by the publishing client, the ACL module of the server can obtain the identifier of the publishing client corresponding to the session according to the session receiving the publishing message after determining that it has the authority to publish, and send an indication to the publishing service module. After receiving the indication, the publishing service module can return a response message to the publishing client according to the QoS identifier, and save the publishing message in the session of the publishing client for a period of time. If the publishing message includes a persistence identifier, the publishing service module can instruct the persistence module to save the publishing message to a disk, a tape, etc., so that after receiving the subscription message sent by the subscribing client, the server can send the persistent message to the subscribing client after determining that the subscribing client has subscribed to a certain persistent message, without waiting for the server to receive a new publishing message before sending the new publishing message to the subscribing client.
[0122] It should be noted that in the embodiment of the present application, in step 402, after the server receives the subscription message sent by the subscription client and obtains the identifier of the subscription client according to the subscription message, it can first obtain at least one pre-stored persistent message, and use at least one topic filter included in the subscription message as a subscription tree, and then determine which persistent messages are sent to the subscription client by performing topic matching and label matching. Among them, the server searches the subscription tree according to the topic name included in any persistent message, and the specific process of performing label matching is similar to the description of the following steps 306-310, which will not be repeated here. Then, the server associates at least one topic filter included in the subscription message to the pre-stored subscription tree, and executes the following steps 306-310 when receiving a new publish message.
[0123] 306. The server searches the subscription tree according to the topic name and obtains the identifier of the subscribing client.
[0124] Among them, after the server obtains the identifier of the publishing client, the server's topic matching module can traverse the topic levels in the subscription tree layer by layer, compare the topic level of the topic name with the corresponding topic level in the subscription tree to obtain a topic filter that successfully matches the topic name, and obtain the identifier of the subscribing client in the last topic level of the topic filter.
[0125] In the specific implementation, Figure 7 This is a flowchart for layer-by-layer topic matching, such as Figure 7As shown, the topic matching module of the server can traverse the topic levels in the subscription tree layer by layer, and compare the topic level of the topic name with the corresponding topic level in the subscription tree. For the Nth topic level, the server can compare the Nth topic level of the topic name with all the Nth topic levels in the subscription tree, first determine whether the content of the Nth topic level of the topic name is the same as the content of a certain Nth topic level of the subscription tree, or determine whether a certain Nth topic level of the subscription tree is +. If the content of the Nth topic level of the topic name is the same as the content of the Nth topic level under the N-1th topic level in the subscription tree, or if a certain Nth topic level under the N-1th topic level in the subscription tree is +, it indicates that the layer is matched successfully, and the server can determine whether there is an N+1th topic level under the Nth topic level of the subscription tree. If so, the server continues to match the next topic level. If not, it indicates that the topic name successfully matches the topic filter, and the server can obtain the identifier of the subscription client stored in the Nth topic level. Otherwise, the server determines whether the Nth topic level in the subscription tree is #. If the Nth topic level in the subscription tree is #, it indicates that the topic name matches the topic filter successfully, and the server can obtain the identifier of the subscription client saved in the Nth topic level. If the Nth topic level in the subscription tree is not #, it can be determined whether there is a subtree after the Nth topic level. If so, the Nth topic level of the topic name is matched with the Nth level topic level. After obtaining the identifier of the subscription client saved in the Nth topic level, the publishing service module can determine whether there is a subtree after the Nth topic level. If so, the Nth topic level of the topic name is matched with the Nth level topic level. After obtaining the identifier of the subscription client saved in the Nth topic level, the publishing service module can determine whether there is a subtree after the Nth topic level. If so, the Nth topic level of the topic name is matched with the Nth level topic level.
[0126] For example, assuming that the topic name received by the server is thermometer / 1234, then the first topic level thermometer of the topic name successfully matches the first topic level thermometer of the subscription tree. At this time, the server successfully matches the second topic level 1234 of the topic name with the second topic level + under the first topic level thermometer of the subscription tree, and obtains the identifiers of the subscribing clients as C1', C4', C7' and C8'. The server also determines that there is another second topic level 1234 under the first topic level thermometer of the subscription tree, which has the same content as the second topic level 1234 of the topic name, and obtains the identifiers of the subscribing clients as C3, C6'. The server determines that the first topic level of the topic name fails to match the other first topic level ammeters of the subscription tree.
[0127] For another example, suppose the topic name received by the server is Thermometer / 2345. Since the topic is case sensitive, the first topic level Thermometer in the topic name fails to match the first topic level thermometer in the subscription tree. Also, the first topic level Thermometer in the topic name fails to match the first topic level ammeters in the subscription tree.
[0128] For another example, assuming that the topic name received by the server is things / 12 / temp, the first topic level things of the topic name fails to match the first topic level thermometer and ammeters of the subscription tree.
[0129] It should be noted that in order to solve the problem that the subscription relationship on the subscription client is difficult to maintain when realizing on-demand diversion of published messages, after the topic matching module of the server obtains the identifier of the subscription client, the following steps 307-310 can be performed for any one of the identifiers of the multiple subscription clients:
[0130] 307. The server determines that the subtree storing the identifier of the subscribing client also stores indication information for indicating that the subscribing client supports tag matching.
[0131] Among them, the topic matching module can determine whether the subtree storing the identifier of the subscription client also stores indication information for indicating that the subscription client supports tag matching. If it is determined that indication information for indicating that the subscription client supports tag matching is stored, it indicates that the subscription client supports tag matching, and the following step 308 can be performed at this time. If it is determined that indication information for indicating that the subscription client does not support tag matching is stored, it indicates that the subscription client does not support tag matching, and the topic matching module can send a publishing message to the subscription client through the publishing service module. In this way, since the client's tag is maintained in the server, compared with the prior art II in which the region identifier is carried in the topic, the original subscription publishing mechanism that only supports topic matching in the prior art is retained.
[0132] 308. The server obtains a first tag corresponding to the identifier of the subscribing client according to the identifier of the subscribing client and the first mapping table, and obtains a second tag corresponding to the identifier of the publishing client according to the identifier of the publishing client and the first mapping table.
[0133] The tag is used to indicate at least one attribute information of the client corresponding to the tag. After determining that the subtree storing the identifier of the subscribing client also stores indication information indicating that the subscribing client supports tag matching, the topic matching module can instruct the tag management module to obtain the first tag corresponding to the identifier of the subscribing client from the first mapping table, and obtain the second tag corresponding to the identifier of the publishing client.
[0134] It should be noted that, in an embodiment of the present application, each table entry in the first mapping table includes an identifier of the client and a label corresponding to the identifier of the client, and the label is used to indicate at least one attribute information of the client. One attribute information may include an attribute name and an attribute value, wherein the attribute value may be a single value or multiple values, such as an array or a list, or a logical expression supported by the tag engine module, or the content of a lightweight data exchange format (JavaScript object notation) based on the JavaScript language. In addition to the unique identifier and the attribute information contained in the corresponding relationship, the attribute information of the client may also include a display name, etc.
[0135] And because the client includes a publishing client and a subscribing client, the attribute values contained in the tag are also different for different types of clients. Exemplarily, if the attribute value of the publishing client is multiple values, it means broadcasting, which is equivalent to multiple publishing clients publishing two publishing messages respectively, and the tag of each publishing client contains one of the multiple values. For example, assuming that the attribute name of a kind of attribute information of the publishing client is zone, and the attribute values are sz and nj, it is equivalent to two publishing clients publishing two messages, and the two publishing clients have a kind of attribute information, which is zone=sz and zone=nj respectively. Exemplarily, if the attribute value of the subscribing client is multiple values, it means inclusion, if there is a value in the attribute value of the same kind of attribute information of the publishing client that is the same as the attribute value of the subscribing client, then the attribute information of the subscribing client and the attribute information of the publishing client are matched successfully. For example, assuming that the attribute name of a kind of attribute information of the subscribing client is zone, and the attribute values are sz and nj, it is equivalent to the subscribing client subscribing to the messages published by the publishing client with zone=sz and the publishing client with zone=nj at the same time.
[0136] 309. The server determines whether the attribute value of each attribute information included in the first tag respectively conforms to a preset logical relationship with the attribute value of the corresponding attribute information included in the second tag.
[0137] Among them, after the tag management module obtains the first tag and the second tag, it can send the first tag and the second tag to the tag engine (tagsengine) module, and the tag engine module can determine whether the attribute values of each attribute information included in the first tag respectively conform to the preset logical relationship with the attribute values of the corresponding attribute information included in the second tag. Only when the two attribute values conform to the preset logical relationship, it is determined that the attribute information matches successfully, and only when all types of attribute information match successfully, it is determined that the first tag and the second tag match successfully, and the result of successful matching is returned to the publishing service module, so that the publishing service module sends a publishing message to the subscribing client after receiving the result of successful matching.
[0138] It should be noted that, in the embodiment of the present application, the preset logical relationship is closely related to the type of attribute information. For example, the logical relationship may be an inclusion relationship of different attribute values.
[0139] 310. When determining that the first tag and the second tag match successfully, the server sends a publishing message to the subscribing client.
[0140] It should be noted that after the server sends a publishing message to the subscribing client, the server can determine whether there is still an identification of the subscribing client. If there is still an identification of the subscribing client, the server can repeat steps 307-310. If there is no identification of the subscribing client, the server can determine whether there is still a subtree in the topic hierarchy of the same layer. If so, repeat steps 306-310 until the last topic filter that successfully matches the topic name is obtained, thereby obtaining the identification of the subscribing client and sending a publishing message to the subscribing client with the last tag matching successfully.
[0141] Exemplarily, in a multi-tenant scenario, assuming that the first tag and the second tag include two types of attribute information, namely tenant and domain, at this time, the tag engine module can determine that the first tag and the second tag match successfully when it is determined that the attribute value of the tenant of the subscribing client includes the attribute value of the tenant of the publishing client, and the attribute value of the domain of the subscribing client includes the attribute value of the domain of the publishing client. For example, according to the example in step 306, assuming that the identifier of the publishing client obtained by the server is t1, and the identifiers of the subscribing clients obtained are C1', C4', C7' and C8', as shown in Table 4, which are the identifiers of the clients in the first mapping table, and the tags corresponding to the identifiers of the clients, and the tags include tenants and domains.
[0142] Table 4
[0143]
[0144] Then, after obtaining the tag corresponding to C1 and the tag corresponding to t1, the server determines that the attribute value tenant 1 of the tenant of C1 contains the attribute value tenant 1 of the tenant of t1, and the attribute value sz of the domain of C1 contains the attribute value sz of the domain of t1, and can send a publishing message to the subscribing client identified as C1. The server determines that there is also a subscribing client identified as C4, and determines that the attribute value tenant 2 of the tenant of C4 is not equal to the attribute value tenant 1 of the tenant of t1, and will not send a publishing message to the subscribing client identified as C4. The server determines that there is also a subscribing client identified as C7, and determines that the attribute value tenant 1 of the tenant of C7 contains the attribute value tenant 1 of the tenant of t1, and the attribute value sz,nj of the domain of C7 contains the attribute value sz of the domain of t1, and sends a publishing message to the subscribing client identified as C7. Similar to C4, the server will not send a publishing message to the subscribing client identified as C8.
[0145] Exemplarily, in a scenario with priority, the value of the attribute can be a complex logical expression. Assuming that the first tag and the second tag include two kinds of attribute information, namely, domain and priority, at this time, the tag engine module can determine that the first tag and the second tag match successfully when it is determined that the attribute value of the domain of the publishing client satisfies the logical expression of the attribute value of the domain of the subscribing client, and the attribute value of the priority of the publishing client satisfies the logical expression of the attribute value of the priority of the subscribing client, and sends a publishing message to the subscribing client. In this way, by matching the priority, different subscribing clients can process publishing messages of different priorities. For example, assuming that there are subscribing clients A and B, if subscribing client A can use a faster network and more resources, and subscribing client B uses a slower network and uses fewer resources, then the priority attribute value in the tag corresponding to subscribing client A can be set in the tag management module to be greater than 50, and the priority attribute value in the tag corresponding to subscribing client B can be set to be less than 50, so that subscribing client A can process publishing messages with higher priority, and subscribing client B can process publishing messages with lower priority.
[0146] For example, according to the example in step 306, assuming that the identifier of the publishing client obtained by the server is t1, and the identifiers of the subscribing clients obtained are C1', C4', C7' and C8', as shown in Table 5, which are the identifiers of the clients in the first mapping table, and the labels corresponding to the identifiers of the clients, which include domains and priorities.
[0147] Table 5
[0148]
[0149]
[0150] In addition, the embodiment of the present application introduces the operators involved in Table 5: $not: means logical "not", $eq: means equality or inclusion, similar to $in ($eq emphasizes the inclusion of a single value, $in emphasizes that the value is an array), $or: means logical "or", $and: means logical "and"; $gt: means greater than, $ge: means greater than or equal to, $lt: means less than, $le: means less than or equal to.
[0151] Then, after obtaining the tag corresponding to C1 and the tag corresponding to t1, the server can determine that the attribute value sz of the domain of t1 does not satisfy the logical expression {$not: {$eq: sz}} of the attribute value of the domain of C1. The meaning of this logical expression is: including domains other than sz, no publishing message will be sent to the subscribing client identified as C1.
[0152] The subscription and publishing method provided in the embodiment of the present application is that after receiving the publishing message including the topic name sent by the publishing client and obtaining the identifier of the publishing client according to the publishing message, the server searches the subscription tree according to the topic name in the publishing message to obtain the identifier of the subscribing client corresponding to a topic filter that successfully matches the topic name, and after obtaining the first tag according to the identifier of the subscribing client and the first mapping table, and obtaining the second tag according to the identifier of the publishing client and the first mapping table, the server can match the first tag and the second tag, and send the publishing message to the subscribing client when it is determined that the first tag and the second tag match successfully. In the present application, the first mapping table that records the correspondence between the client identifier and the tag is pre-stored in the server, and the server can match the attribute information of the publishing client and the subscribing client when the topic name matches the topic filter successfully, and send the publishing message to the subscribing client when the attribute information of the publishing client and the subscribing client matches successfully. In this way, when the subscribing client migrates and expands, the subscribing client does not need to republish the subscription message, and only needs to change the attribute information of the client, thereby solving the maintenance difficulty caused by the subscribing client maintaining the subscription relationship by itself. Moreover, the attribute information of the client in the present application includes a variety of information about the region. Compared with the prior art that can only match the region, the subscribing client can obtain published messages in more dimensions, that is, realize subscription in more dimensions, and have better scalability.
[0153] Furthermore, when the server determines that the identifier of the subscribing client is not an identifier that supports tag matching, it sends a publishing message to the subscribing client. In this way, since the client's tag is maintained in the server, compared with the second prior art in which the region identifier is carried in the topic, the original subscription and publishing mechanism that only supports topic matching in the prior art is retained. By managing the situation in which the topic filter supports tag matching in the server, the topic filter in the subscription message is separated from the situation in which it supports tag matching, so that when the topic filter remains unchanged and the topic filter is changed to support tag matching, the identification information corresponding to the topic filter in the server can be adjusted without the need for the subscribing client to first cancel the subscription and then re-subscribe to the topic filter.
[0154] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the interaction between various network elements. It can be understood that in order to implement the above functions, the server includes hardware structures and / or software modules corresponding to the execution of various functions. Those skilled in the art should easily realize that, in combination with the algorithm steps of each example described in the embodiments disclosed in this document, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0155] The embodiment of the present application can divide the functional modules of the server according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0156] In the case of dividing each functional module into corresponding functional modules, Figure 8 A possible composition diagram of the server involved in the above-mentioned embodiments is shown as follows: Figure 8 As shown, the server may include: a receiving module 41 , an acquiring module 42 , a publishing service module 43 , a tag management module 44 and a tag engine module 45 , wherein the publishing service module 43 may include a topic matching module 431 .
[0157] The receiving module 41 is used to execute Figure 2 The receiving publishing message sent by the publishing client as described in step 202 of the subscription publishing method shown in FIG. Figure 3The subscription and publishing method shown in the figure includes receiving a subscription message sent by a subscription client in step 302 and receiving a publishing message sent by a publishing client in step 305.
[0158] Acquisition module 42, used to execute Figure 2 The step 202 in the subscription publishing method shown in FIG. 10 is to obtain the identifier of the publishing client according to the publishing message. Figure 3 In the subscription and publishing method shown, step 302 of obtaining the identifier of the subscribing client according to the subscription message, and step 305 of obtaining the identifier of the publishing client according to the publishing message.
[0159] The publishing service module 43 is a module for processing publishing messages and is used to execute Figure 2 Step 206 in the subscription publishing method shown, Figure 3 Step 310 in the subscription and publishing method shown is used to send a publishing message to the subscription client after receiving the successful matching result returned by the label engine module 45, or to send a publishing message to the subscription client after receiving the instruction of the label matching module 432. And the publishing service module 43 is also used to process the publishing message after receiving the instruction sent by the ACL module 48. Specifically: if the publishing message contains a persistence identifier, the publishing service module 43 instructs the persistence module 49 to persist the publishing message, that is, to save the publishing message in a certain format to a non-volatile medium such as a hard disk or a tape, so that after receiving the subscription message sent by the subscription client, the server can send the persistent publishing message to the subscription client when it is determined that the subscription client has subscribed to the persistent publishing message, without waiting for the receipt of a new publishing message before sending a new publishing message to the subscription client. The publishing service module 43 is also used to return a response message to the publishing client according to the QoS identifier contained in the publishing message, and save the publishing message for a period of time in the session corresponding to the identifier of the publishing client in the session management module 47, so that when the subscribing client that has subscribed to the publishing message disconnects and reconnects to the server, the publishing service module 43 can send the publishing message to the subscribing client when it is determined that the subscribing client has subscribed to the publishing message.
[0160] Theme matching module 431 is used to perform Figure 2 Step 203 in the subscription publishing method shown, Figure 3 Step 306 in the subscription publishing method shown is used to search the subscription tree according to the topic name included in the publishing message, and obtain the identifier of the subscription client corresponding to the topic filter that successfully matches the topic name.
[0161] The tag management module 44 is used to provide management services for tags corresponding to the client, and can update the tags corresponding to the client's identification in real time. In a specific implementation, the tag management module 44 is used to execute Figure 2 Step 204 in the subscription publishing method shown, Figure 3 Step 308 in the subscription and publishing method shown is used to obtain a first tag corresponding to the identifier of the subscription client based on the identifier of the subscription client and the first mapping table after receiving an indication sent by the second subscription processing module 462, and to obtain a second tag corresponding to the identifier of the publishing client based on the identifier of the publishing client and the first mapping table, and to send the first tag and the second tag to the tag engine module 45.
[0162] The tag engine module 45 is used to execute Figure 2 Step 205 in the subscription publishing method shown, Figure 3 Step 309 in the subscription publishing method shown is used to match the first tag with the second tag and return the matching result to the publishing service module 43.
[0163] In the embodiments of the present application, further, Fig. 9 As shown, the server may also include: a subscription service module 46, a session management module 47, an ACL module 48 and a persistence module 49, the publishing service module 43 also includes a tag matching module 432, and the subscription service module 46 also includes a first subscription processing module 461 and a second subscription processing module 462.
[0164] The tag matching module 432 is used to determine whether the subscribing client supports tag matching. If tag matching is supported, the tag management module 44 is instructed to obtain a first tag corresponding to the identifier of the subscribing client and a second tag corresponding to the identifier of the publishing client. If tag matching is not supported, the publishing service module 43 is instructed to send a publishing message to the subscribing client.
[0165] The subscription service module 46 is a module for processing subscription messages and is used to execute Figure 3Step 303 in the subscription publishing method shown is used to determine whether each of the at least one topic filter included in the subscription message supports tag matching after receiving the instruction sent by the ACL module 48. For any topic filter, if the topic filter supports tag matching, an instruction is sent to the first subscription processing module 461, and the first subscription processing module 461 is used to associate the topic filter with the corresponding subtree in the subscription tree after receiving the instruction, and save the information of the subscription client in the subtree of the last topic level where the topic filter is stored, and the information of the subscription client includes the identifier of the subscription client and the indication information used to indicate that the subscription client supports tag matching. If the topic filter does not support tag matching, an instruction is sent to the second subscription processing module 462, and the second subscription processing module 462 is used to associate the topic filter with the corresponding subtree in the subscription tree after receiving the instruction, and save the information of the subscription client in the subtree of the last topic level where the topic filter is stored, and the information of the subscription client includes the identifier of the subscription client and the indication information used to indicate that the subscription client does not support tag matching.
[0166] The session management module 47 stores a second mapping table, each entry of which includes an identifier of the client, at least one topic filter corresponding to the identifier of the client, and identifier information corresponding to each topic filter in the at least one topic filter, each identifier information being used to indicate whether the topic filter corresponding to the identifier information supports tag matching, that is, the session management module 47 is used to execute Figure 3 The subscription publishing method shown obtains identification information corresponding to the first topic filter according to the identification of the subscription client, the first topic filter and the second mapping table. The session management module 47 is also used to resume the subscription work according to the session when it is determined that the session of the client is within the validity period after the client is disconnected and reconnected to the server.
[0167] ACL module 48 is used for access authentication and operation authentication of the client, and the client may include a subscription client and a publishing client. In a specific implementation, ACL module 48 is used to authenticate the username and password after receiving a connection request sent by the client containing the username, password and the client's identifier, and feedback the result to the client after the authentication is passed, and generate and save the client's session and the client's identifier corresponding to the session in session management module 47. ACL module 48 is also used to determine whether there is permission to subscribe to at least one topic filter included in the subscription message after receiving the subscription message sent by the subscription client, and after determining that there is permission to subscribe, instruct subscription service module 46 to process the subscription message. ACL module 48 is also used to determine whether the publishing client has permission to publish messages to the specified topic name after receiving the publishing message sent by the publishing client, and after determining that there is permission to publish, instruct publishing service module 43 to process the publishing message.
[0168] The persistence service module 49 is used for persistence of sessions, subscription messages and publishing messages.
[0169] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
[0170] The server provided in the embodiment of the present application is used to execute the above-mentioned subscription and publishing method, and thus can achieve the same effect as the above-mentioned subscription and publishing method.
[0171] In the case of an integrated unit, the server may include a processing module, a communication module and a storage module. The processing module may be a processor or a controller. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present application. The processor may also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of a digital signal processor (DSP) and a microprocessor, and the like. The communication module may be a transceiver, a transceiver circuit or a communication interface, and the like. The storage module may be a memory.
[0172] Fig.10 FIG. 2 shows another possible composition diagram of the server involved in the above embodiment. Fig.10 As shown, the server includes: a processor 51 , a memory 52 , a communication interface 53 and a communication bus 54 .
[0173] The processor 51 is the control center of the server, and may be a processor or a general term for multiple processing elements. For example, the processor 51 is a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application, such as one or more DSPs, or one or more field-programmable gate arrays (FPGAs).
[0174] The processor 51 can execute various functions of the server by running or executing the software program stored in the memory 52 and calling the data stored in the memory 52. For example, the processor 51 is used to execute Figure 2 The step 202 in step 203, step 204, step 205, Figure 3 The steps of step 302 of obtaining the identification of the subscribing client according to the subscription message, step 303, step 305 of obtaining the identification of the publishing client according to the publishing message, step 306, step 307, step 308, step 309, and / or other processes for the technology described in this article.
[0175] In a specific implementation, as an embodiment, the processor 51 may include one or more CPUs, such as Fig.10 As an example, the server may include multiple processors, such as Fig.10 51 and 55 are shown in FIG. Each of these processors may be a single-CPU or a multi-CPU. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0176] The memory 52 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 52 may exist independently and be connected to the processor 51 via a communication bus 54. The memory 52 may also be integrated with the processor 51.
[0177] The memory 52 is used to store the software program for executing the solution of the present application, and the execution is controlled by the processor 51 .
[0178] The communication interface 53 uses any transceiver-like device to communicate with other devices or communication networks, such as a subscribing client, a publishing client, a radio access network (RAN), a wireless local area network (WLAN), etc. In a specific implementation, the server can receive attribute information of the subscribing client's tag sent by the subscribing client, and attribute information of the publishing client's tag sent by the publishing client through the communication interface 53. The communication interface 53 can include a receiving unit to implement a receiving function, and a sending unit to implement a sending function. For example, the communication interface 53 is used to perform Figure 2 Step 202 of the step 206 of receiving the publishing message sent by the publishing client, Figure 3 The step 302 of receiving the subscription message sent by the subscription client, the step 305 of receiving the publishing message sent by the publishing client, and the step 310.
[0179] In the specific implementation of the embodiment of the present application, the communication interface 53 is an interface for the server running on the server to provide services to the outside. Since the MQTT protocol can communicate based on the transmission control protocol / internet protocol (TCP / IP), the communication interface 53 is bound to the 1833 service port by default. Of course, the MQTT protocol can also communicate based on other protocols, such as the Socket protocol. At this time, it is necessary to configure a communication interface 53 connected to other service ports. Therefore, based on different communication protocols, the server can configure different communication interfaces 53 as needed. In addition, the server can be configured with a communication interface 53 for managing tags, through which the tags of the client can be dynamically adjusted. The server can also be configured with a communication interface 53 for managing topic filters, through which the identification information corresponding to the topic filter can be dynamically modified to change whether the topic filter supports tag matching. It should be noted that in the embodiment of the present application, the communication interface 53 for managing tags and the communication interface 53 for managing topic filters can be the same interface or different interfaces. The embodiment of the present application does not specifically limit whether the communication interface for managing tags and the interface for managing topic filters are the same interface.
[0180] The communication bus 54 may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0181] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0182] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0183] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0184] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0185] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks or optical disks.
[0186] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A subscription publishing method, characterized in that: include: The server receives a publishing message sent by a publishing client, wherein the publishing message includes a topic name; The server obtains the identifier of the publishing client according to the publishing message; The server obtains the identifier of the subscribing client according to the topic name; The server acquires, according to the identifier of the subscribing client, a first tag corresponding to the identifier of the subscribing client; The first tag is used to indicate at least one attribute information of the subscribing client; The server acquires a second tag corresponding to the identifier of the publishing client according to the identifier of the publishing client; the second tag is used to indicate at least one attribute information of the publishing client; When determining that the first tag matches the second tag, the server sends the publishing message to the subscribing client.
2. The method according to claim 1, characterized in that The server obtains the identifier of the subscription client according to the topic name, including: The server searches the subscription tree according to the topic name to obtain the identifier of the subscription client, wherein the subscription tree is a topological structure composed of at least one topic filter, and the identifier of the subscription client is an identifier corresponding to a topic filter matching the topic name.
3. The method according to claim 1, characterized in that: The server acquiring, according to the identifier of the subscribing client, a first tag corresponding to the identifier of the subscribing client comprises: the server acquiring, according to the identifier of the subscribing client and a first mapping table, each entry of the first mapping table comprising the identifier of the client and the corresponding tag; The server acquiring, according to the identifier of the publishing client, a second tag corresponding to the identifier of the publishing client includes: the server acquiring, according to the identifier of the publishing client and the first mapping table, the second tag.
4. The method according to claim 3, characterized in that Before the server acquires the first tag according to the identifier of the subscription client and the first mapping table, the method further includes: The server determines that the subscribing client supports tag matching.
5. The method according to claim 1, characterized in that Before the server obtains the identifier of the subscribing client according to the topic name, the method further includes: The server receives a subscription message sent by the subscription client, wherein the subscription message includes at least one topic filter; The server obtains the identifier of the subscribing client according to the subscription message.
6. The method according to claim 5, characterized in that Each topic filter is divided into multiple layers, each layer is a topic level, and each topic level is stored in a subtree of the subscription tree. The method further includes: When the server determines that the first topic filter among the at least one topic filter supports tag matching, the server associates the first topic filter to the subscription tree, and saves the information of the subscription client in the subtree of the last topic level of the first topic filter stored in the subscription tree, wherein the information of the subscription client includes: an identifier of the subscription client and indication information for indicating that the subscription client supports tag matching, and the first topic filter is any one of the at least one topic filter.
7. The method according to claim 6, characterized in that The subscription message also includes: a first flag bit, the first flag bit includes a first value or a second value, the first value is used to indicate that each of the at least one topic filter supports tag matching, and the second value is used to indicate that the at least one topic filter includes at least one topic filter that does not support tag matching.
8. The method according to claim 7, characterized in that The determining that a first topic filter among the at least one topic filter supports tag matching includes: When the server determines that the first flag bit includes the first value, it determines that the first topic filter supports tag matching.
9. The method according to claim 7, characterized in that: The subscription message also includes: a second flag bit corresponding to each topic filter in the at least one topic filter, each second flag bit includes a third value or a fourth value, the third value is used to indicate that the topic filter corresponding to the second flag bit supports label matching, and the fourth value is used to indicate that the topic filter corresponding to the second flag bit does not support label matching.
10. The method according to claim 9, characterized in that The determining that a first topic filter among the at least one topic filter supports tag matching includes: When the server determines that the first flag bit includes the second value and determines that the second flag bit corresponding to the first topic filter includes the third value, the server determines that the first topic filter supports tag matching.
11. The method according to claim 6, characterized in that The method further comprises: The server obtains identification information corresponding to the first topic filter according to the identifier of the subscription client, the first topic filter and the second mapping table, each table entry of the second mapping table includes the identifier of the client, at least one topic filter corresponding to the identifier of the client, and identification information corresponding to each topic filter in at least one topic filter, each identification information includes a fifth value or a sixth value, the fifth value is used to indicate that the topic filter corresponding to the identification information supports label matching, and the sixth value is used to indicate that the topic filter corresponding to the identification information does not support label matching; The determining that a first topic filter among the at least one topic filter supports tag matching includes: When the server determines that the identification information corresponding to the first topic filter includes the fifth value, it determines that the first topic filter supports tag matching.
12. The method according to claim 6, characterized in that The determining that the subscription client supports tag matching includes: When the server determines that the subtree storing the identifier of the subscribing client further stores indication information indicating that the subscribing client supports tag matching, the server determines that the subscribing client supports tag matching.
13. The method according to any one of claims 1 to 12, characterized in that The first tag and the second tag match, including: The attribute values of each type of attribute information included in the first tag respectively conform to a preset logical relationship with the attribute values of the corresponding attribute information included in the second tag.
14. The method according to any one of claims 1 to 12, characterized in that: The method further comprises: The server receives a second subscription message sent by a second subscription client, where the second subscription message includes at least one topic filter; The server obtains the identifier of the second subscription client according to the second subscription message; The server obtains a pre-stored persistent message, where the persistent message is a persistent published message and includes a topic name; The server obtains, according to the topic name included in the persistent message, the identifier of the second subscription client corresponding to the topic filter that successfully matches the topic name in the persistent message; The server obtains the identifier of the second publishing client according to the persistent message; The server acquires, according to the identifier of the second publishing client, a third tag corresponding to the identifier of the second publishing client; The server acquires, according to the identifier of the second subscription client, a fourth tag corresponding to the identifier of the second subscription client; When determining that the third tag matches the fourth tag, the server sends the persistent message to the second subscription client.
15. A server, characterized in that: including memory and processor, The memory is used to store computer executable instructions; The processor is used to execute the computer-executable instructions so that the server implements the method according to any one of claims 1 to 14.
