CN115567584A - Processing method and device of subscription theme, electronic equipment and readable storage medium - Google Patents
Processing method and device of subscription theme, electronic equipment and readable storage medium Download PDFInfo
- Publication number
- CN115567584A CN115567584A CN202211152514.XA CN202211152514A CN115567584A CN 115567584 A CN115567584 A CN 115567584A CN 202211152514 A CN202211152514 A CN 202211152514A CN 115567584 A CN115567584 A CN 115567584A
- Authority
- CN
- China
- Prior art keywords
- topic
- wildcard
- level
- theme
- filter
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 16
- 238000012216 screening Methods 0.000 claims abstract description 65
- 238000000034 method Methods 0.000 claims description 39
- 239000002356 single layer Substances 0.000 claims description 38
- 238000012545 processing Methods 0.000 claims description 33
- 230000004044 response Effects 0.000 claims description 28
- 239000010410 layer Substances 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 15
- 230000014759 maintenance of location Effects 0.000 claims description 6
- 238000012217 deletion Methods 0.000 claims description 5
- 230000037430 deletion Effects 0.000 claims description 5
- 238000004891 communication Methods 0.000 abstract description 13
- 238000010586 diagram Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 9
- 238000001914 filtration Methods 0.000 description 5
- 230000000717 retained effect Effects 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000033228 biological regulation Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000002955 isolation Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/26—Special purpose or proprietary protocols or architectures
Landscapes
- Engineering & Computer Science (AREA)
- Computing Systems (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The disclosure provides a subscription theme processing method and device, electronic equipment and a readable storage medium, and relates to the field of computers and communications, in particular to the field of internet of things. The specific implementation scheme is as follows: responding to a received subscription request sent by a subscription end, and acquiring a topic filter carried in the subscription request; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until a first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topic subscribed by the subscriber can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topic to the subscriber.
Description
Technical Field
The disclosure relates to the technical field of computers and communications, particularly to the technical field of internet of things, and more particularly to a subscription theme processing method and apparatus, an electronic device, and a readable storage medium.
Background
The Message Queue Telemetry Transport (MQTT) protocol is a communication protocol based on a publish/subscribe mode, and is widely applied to the Internet of Things (Internet of Things, ioT) field.
The MQTT protocol supports a reservation message mechanism. When the MQTT server receives the reservation message, the reservation message is stored. After the MQTT client is accessed, a subscription request is sent, the subscription request carries a topic filter (topic filter), the MQTT server screens out subscription topics of the MQTT client according to the topic filter, and then reservation messages corresponding to the subscription topics are pushed to the MQTT client.
The MQTT client may subscribe to a plurality of topics at a time, which requires introducing wildcards into the topic filter, and how to effectively screen out the subscribed topics of the MQTT client according to the topic filter becomes an important technical problem under the condition that the wildcards are introduced into the topic filter.
Disclosure of Invention
In order to solve at least one of the above drawbacks, the present disclosure provides a method and an apparatus for processing a subscription topic, an electronic device, and a readable storage medium.
According to a first aspect of the present disclosure, there is provided a method for processing a subscription topic, the method including:
responding to a subscription request sent by a subscription end, and acquiring a theme filter carried in the subscription request;
according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until the first wildcard is found;
screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard;
and determining the target topic subscribed by the subscriber based on the first topic set.
According to a second aspect of the present disclosure, there is provided a processing apparatus for subscribing to a topic, the apparatus comprising:
the topic filter acquisition module is used for responding to a received subscription request sent by a subscription end and acquiring a topic filter carried in the subscription request;
the first wildcard character determining module is used for sequentially searching from the root theme level of the theme filter according to the theme level sequence in the theme filter until the first wildcard character is searched;
the first topic set determining module is used for screening out a first topic set under a topic hierarchy occupied by a first wildcard from a preset initial topic set based on a topic screening mode corresponding to a wildcard type of the first wildcard;
and the subscription theme determining module is used for determining the target theme subscribed by the subscriber based on the first theme set.
According to a third aspect of the present disclosure, there is provided an electronic apparatus comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor, the instructions being executable by the at least one processor to enable the at least one processor to perform the method for processing the subscription topic.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the above-described processing method of a subscription topic.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the above-described processing method of subscription topics.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a schematic structural diagram of a publish-subscribe system provided by an embodiment of the present disclosure;
fig. 2 is a flowchart illustrating a method for processing a subscription topic according to an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating another topic subscription processing method provided by an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a processing apparatus for subscribing to a topic according to an embodiment of the present disclosure;
FIG. 5 is a schematic structural diagram of another topic subscription processing apparatus provided in an embodiment of the present disclosure;
fig. 6 is a block diagram of an electronic device for implementing a method for processing a subscription topic according to an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of embodiments of the present disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The terms referred to in this application will first be introduced and explained:
the Message Queue Telemetry Transport (MQTT) protocol is a communication protocol based on a publish/subscribe mode, and is widely applied to the field of Internet of Things (IoT).
Reservation Messages (retrieved Messages) are one MQTT message with the reservation flag set to true (true). The MQTT client receives a reservation message associated with the topic after subscribing to the topic.
The topic filter (topic filter) is the topic name of the MQTT client when subscribing the topic, and the subscription topic of the MQTT client can be screened out through the topic filter.
Wildcards, are symbols that are used to replace a given level in a topic filter. Wildcards include single-layer wildcards as well as multi-layer wildcards.
A single-level wildcard is generally indicated by a "+" and is used to occupy a single topic level in a topic filter, and a single-level wildcard may be used at any topic level of a topic filter. The theme filter may include a plurality of single-layer wildcards.
Multiple levels of wildcards are generally indicated by "#" for occupying multiple theme levels in the theme filter. The multi-level wildcard must be the last character and not preceded by a character or preceded by a subject level delimiter.
The scheme provided in the embodiment of the present disclosure is not only applicable to the MQTT protocol, but also applicable to other communication protocols in accordance with the usage rules of wildcards in the subject filter specified in the MQTT protocol, for example, network Address translation protocol (NATS).
A schematic structural diagram of a publish-subscribe system provided in an embodiment of the present disclosure is shown in fig. 1. As shown in fig. 1, the publish-subscribe system includes a plurality of MQTT servers, a plurality of MQTT clients, a reservation message service 130, and a reservation message library 140.
The MQTT client 110 serves as a publishing end of the reservation information, the MQTT client 110 may send the reservation information to the MQTT server 120, and the MQTT server 120 receives the reservation information sent by the MQTT client 110 and pushes the reservation information to the reservation message service 130. The reservation message service 130 may write the reservation message to the reservation message library 140 after receiving the reservation message pushed by the MQTT service 120.
The MQTT client 160 serves as a subscription end for retaining information, the MQTT client 160 may submit a subscription request to the MQTT server 150, and after receiving the subscription request submitted by the MQTT client 160, the MQTT server 150 screens out topics subscribed by the MQTT client 160, and sends an acquisition request for a retention message associated with the topics subscribed by the MQTT client 160 to the retention information service.
After receiving the acquisition request sent by the MQTT server 150, the reservation message service 130 may read the reservation message associated with the topic subscribed by the MQTT client 160 from the reservation message library 140, and return the reservation message to the MQTT server 150. After receiving the reservation message returned by the reservation message service 130, the MQTT server 150 sends the reservation message to the MQTT client 160.
Fig. 2 is a flowchart illustrating a method for processing a subscription topic provided in an embodiment of the present disclosure, and as shown in fig. 2, the method mainly includes:
step S210: and responding to the received subscription request sent by the subscription terminal, and acquiring the topic filter carried in the subscription request.
The subscription terminal can be an MQTT client terminal, and can send a subscription request to the MQTT server terminal after accessing a publish-subscribe system, wherein the subscription request carries a topic filter, and the MQTT server terminal screens out a target topic subscribed by the subscription terminal according to the topic filter.
The theme filter can comprise a plurality of theme hierarchies, and each theme hierarchy can be divided and placed by a theme hierarchy separator, wherein the theme hierarchy separator is 'v' in general.
Step S220: and sequentially searching from the root theme level of the theme filter according to the theme level sequence in the theme filter until the first wildcard is searched.
One or more wildcards may be included in the topic filter. Wildcards are used to occupy one or more theme hierarchies in the theme filter.
The first wildcard is the wildcard found closest to the root topic level of the topic filter according to the topic level sequence in the topic filter.
As an example, the theme filter is "device/status/+/car/#", where the theme level corresponding to the root theme level of the theme filter is identified as "device", and the first found wildcard "+" may be used as the first wildcard by searching from the root theme level according to the order of the theme levels in the theme filter.
Step S230: and screening a first subject matter set under a subject level occupied by the first wildcard from a preset initial subject matter set based on a subject screening mode corresponding to the wildcard type of the first wildcard.
Step S240: and determining the target topic subscribed by the subscriber based on the first topic set.
The wildcard type of the first wildcard can be a single-layer wildcard or a multi-layer wildcard. A single-layer wildcard is used to occupy any single topic level in the topic filter, generally denoted by "+". The theme filter may include a plurality of single-layer wildcards. Multiple levels of wildcards are used to occupy multiple subject levels in the subject filter. The multi-level wildcards are generally indicated by "#", which must be the last character and not preceded by a character or preceded by a subject-level delimiter.
Due to the different characteristics of the single-layer wildcards and the multi-layer wildcards in use, different theme screening modes can be respectively configured for the single-layer wildcards and the multi-layer wildcards.
In the embodiment of the present disclosure, the MQTT server may summarize topics corresponding to the stored reservation messages, and construct an initial topic set.
After the first wildcard is found, the corresponding topic screening mode can be determined according to the wildcard type of the first wildcard, and then the first topic set under the topic hierarchy occupied by the first wildcard is screened out based on the topic screening mode.
Since the first wildcard is the wildcard closest to the root topic hierarchy of the topic filter, if there are other wildcards in the topic filter in addition to the first wildcard, the topic hierarchy occupied by the other wildcards is also lower than the topic hierarchy occupied by the first wildcard, and the topics under the topic hierarchy occupied by the other wildcards are also within the first topic set. Accordingly, a target topic subscribed to by the subscriber may be determined based on the first set of topics.
As an example, the topic filter is "device/status/+/car/#", the topic hierarchy corresponding to "device" is recorded as the root topic hierarchy, the topic hierarchy corresponding to "status" is recorded as the first sub-topic hierarchy, the topic hierarchy corresponding to "+" is recorded as the second sub-topic hierarchy, the topic hierarchy corresponding to "car" is recorded as the third sub-topic hierarchy, and the topic hierarchy corresponding to "#" is recorded as the fourth sub-topic hierarchy. The first wildcard character is "+", the first theme set is the theme of the initial theme set under the third sub-theme level, and the theme under the fourth sub-theme level occupied by the wildcard character "#" in the initial theme set belongs to the first theme set.
In the embodiment of the present disclosure, when performing topic screening for a topic filter including wildcards, a first wildcard closest to a root topic level in the topic filter may be found first, a first topic set under the topic level occupied by the first wildcard is screened from an initial topic set, and a target topic subscribed by a subscriber is determined from the first topic set.
According to the method provided by the embodiment of the disclosure, a topic filter carried in a subscription request is obtained by responding to the received subscription request sent by a subscription end; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until the first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topics subscribed by the subscriber terminal can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topics to the subscriber terminal.
In the embodiment of the disclosure, when the topic filter includes wildcards, first wildcards of a nearest root topic level in the topic filter are found, and a first topic set under the topic level occupied by the first wildcards is screened out from the initial topic set, so as to determine a target topic subscribed by the subscriber from the first topic set. Compared with the method for directly screening the target subject subscribed by the subscriber from the initial subject set, the method for screening the target subject has the advantages that the screened first subject set is less in number of the subject contained in the initial subject set, the target subject subscribed by the subscriber is screened from the first subject set, the number of the screened subjects is less, the operation for screening the subject is quicker, and the calculation power is saved.
In an optional manner of the present disclosure, determining a target topic subscribed by a subscriber based on a first topic set includes:
and in response to the first wildcard being a multi-layer wildcard or no other wildcard existing after the first wildcard in the topic filter, determining the first topic set as the target topic subscribed by the subscriber.
In the embodiment of the present disclosure, the multilayer wildcard is the last character in the topic filter, and therefore, when the first wildcard is the multilayer wildcard, it may be considered that the topic filter only includes one multilayer wildcard, and the first topic set under the topic hierarchy occupied by the multilayer wildcard may be determined as the target topic subscribed by the subscriber.
For example, the topic filter is "device/status/car/#", the first wildcard in the topic filter is "#", i.e., the last character of the topic filter is a multi-level wildcard.
In the embodiment of the present disclosure, the topic filter may only include one single-layer wildcard (i.e., the first wildcard) and not include other wildcards, and then the first topic set under the topic hierarchy occupied by the single-layer wildcard may be determined as the target topic subscribed by the subscriber.
For example, the topic filter is "device/status/+/car/", the first wildcard in the topic filter is "+", and the topic filter contains only one single-layer wildcard.
In an optional manner of the present disclosure, determining a target topic subscribed by a subscriber based on a first topic set includes:
in response to the first wildcard being a single-layer wildcard, sequentially searching from the sub-level of the theme level occupied by the first wildcard in the theme filter according to the sequence of the theme level in the theme filter until a second wildcard is searched;
screening a second subject set under a subject level occupied by a second wildcard from a preset first subject set based on a subject screening mode corresponding to the wildcard type of the second wildcard;
determining the second topic set as the target topic subscribed by the subscriber end in response to the second wildcard being a multi-layer wildcard or no other wildcard existing after the second wildcard in the topic filter;
and in response to the second wildcard being a single-layer wildcard, taking the second wildcard as a first wildcard, taking the second topic set as a first topic set, repeatedly performing the steps of sequentially searching from the sub-level of the topic level occupied by the first wildcard in the topic filter according to the topic level sequence in the topic filter until the second wildcard is found, and screening a second topic set under the topic level occupied by the second wildcard from the preset first topic set based on a topic screening mode corresponding to the wildcard type of the second wildcard until the second wildcard is a multi-layer wildcard, or determining the second topic set as a target topic subscribed by the subscriber when no other wildcard exists behind the second wildcard in the topic filter.
In the embodiment of the present disclosure, when the first wildcard is a single-layer wildcard and there are other wildcards after the first wildcard in the topic filter, according to the topic hierarchy sequence in the topic filter, other wildcards that are after the first wildcard and are closest to the first wildcard are found in the topic filter, and the first found wildcard is used as the second wildcard.
The wildcard type of the second wildcard can be a single-layer wildcard or a multi-layer wildcard, and a second topic set under the topic level occupied by the second wildcard can be screened from the first topic set according to a topic screening mode corresponding to the wildcard type of the second wildcard.
And when the second wildcard is a multilayer wildcard, the second wildcard is the last character in the topic filter, and at this time, the step of continuously searching the wildcard after the second wildcard can be stopped, and the second topic set is directly determined as the target topic subscribed by the subscriber.
For example, the topic filter is "device/status/+/car/#", and the second wildcard in the topic filter is the multi-level wildcard "#".
When the second wildcard is a single-layer wildcard and there is no other wildcard after the second wildcard in the topic filter, the step of searching for the wildcard after the second wildcard may be stopped, and the second topic set is directly determined as the target topic subscribed by the subscriber.
For example, the topic filter is "device/status/+/car/+" and the second wildcard in the topic filter is a single-layer wildcard "+".
The second wildcard is a single-layer wildcard, and when there are other wildcards in the subject filter after the second wildcard, for example, the subject filter is "device/status/+/car/+/aa/#", the second wildcard in the subject filter is a single-layer wildcard "+", and the subject filter also has other characters after the second wildcard. Then, the second wildcard may be used as the first wildcard, the second topic set may be used as the first topic set, the above steps of sequentially searching from the sub-level of the topic hierarchy occupied by the first wildcard in the topic filter according to the topic hierarchy sequence in the topic filter until the second wildcard is found are repeatedly executed, and based on the topic screening manner corresponding to the wildcard type of the second wildcard, the second topic set under the topic hierarchy occupied by the second wildcard is screened from the preset first topic set until the second wildcard is a multi-layer wildcard, or no other wildcard exists after the second wildcard in the topic filter, and the second topic set is determined as the target topic subscribed by the subscriber.
By repeatedly executing the operation of searching the next wildcard and determining the topic set under the topic level occupied by the searched wildcard, all the wildcards in the topic filter can be searched, and the topic sets under the topic level occupied by the wildcard are sequentially screened from the initial topic set until the target topic subscribed by the subscriber is finally screened.
The method provided by the embodiment of the disclosure can traverse all wildcards in the topic filter, and can sequentially screen out the topic sets under the topic hierarchy occupied by the wildcards from the initial topic set until the target topics subscribed by the subscribers are finally screened out, compared with the method of directly screening out the target topics subscribed by the subscribers from the initial topic set, the number of the screened topics is less, so that the topic screening operation is faster, and the calculation power is more saved.
In an optional manner of the present disclosure, based on a topic screening manner corresponding to a wildcard type of a first wildcard, screening out a first topic set under a topic hierarchy occupied by the first wildcard from a preset initial topic set, includes:
determining candidate topics of which the level identifications of a first topic level are matched with the first topic level identifications from a preset initial topic set, wherein the first topic level is a parent level of the topic level occupied by a first wildcard in a topic filter, and the first topic level identifications are level identifications of the first topic level in the topic filter;
in response to the first wildcard being a single-layer wildcard, determining from the candidate topics a first topic set whose hierarchical identity of the second topic level matches a second topic level identity, the second topic level being a sub-level of the topic level occupied by the first wildcard in the topic filter, the second topic level identity being a level identity of a second topic level in the topic filter;
in response to the first wildcard being a multi-level wildcard, a candidate topic is determined as a first topic set under the topic hierarchy occupied by the first wildcard.
In the embodiment of the present disclosure, a parent level of a theme level occupied by a first wildcard in the theme filter may be marked as a first theme level, and a level identifier of the first theme level in the theme filter may be marked as a first theme level identifier.
And matching the hierarchical identification of each topic in the initial topic set at the first topic hierarchy with the identification of the first topic hierarchy to obtain a candidate topic. The level identification of the candidate subject at the first subject level is matched with the level identification of the first subject, namely the level identification of the candidate subject at the first subject level is the same as the level identification of the first subject.
For example, the topic filter is "device/+/car/", the first wildcard in the topic filter is a single-layer wildcard "+", the hierarchy of the first topic hierarchy is identified as "device", and all topics that are matched out of the initial topic set at the hierarchy of the first topic hierarchy and identified as "device" are candidate topics.
In the embodiment of the present disclosure, the first wildcard can be a single-layer wildcard or a multi-layer wildcard, and the first topic set under the topic hierarchy occupied by the first wildcard is within the candidate topics.
When the first wildcard is a single-layer wildcard, a sub-level of the theme level occupied by the first wildcard in the theme filter can be marked as a second theme level, and a level identifier of the second theme level in the theme filter can be marked as a second theme level identifier.
And the topic of the second topic hierarchy in the candidate topics is matched with the second topic hierarchy, namely the first topic set under the topic hierarchy occupied by the first wildcard.
Therefore, the level identification of each candidate topic in the second topic level can be matched with the identification of the second topic level, and the first topic set is matched. The level identification of each topic in the first topic set at the second topic level is matched with the level identification of the second topic, namely the level identification of each topic in the first topic set at the second topic level is the same as the level identification of the second topic.
For example, the topic filter is "device/+/car/", the first wildcard in the topic filter is a single-layer wildcard "+", the hierarchy of the second topic hierarchy is identified as "car", and all topics matching the hierarchy of the second topic hierarchy identified as "car" in the candidate topic are taken as the first topic set.
When the first wildcard is a multilayer wildcard, the first wildcard is the last character in the topic filter, so that the candidate topics can be directly determined as the first topic set under the topic hierarchy occupied by the first wildcard without further screening of the candidate topics.
In the embodiment of the present disclosure, based on the theme filtering manner corresponding to the wildcard type of the second wildcard, a specific principle of filtering out the second theme set under the theme hierarchy occupied by the second wildcard from the preset first theme set may refer to a principle of filtering out the first theme set under the theme hierarchy occupied by the first wildcard from the preset initial theme set.
In particular, a second candidate topic may be determined from the first topic set whose hierarchical identity of a third topic hierarchy matches a third topic hierarchy identity, the third topic hierarchy being a parent hierarchy of the topic hierarchy occupied by the second wildcard in the topic filter, the third topic hierarchy identity being a hierarchical identity of a third topic hierarchy in the topic filter;
in response to the second wildcard being a single-layer wildcard, determining from the second candidate topic a second topic set whose topic level identifier matches a fourth topic level identifier, the fourth topic level being a sub-level of the topic level occupied by the second wildcard in the topic filter, the fourth topic level identifier being a level identifier of a fourth topic level in the topic filter;
in response to the second wildcard being a multi-level wildcard, a second candidate topic is determined as a second topic set under the topic hierarchy occupied by the second wildcard.
In an optional manner of the present disclosure, the step of determining candidate topics, in which the hierarchical identifier of the first topic hierarchy matches the first topic hierarchy identifier, from a preset initial topic set, includes:
searching a first theme, of which the level identification of the first theme level is matched with the first theme level identification, from a preset initial theme set;
sequentially searching from the first theme according to the arrangement sequence of the themes in the initial theme set until the last theme matched with the hierarchy identifier of the first theme hierarchy is searched;
the first topic, the last topic, and all topics in the initial set of topics between the first topic and the last topic are determined as candidate topics matching the first topic hierarchy identification.
In the embodiment of the present disclosure, the topics in the initial topic set are arranged according to the alphabetical order of the corresponding topic identifier, that is, according to the letters included in each topic identifier, the topics are sorted according to the alphabetical order. The alphabetical order in this example is a 26 letter alphabetical ranking.
In this disclosure, since the topics in the initial topic set are arranged according to the alphabetical order of the corresponding topic identifiers, a first topic, where the hierarchy identifier of the first topic hierarchy matches the hierarchy identifier of the first topic, may be found from the initial topic set, and then sequentially searched from the first topic according to the arrangement order of the topics in the initial topic set until a last topic, where the hierarchy identifier of the first topic hierarchy matches the hierarchy identifier of the first topic, is found, at this time, it may be considered that all candidate topics have been found, and all topics, which are located between the first topic and the last topic in the initial topic set, may be determined as candidate topics matching the hierarchy identifier of the first topic.
By the theme searching mode, the theme can be quickly searched.
In an optional implementation manner of the present disclosure, after determining, based on the first topic set, a target topic subscribed by the subscriber, the method further includes:
and determining a target reservation message associated with the target topic from reservation messages stored in a preset reservation message library, and returning the target reservation message to the subscriber terminal.
In the embodiment of the disclosure, the MQTT server may store the reservation message in the reservation message library, and after determining the target topic subscribed by the subscriber, may find out the target reservation message associated with the target topic from the reservation message library, and return the target reservation message to the subscriber.
In an optional mode of the present disclosure, the reserving message library is constructed based on the reserving messages and key values corresponding to the reserving messages, the key values include topic identifiers associated with the reserving messages, and determining a target reserving message associated with a target topic from a preset reserving message library includes:
determining a target key value from key values stored in a reserved message library, wherein the target key value comprises a subject mark of a target subject;
targeted retained messages associated with the targeted subject are located from the retained message store based on the targeted key value.
In the embodiment of the present disclosure, after receiving the reservation message, a key value corresponding to the reservation message may be generated, and the reservation message and the key value form a key value pair and are stored in the reservation message library.
Specifically, the key value may be assembled based on a predetermined assembly manner and according to the topic identifier associated with the reservation message.
When the target reservation message associated with the target topic is searched from the reservation message library, the target key value containing the topic identification of the target topic can be searched from all key values, and then the reservation message corresponding to the target key value is used as the target reservation message associated with the target topic.
As one example, each reservation message in the pool of reservation messages may be sorted alphabetically by key value. The target subject is matched from the initial subject set, so that the target subject can be sorted according to the alphabetical sequence of the subject identification, a first subject in the target subject and a last subject in the target subject can be determined, then a first key value is assembled according to the first subject, and a second key value is assembled according to the last subject. And constructing a key value interval by using the first key value and the second key value, wherein the reserved message corresponding to the key value interval is the target reserved message associated with the target theme, so that the target reserved message associated with the target theme can be quickly searched from the reserved message library according to the key value interval.
In the embodiment of the present disclosure, for the case that the topic filter does not include a wildcard, after receiving the reservation message, a key value may be combined according to the topic identifier of the topic associated with the reservation message. And performing table look-up operation in the reservation message library according to the key value to obtain corresponding reservation information and returning the corresponding reservation information to the subscriber.
According to the rules in the MQTT protocol, only one reservation message corresponding to each topic can be stored in the reservation message library. An update mechanism for the reservation message may also be supported in embodiments of the present disclosure. Specifically, after receiving the reservation message, the MQTT client combines key values according to the topic identifier of the topic associated with the reservation message. If the message body of the reservation message is not empty, the corresponding key value pair can be searched from the reservation information base according to the key value and updated.
The embodiment of the disclosure also supports a deletion mechanism of the reservation message. Specifically, after receiving the reservation message, the MQTT client combines a key value according to the topic identifier of the topic associated with the reservation message. If the message body of the reservation message is empty, the corresponding key value pair can be searched from the reservation information base according to the corresponding key value and deleted.
In an alternative aspect of the disclosure, the topics in the initial topic set are divided into at least one topic group, and the topic group satisfies at least one of the following:
the number of subscribed topics in the topic group is not greater than a first preset value;
the number of the reserved messages associated with the topics contained in the topic group is not greater than a second preset value;
the reading frequency of the reservation messages associated with the topics contained in the topic group is not more than a third preset value;
the writing frequency of the reservation messages associated with the topics contained in the topic group is not greater than a fourth preset value;
the frequency of deletion of the retention messages associated with the topics contained in the topic group is not greater than a fifth preset value.
In the embodiment of the disclosure, the topics can be grouped, and the topics in the initial topic set are divided into at least one topic group, so that the isolation of the topics among different topic groups is realized.
The topic groups may be divided according to actual service requirements, and as an example, the topic groups may correspond to users, so that topics issued by different users can be isolated from each other.
In the embodiment of the present disclosure, the related services for the topics in the topic group may be controlled by taking the topic group as a granularity.
As an example, the number of subscribed topics within the topic group may be limited to be no greater than a first preset value at the granularity of the topic group.
When the topic filter of the subscriber contains multiple layers of wildcards, the number of topics subscribed by the subscriber can be large, which makes the message amount of the message published to the subscriber huge, and causes processing pressure. By limiting the number of the subscribed topics in the topic group to be not greater than the first preset value, the situation that the number of the subscribed topics is excessive at the subscribing end is avoided, and the processing pressure is avoided.
As an example, the number of the reservation messages associated with the topics contained in the topic group may be limited to be not greater than the second preset value by using the topic group as a granularity, so as to avoid that too many reservation messages are stored in the reservation message library for a single topic group, which may cause memory pressure.
As an example, the frequency of reading, writing, deleting, etc. operations of the reserved messages associated with the topics contained in the topic group may be limited with the topic group as a granularity, so that the reading frequency is not greater than the third preset value, the writing frequency is not greater than the fourth preset value, and the deleting frequency is not greater than the fifth preset value, so as to avoid processing pressure caused by frequent operations on the reserved messages in a single topic group.
In the embodiment of the present disclosure, the values of the first preset value, the second preset value, the third preset value, the fourth preset value, and the fifth preset value may be configured according to actual service needs.
Fig. 3 is a flowchart illustrating another method for processing a subscription topic provided in the embodiment of the present disclosure, and as shown in fig. 3, the method mainly includes:
step S310: and responding to the received subscription request sent by the subscription terminal, and acquiring the topic filter carried in the subscription request.
The subscription terminal can be an MQTT client terminal, and can send a subscription request to the MQTT server terminal after accessing a publish-subscribe system, wherein the subscription request carries a topic filter, and the MQTT server terminal screens out a target topic subscribed by the subscription terminal according to the topic filter.
The theme filter can comprise a plurality of theme hierarchies, and each theme hierarchy can be divided and placed by a theme hierarchy separator, wherein the theme hierarchy separator is 'v' in general.
Step S320: and sequentially searching from the root theme level of the theme filter according to the theme level sequence in the theme filter until the first wildcard is searched.
One or more wildcards may be included in the topic filter. Wildcards are used to occupy one or more theme hierarchies in the theme filter.
The first wildcard is the wildcard found closest to the root topic level of the topic filter according to the topic level sequence in the topic filter.
As an example, the topic filter is "device/status/+/car/#", wherein the topic level corresponding to the root topic level of the topic filter is identified as "device", and the topic level is searched from the root topic level according to the sequence of topic levels in the topic filter, and the wildcard "+" searched first can be used as the first wildcard.
Step S330: and screening a first subject set under a subject level occupied by the first wildcard from a preset initial subject set based on a subject screening mode corresponding to the wildcard type of the first wildcard.
Step S340: and determining the target topic subscribed by the subscriber based on the first topic set.
Step S350: after determining the target topic subscribed by the subscriber based on the first topic set, determining a target reservation message associated with the target topic from reservation messages stored in a preset reservation message library, and returning the target reservation message to the subscriber.
The wildcard type of the first wildcard can be a single-layer wildcard or a multi-layer wildcard. A single-layer wildcard is used to occupy any single topic level in the topic filter, generally denoted by "+". The theme filter may include a plurality of single-layer wildcards. Multiple levels of wildcards are used to occupy multiple subject hierarchies in the subject filter. The multi-level wildcards are generally indicated by "#", which must be the last character and not preceded by a character or preceded by a subject-level delimiter.
Due to the different characteristics of the single-layer wildcards and the multi-layer wildcards in use, different theme screening modes can be configured for the single-layer wildcards and the multi-layer wildcards respectively.
In the embodiment of the disclosure, the MQTT server may summarize topics corresponding to the stored reservation messages to construct an initial topic set.
After the first wildcard is found, the corresponding topic screening mode can be determined according to the wildcard type of the first wildcard, and then the first topic set under the topic hierarchy occupied by the first wildcard is screened out based on the topic screening mode.
Since the first wildcard is the wildcard closest to the root topic hierarchy of the topic filter, if there are other wildcards in the topic filter in addition to the first wildcard, the topic hierarchy occupied by the other wildcards is also lower than the topic hierarchy occupied by the first wildcard, and the topics under the topic hierarchy occupied by the other wildcards are also within the first topic set. Accordingly, a target topic subscribed to by the subscriber may be determined based on the first set of topics.
As an example, the topic filter is "device/status/+/car/#", the topic hierarchy corresponding to "device" is recorded as the root topic hierarchy, the topic hierarchy corresponding to "status" is recorded as the first sub-topic hierarchy, the topic hierarchy corresponding to "+" is recorded as the second sub-topic hierarchy, the topic hierarchy corresponding to "car" is recorded as the third sub-topic hierarchy, and the topic hierarchy corresponding to "#" is recorded as the fourth sub-topic hierarchy. The first wildcard character is "+", the first theme set is the theme of the initial theme set under the third sub-theme level, and the theme of the fourth sub-theme level occupied by the wildcard character "#" in the initial theme set belongs to the first theme set.
In the embodiment of the present disclosure, when performing topic screening on a topic filter including wildcards, a first wildcard closest to a root topic level in the topic filter may be found first, a first topic set under the topic level occupied by the first wildcard is screened from an initial topic set, and a target topic subscribed by a subscriber is determined from the first topic set.
In the method provided by the embodiment of the disclosure, a topic filter carried in a subscription request is obtained by responding to the received subscription request sent by a subscription end; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until a first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topics subscribed by the subscriber terminal can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topics to the subscriber terminal.
In the embodiment of the disclosure, when the topic filter includes wildcards, first wildcards of a nearest root topic level in the topic filter are found, and a first topic set under the topic level occupied by the first wildcards is screened out from the initial topic set, so as to determine a target topic subscribed by the subscriber from the first topic set. Compared with the method for directly screening the target topics subscribed by the subscription end from the initial topic set, the method has the advantages that the screened first topic set is smaller in number of the topics compared with the initial topic set, the target topics subscribed by the subscription end are screened from the first topic set, the screened topics are smaller in number, screening operation on the topics is quicker, and calculation power is saved.
In the embodiment of the disclosure, the MQTT server may store the reservation message in the reservation message library, and after determining the target topic subscribed by the subscriber, may find out the target reservation message associated with the target topic from the reservation message library, and return the target reservation message to the subscriber.
Based on the same principle as the method shown in fig. 2, fig. 4 shows a schematic structural diagram of a processing apparatus for subscribing to a topic provided by the embodiment of the present disclosure, as shown in fig. 4, the processing apparatus 40 for subscribing to a topic may include:
a topic filter obtaining module 410, configured to, in response to receiving a subscription request sent by a subscriber, obtain a topic filter carried in the subscription request;
a first wildcard character determining module 420, configured to sequentially search from a root topic level of the topic filter according to a topic level sequence in the topic filter until a first wildcard character is found;
a first topic set determining module 430, configured to filter, from a preset initial topic set, a first topic set in a topic hierarchy occupied by a first wildcard, based on a topic filtering manner corresponding to a wildcard type of the first wildcard;
and a subscribed topic determining module 440, configured to determine, based on the first topic set, a target topic subscribed by the subscriber.
According to the device provided by the embodiment of the disclosure, a topic filter carried in a subscription request is obtained by responding to the received subscription request sent by a subscription terminal; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until the first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topics subscribed by the subscriber terminal can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topics to the subscriber terminal.
Optionally, the subscription topic determination module is specifically configured to:
and in response to the first wildcard being a multi-layer wildcard or no other wildcard existing after the first wildcard in the topic filter, determining the first topic set as the target topic subscribed by the subscriber.
Optionally, the subscription topic determination module is specifically configured to:
in response to the first wildcard being a single-layer wildcard, sequentially searching from a sub-level of the topic level occupied by the first wildcard in the topic filter according to the topic level sequence in the topic filter until a second wildcard is searched;
screening a second subject set under a subject level occupied by a second wildcard from a preset first subject set based on a subject screening mode corresponding to the wildcard type of the second wildcard;
in response to the second wildcard being a multi-layer wildcard or no other wildcard existing after the second wildcard in the topic filter, determining the second topic set as a target topic subscribed by the subscriber;
and in response to the second wildcard being a single-layer wildcard, taking the second wildcard as a first wildcard, taking a second topic set as a first topic set, repeatedly executing the steps of sequentially searching from a sub-level of a topic level occupied by the first wildcard in the topic filter according to the topic level sequence in the topic filter until the second wildcard is found, and screening the second topic set under the topic level occupied by the second wildcard from the preset first topic set based on a topic screening mode corresponding to the wildcard type of the second wildcard until the second wildcard is a multi-layer wildcard or no other wildcard exists after the second wildcard in the topic filter, and determining the second topic set as a target topic subscribed by the subscriber.
Optionally, the first theme set determination module is specifically configured to:
determining candidate themes of which the level identifications of the first theme level are matched with the first theme level identifications from a preset initial theme set, wherein the first theme level is a parent level of the theme level occupied by a first wildcard in a theme filter, and the first theme level identifications are level identifications of the first theme level in the theme filter;
in response to the first wildcard being a single-layer wildcard, determining from the candidate topics a first topic set whose hierarchical identity of the second topic level matches a second topic level identity, the second topic level being a sub-level of the topic level occupied by the first wildcard in the topic filter, the second topic level identity being a level identity of a second topic level in the topic filter;
in response to the first wildcard being a multi-level wildcard, a candidate topic is determined as a first topic set under the topic hierarchy occupied by the first wildcard.
Optionally, the topics in the initial topic set are arranged in an alphabetical order according to the corresponding topic identifier, and when the first topic set determining module determines a candidate topic, where the hierarchical identifier of the first topic hierarchy matches the hierarchical identifier of the first topic, from a preset initial topic set, the first topic set determining module is specifically configured to:
searching a first theme, of which the level identification of the first theme level is matched with the first theme level identification, from a preset initial theme set;
sequentially searching from the first theme according to the arrangement sequence of the themes in the initial theme set until the last theme matched with the hierarchy identifier of the first theme hierarchy is searched;
the first topic, the last topic, and all topics in the initial set of topics between the first topic and the last topic are determined as candidate topics matching the first topic hierarchy identification.
Optionally, the apparatus further comprises:
and the target reservation message returning module is used for determining a target reservation message associated with the target topic from the reservation messages stored in the preset reservation message library after determining the target topic subscribed by the subscriber based on the first topic set, and returning the target reservation message to the subscriber.
Optionally, the reservation message library is constructed based on the reservation message and a key value corresponding to the reservation message, and when the target reservation message return module determines the target reservation message associated with the target topic from the reservation messages stored in the preset reservation message library, the target reservation message return module is specifically configured to:
determining a target key value from key values stored in a reserved message library, wherein the target key value comprises a subject mark of a target subject;
a targeted retained message associated with the targeted subject is located from the retained message store based on the targeted key value.
Optionally, the topics in the initial topic set are divided into at least one topic group, and the topic group satisfies at least one of the following:
the number of subscribed topics in the topic group is not greater than a first preset value;
the number of the reserved messages associated with the topics contained in the topic group is not greater than a second preset value;
the reading frequency of the reservation messages associated with the topics contained in the topic group is not more than a third preset value;
the writing frequency of the reservation messages associated with the topics contained in the topic group is not more than a fourth preset value;
the frequency of deletion of the retention messages associated with the topics contained in the topic group is not greater than a fifth preset value.
It is understood that the above modules of the processing apparatus for the subscription topic in the embodiment of the present disclosure have functions of implementing the corresponding steps of the processing method for the subscription topic in the embodiment shown in fig. 2. The function can be realized by hardware, and can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the functions described above. The modules may be software and/or hardware, and each module may be implemented separately or implemented by integrating a plurality of modules. For the functional description of each module of the processing apparatus for subscribing to a topic, reference may be specifically made to the corresponding description of processing of a subscription topic in the embodiment shown in fig. 2, and details are not repeated here.
Based on the same principle as the method shown in fig. 3, fig. 5 shows a schematic structural diagram of another processing apparatus for subscribing to a topic provided by the embodiment of the present disclosure, as shown in fig. 5, the processing apparatus 50 for subscribing to a topic may include:
a topic filter obtaining module 510, configured to, in response to receiving a subscription request sent by a subscriber, obtain a topic filter carried in the subscription request;
a first wildcard character determining module 520, configured to sequentially search from a root topic level of the topic filter according to a topic level sequence in the topic filter until a first wildcard character is found;
a first topic set determining module 530, configured to filter, from a preset initial topic set, a first topic set in a topic hierarchy occupied by a first wildcard, based on a topic filtering manner corresponding to a wildcard type of the first wildcard;
a subscription topic determining module 540, configured to determine, based on the first topic set, a target topic subscribed by the subscriber;
and a target reservation message returning module 550, configured to, after determining the target topic subscribed by the subscriber based on the first topic set, determine a target reservation message associated with the target topic from reservation messages stored in a preset reservation message library, and return the target reservation message to the subscriber.
According to the device provided by the embodiment of the disclosure, a topic filter carried in a subscription request is obtained by responding to the received subscription request sent by a subscriber; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until the first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topics subscribed by the subscriber terminal can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topics to the subscriber terminal.
It is understood that the above modules of the processing apparatus for the subscription topic in the embodiment of the present disclosure have functions of implementing the corresponding steps of the processing method for the subscription topic in the embodiment shown in fig. 3. The function can be realized by hardware, and can also be realized by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the functions described above. The modules may be software and/or hardware, and each module may be implemented separately or implemented by integrating a plurality of modules. For the functional description of each module of the processing apparatus for subscription topics, reference may be specifically made to the corresponding description of processing of subscription topics in the embodiment shown in fig. 3, and details are not repeated here.
In the technical scheme of the disclosure, the collection, storage, use, processing, transmission, provision, disclosure and other processing of the personal information of the related user are all in accordance with the regulations of related laws and regulations and do not violate the good customs of the public order.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
The electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executable by the at least one processor to enable the at least one processor to perform a method of processing a subscription topic as provided by an embodiment of the disclosure.
Compared with the prior art, the electronic equipment responds to a received subscription request sent by a subscription terminal to obtain a topic filter carried in the subscription request; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until the first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topic subscribed by the subscriber can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topic to the subscriber.
The readable storage medium is a non-transitory computer readable storage medium storing computer instructions for causing a computer to execute the processing method of subscribing to a topic as provided by the embodiment of the present disclosure.
Compared with the prior art, the readable storage medium responds to a received subscription request sent by a subscription end to acquire a topic filter carried in the subscription request; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until the first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topic subscribed by the subscriber can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topic to the subscriber.
The computer program product includes a computer program, and the computer program realizes the processing method of the subscription theme as provided by the embodiment of the disclosure when being executed by a processor.
Compared with the prior art, the computer program product responds to a received subscription request sent by a subscription terminal to obtain a topic filter carried in the subscription request; according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until the first wildcard is found; screening a first subject set under a subject level occupied by a first wildcard from a preset initial subject set based on a subject screening mode corresponding to a wildcard type of the first wildcard; and determining the target topic subscribed by the subscriber based on the first topic set. Based on the scheme, when the topic filter contains the wildcards, the topics subscribed by the subscriber terminal can be effectively screened out according to the topic filter, and a basis is provided for subsequently returning reservation messages associated with the subscribed topics to the subscriber terminal.
FIG. 6 illustrates a schematic block diagram of an example electronic device 60 that can be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the electronic device 60 includes a computing unit 610 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 620 or a computer program loaded from a storage unit 680 into a Random Access Memory (RAM) 630. In the RAM630, various programs and data required for the operation of the device 60 may also be stored. The computing unit 610, the ROM620, and the RAM630 are connected to each other by a bus 640. An input/output (I/O) interface 650 is also connected to bus 640.
Various components in device 60 are connected to I/O interface 650, including: an input unit 660 such as a keyboard, a mouse, etc.; an output unit 670 such as various types of displays, speakers, and the like; a storage unit 680 such as a magnetic disk, optical disk, or the like; and a communication unit 690 such as a network card, modem, wireless communication transceiver, etc. The communication unit 690 allows the device 60 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server with a combined blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the protection scope of the present disclosure.
Claims (19)
1. A processing method of a subscription topic comprises the following steps:
responding to a received subscription request sent by a subscription end, and acquiring a topic filter carried in the subscription request;
according to the sequence of the theme levels in the theme filter, sequentially searching from the root theme level of the theme filter until a first wildcard is found;
screening a first subject set under a subject level occupied by the first wildcard from a preset initial subject set based on a subject screening mode corresponding to the wildcard type of the first wildcard;
and determining the target topic subscribed by the subscriber based on the first topic set.
2. The method of claim 1, wherein the determining the target topic subscribed to by the subscriber based on the first set of topics comprises:
in response to the first wildcard being a multi-layer wildcard or no other wildcard existing in the topic filter after the first wildcard, determining the first topic set as a target topic subscribed by the subscriber.
3. The method according to claim 1 or 2, wherein the determining a target topic subscribed by the subscriber based on the first topic set comprises:
in response to that a first wildcard is a single-layer wildcard, sequentially searching from a sub-level of a theme level occupied by the first wildcard in the theme filter according to the theme level sequence in the theme filter until a second wildcard is searched;
screening a second subject set under a subject level occupied by the second wildcard from a preset first subject set based on a subject screening mode corresponding to the wildcard type of the second wildcard;
in response to the second wildcard being a multi-layer wildcard or no other wildcard existing after the second wildcard in the topic filter, determining the second topic set as a target topic subscribed by the subscriber;
in response to that the second wildcard is a single-layer wildcard, taking the second wildcard as the first wildcard, taking the second topic set as the first topic set, repeatedly executing the steps of sequentially searching from a sub-level of a topic level occupied by the first wildcard in the topic filter according to the topic level sequence in the topic filter until the second wildcard is found, and screening the second topic set under the topic level occupied by the second wildcard from the preset first topic set based on a topic screening manner corresponding to the wildcard type of the second wildcard until the second wildcard is a multi-layer wildcard or no other wildcard exists behind the second wildcard in the topic filter, and determining the second topic set as a target topic subscribed by the subscriber.
4. The method according to any one of claims 1 to 3, wherein the screening out a first topic set under a topic hierarchy occupied by the first wildcard from a preset initial topic set based on a topic screening manner corresponding to a wildcard type of the first wildcard comprises:
determining candidate topics of which the level identification of a first topic level is matched with a first topic level identification from a preset initial topic set, wherein the first topic level is a parent level of a topic level occupied by the first wildcard in the topic filter, and the first topic level identification is the level identification of the first topic level in the topic filter;
in response to the first wildcard being a single-layer wildcard, determining from the candidate topics a first topic set whose hierarchical identity of a second topic hierarchy matches a second topic hierarchy identity, the second topic hierarchy being a sub-level of the topic hierarchy occupied by the first wildcard in the topic filter, the second topic hierarchy identity being a hierarchical identity of the second topic hierarchy in the topic filter;
in response to the first wildcard being a multi-level wildcard, determining the candidate topic as a first topic set under a topic hierarchy occupied by the first wildcard.
5. The method of claim 4, wherein the topics in the initial topic set are arranged according to an alphabetical order of corresponding topic identifications, and the determining a candidate topic from a preset initial topic set, wherein the hierarchical identification of the first topic hierarchy matches the first topic hierarchy identification, comprises:
searching a first theme matched with the hierarchical identification of the first theme hierarchy from a preset initial theme set;
sequentially searching the first theme according to the arrangement sequence of the themes in the initial theme set until the last theme matched with the hierarchy identifier of the first theme hierarchy is searched;
determining the first topic, the last topic, and all topics in the initial set of topics that are located between the first topic and the last topic as candidate topics that match a first topic hierarchy identification.
6. The method of any of claims 1-5, after the determining a target topic subscribed to by the subscriber based on the first set of topics, the method further comprising:
and determining a target reservation message associated with the target topic from reservation messages stored in a preset reservation message library, and returning the target reservation message to the subscriber.
7. The method of claim 6, wherein the reservation message repository is constructed based on the reservation messages and key values corresponding to the reservation messages, the key values including topic identifications associated with the reservation messages, and wherein determining the targeted reservation message associated with the targeted topic from a preset reservation message repository comprises:
determining a target key value from key values stored in the reserved message library, wherein the target key value comprises a subject identification of the target subject;
and finding out the target reservation message associated with the target subject from the reservation message library based on the target key value.
8. The method of any of claims 1-7, wherein topics in the initial topic set are divided into at least one topic group, the topic group satisfying at least one of:
the number of subscribed topics in the topic group is not greater than a first preset value;
the number of the reserved messages associated with the topics contained in the topic group is not greater than a second preset value;
the reading frequency of the reservation messages associated with the topics contained in the topic group is not more than a third preset value;
the writing frequency of the reservation messages associated with the topics contained in the topic group is not more than a fourth preset value;
the frequency of deletion of the retention messages associated with the topics contained in the topic group is not greater than a fifth preset value.
9. A processing apparatus for subscribing to a topic, comprising:
the topic filter acquisition module is used for responding to a received subscription request sent by a subscription end and acquiring a topic filter carried in the subscription request;
a first wildcard character determining module, configured to search in sequence from a root topic level of the topic filter according to a topic level sequence in the topic filter until a first wildcard character is found;
a first topic set determining module, configured to screen out, from a preset initial topic set, a first topic set in a topic hierarchy occupied by the first wildcard based on a topic screening manner corresponding to a wildcard type of the first wildcard;
and the subscription theme determining module is used for determining the target theme subscribed by the subscriber based on the first theme set.
10. The apparatus of claim 9, wherein the subscription topic determination module is specifically configured to:
in response to the first wildcard being a multi-layer wildcard or no other wildcard existing in the topic filter after the first wildcard, determining the first topic set as a target topic subscribed by the subscriber.
11. The apparatus according to claim 9 or 10, wherein the subscription topic determination module is specifically configured to:
in response to a first wildcard being a single-layer wildcard, sequentially searching from a sub-level of a theme level occupied by the first wildcard in the theme filter according to a theme level sequence in the theme filter until a second wildcard is searched;
screening a second subject set under a subject level occupied by the second wildcard from a preset first subject set based on a subject screening mode corresponding to the wildcard type of the second wildcard;
in response to the second wildcard being a multi-layer wildcard or no other wildcard existing in the topic filter after the second wildcard, determining the second topic set as a target topic subscribed by the subscriber;
in response to that the second wildcard is a single-layer wildcard, taking the second wildcard as the first wildcard, taking the second topic set as the first topic set, repeatedly executing the steps of sequentially searching from a sub-level of a topic level occupied by the first wildcard in the topic filter according to the topic level sequence in the topic filter until the second wildcard is found, and screening a second topic set under the topic level occupied by the second wildcard from a preset first topic set based on a topic screening mode corresponding to the wildcard type of the second wildcard until the second wildcard is a multi-layer wildcard, or determining the second topic set as a target topic subscribed by the subscriber when no other wildcard exists behind the second wildcard in the topic filter.
12. The apparatus of any of claims 9-11, wherein the first topic set determination module is specifically configured to:
determining, from a preset initial topic set, a candidate topic whose level identification matches a first topic level identification, the first topic level being a parent level of a topic level occupied by the first wildcard in the topic filter, the first topic level identification being a level identification of the first topic level in the topic filter;
in response to the first wildcard being a single-layer wildcard, determining from the candidate topics a first topic set whose hierarchical identity of a second topic hierarchy matches a second topic hierarchy identity, the second topic hierarchy being a sub-level of the topic hierarchy occupied by the first wildcard in the topic filter, the second topic hierarchy identity being a hierarchical identity of the second topic hierarchy in the topic filter;
in response to the first wildcard being a multi-level wildcard, determining the candidate topic as a first topic set under a topic hierarchy occupied by the first wildcard.
13. The apparatus according to claim 12, wherein the topics in the initial topic set are arranged in an alphabetical order according to corresponding topic identifiers, and the first topic set determining module, when determining a candidate topic in which a hierarchy identifier of a first topic hierarchy matches a first topic hierarchy identifier from a preset initial topic set, is specifically configured to:
searching a first theme, of which the level identification of the first theme level is matched with the first theme level identification, from a preset initial theme set;
sequentially searching the first theme according to the arrangement sequence of the themes in the initial theme set until the last theme matched with the hierarchy identifier of the first theme hierarchy is searched;
determining the first topic, the last topic, and all topics in the initial set of topics between the first topic and the last topic as candidate topics matching a first topic hierarchy identification.
14. The apparatus of any of claims 9-13, further comprising:
and the target reservation message returning module is used for determining a target reservation message associated with the target topic from reservation messages stored in a preset reservation message library after determining the target topic subscribed by the subscriber based on the first topic set, and returning the target reservation message to the subscriber.
15. The apparatus according to claim 14, wherein the reservation message repository is constructed based on the reservation messages and key values corresponding to the reservation messages, and the targeted reservation message returning module, when determining a targeted reservation message associated with the targeted topic from among the reservation messages stored in the preset reservation message repository, is specifically configured to:
determining a target key value from key values stored in the reserved message library, wherein the target key value comprises a subject identification of the target subject;
and finding out the target reservation message associated with the target subject from the reservation message library based on the target key value.
16. The apparatus of any of claims 9-15, wherein topics in the initial topic set are divided into at least one topic group, the topic group satisfying at least one of:
the number of subscribed topics in the topic group is not greater than a first preset value;
the number of the reserved messages associated with the topics contained in the topic group is not greater than a second preset value;
the reading frequency of the reservation messages associated with the topics contained in the topic group is not more than a third preset value;
the writing frequency of the reservation messages associated with the topics contained in the topic group is not more than a fourth preset value;
the frequency of deletion of the retention messages associated with the topics contained in the topic group is not greater than a fifth preset value.
17. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
18. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-8.
19. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211152514.XA CN115567584A (en) | 2022-09-21 | 2022-09-21 | Processing method and device of subscription theme, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211152514.XA CN115567584A (en) | 2022-09-21 | 2022-09-21 | Processing method and device of subscription theme, electronic equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115567584A true CN115567584A (en) | 2023-01-03 |
Family
ID=84740166
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211152514.XA Pending CN115567584A (en) | 2022-09-21 | 2022-09-21 | Processing method and device of subscription theme, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115567584A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100306264A1 (en) * | 2009-06-02 | 2010-12-02 | International Business Machines Corporation | Optimizing publish/subscribe matching for non-wildcarded topics |
CN110048927A (en) * | 2018-01-16 | 2019-07-23 | 华为技术有限公司 | Communication means and communication device |
US20200195740A1 (en) * | 2017-08-29 | 2020-06-18 | Huawei Technologies Co., Ltd. | Subscribe and publish method and server |
CN111651476A (en) * | 2020-05-18 | 2020-09-11 | 青岛海洋科学与技术国家实验室发展中心 | Quick matching method and system for MQTT theme in gateway of Internet of things |
CN113783838A (en) * | 2021-08-05 | 2021-12-10 | 山东有人物联网股份有限公司 | Subscription method, subscription control device and computer readable storage medium |
-
2022
- 2022-09-21 CN CN202211152514.XA patent/CN115567584A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100306264A1 (en) * | 2009-06-02 | 2010-12-02 | International Business Machines Corporation | Optimizing publish/subscribe matching for non-wildcarded topics |
US20200195740A1 (en) * | 2017-08-29 | 2020-06-18 | Huawei Technologies Co., Ltd. | Subscribe and publish method and server |
CN110048927A (en) * | 2018-01-16 | 2019-07-23 | 华为技术有限公司 | Communication means and communication device |
CN111651476A (en) * | 2020-05-18 | 2020-09-11 | 青岛海洋科学与技术国家实验室发展中心 | Quick matching method and system for MQTT theme in gateway of Internet of things |
CN113783838A (en) * | 2021-08-05 | 2021-12-10 | 山东有人物联网股份有限公司 | Subscription method, subscription control device and computer readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112269789A (en) | Method and device for storing data and method and device for reading data | |
CN109788026B (en) | Message processing method and device | |
CN113961510A (en) | File processing method, device, equipment and storage medium | |
CN112437125B (en) | Information concurrent processing method and device, electronic equipment and storage medium | |
CN115408547A (en) | Dictionary tree construction method, device, equipment and storage medium | |
CN115567584A (en) | Processing method and device of subscription theme, electronic equipment and readable storage medium | |
CN115905322A (en) | Service processing method and device, electronic equipment and storage medium | |
CN115994534A (en) | Government scene hot word mining method, device, equipment and storage medium | |
CN116127154A (en) | Knowledge tag recommendation method and device, electronic equipment and storage medium | |
CN114449031A (en) | Information acquisition method, device, equipment and storage medium | |
CN115525659A (en) | Data query method and device, electronic equipment and storage medium | |
CN115328898A (en) | Data processing method and device, electronic equipment and medium | |
CN114968950A (en) | Task processing method and device, electronic equipment and medium | |
CN114995719A (en) | List rendering method, device, equipment and storage medium | |
CN112860626A (en) | Document sorting method and device and electronic equipment | |
CN114064803A (en) | Data synchronization method and device | |
CN113868373A (en) | Word cloud generation method and device, electronic equipment and storage medium | |
CN115794876A (en) | Fragment processing method, device, equipment and storage medium for service data packet | |
CN113676531A (en) | E-commerce flow peak clipping method and device, electronic equipment and readable storage medium | |
CN113495891A (en) | Data processing method and device | |
CN117729176B (en) | Method and device for aggregating application program interfaces based on network address and response body | |
CN113312549B (en) | Domain name processing method and device | |
CN110795667B (en) | Method, device, equipment and storage medium for determining resources to be pushed | |
CN118445452A (en) | Vector retrieval method, device, equipment and medium | |
CN114417071A (en) | Node state determination method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |