Method and apparatus for distributing publish-subscribe messages
阅读说明:本技术 用于分发发布-订阅消息的方法和装置 (Method and apparatus for distributing publish-subscribe messages ) 是由 C·多纳 于 2017-10-06 设计创作,主要内容包括:用于使用消息代理器通过网络将发布-订阅消息分发到客户端的方法和装置。第一客户端被配置成向消息代理器发送消息,以将第二客户端声明为其继任者。消息代理器被配置成当第一客户端与消息代理器断开连接时,将被指示为传递到第一客户端的一个或多个消息路由到第二客户端。第二客户端然后可以取代第一客户端接收和处理这些消息。(Methods and apparatus for distributing publish-subscribe messages to clients over a network using a message broker. The first client is configured to send a message to the message broker to declare the second client as its successor. The message broker is configured to route one or more messages indicated as delivered to the first client to the second client when the first client is disconnected from the message broker. The second client may then receive and process these messages in place of the first client.)
1. A method for distributing publish-subscribe messages to clients over a network using a message broker, the method comprising:
the message broker receiving a message from the first client identifying the second client as a successor to the first client;
determining that the first client is disconnected from the message broker; and is
In response to determining that the first client is disconnected from the message broker, the message broker routes one or more messages identified for transmission to the first client to the second client.
2. The method of claim 1, wherein determining that the first client is disconnected from the message broker comprises determining that the first client is improperly disconnected from the message broker.
3. The method of claim 1 or claim 2, wherein one or more messages are message queue telemetry messages.
4. A method as claimed in any preceding claim, prior to receiving from the first client a message identifying the second client, comprising:
receiving a message from the second client indicating availability of the second client for receiving messages identified for transmission to other clients; and is
An indication of availability of a second client for receiving one or more messages intended for transmission to the first client is sent to the first client.
5. The method of claim 4, wherein the message from the second client includes a vendor ID of the second client, and sending the indication of the availability of the second client to the first client is performed in response to determining that the vendor ID of the second client matches the vendor ID of the first client.
6. The method of claim 4 or claim 5, comprising:
in response to receiving a polling message from a first client to poll one or more clients to determine availability of the one or more clients to receive one or more messages intended for transmission to the first client, an indication of availability of a second client is sent to the first client.
7. A method as claimed in any preceding claim, wherein the one or more messages are identified for transmission to the first client by an indication of a subscription of the first client to a category of the one or more messages, wherein the indication is stored by the message broker.
8. A method as claimed in any preceding claim, wherein the message from the first client identifying the second client comprises a media access control address of the second client.
9. A method for controlling distribution of a publish-subscribe message to a client, the method comprising:
the first client sends a message to the message broker identifying the second client as a successor to the first client, the message including instructions to the message broker to route one or more messages identified for transmission to the first client to the second client in response to the message broker determining that the first client is disconnected from the message broker.
10. A computer program comprising instructions such that, when the computer program is executed on a computing device, the computing device is arranged to perform the steps of any of claims 1 to 9.
11. A message broker configured to distribute publish-subscribe messages to clients, the message broker comprising at least one processor and at least one memory including computer program code, the at least one memory and the computer program code configured, with the at least one processor, to cause the message broker to at least:
determining that a first client of a message broker is disconnected from the message broker; and is
One or more messages identified for transmission to the first client are routed to a second client identified as successors to the first client in messages from the first client identifying the second client in response to determining that the first client is disconnected from the message broker.
12. A first client device configured to control distribution of publish-subscribe messages to clients, the first device comprising at least one processor and at least one memory including computer program code, the at least one memory and the computer program code configured, with the at least one processor, to cause the first client to at least:
sending a message to the message broker identifying the second client as a successor to the first client, the message including instructions to the message broker to route one or more messages identified for transmission to the first client to the second client in response to the message broker determining that the first client is disconnected from the message broker.
Technical Field
The present disclosure relates to methods and apparatus for distributing publish-subscribe messages to clients over a network using a message broker.
Background
A communication system may be seen as a facility that enables communication between two or more devices, such as user equipment, machine-like terminals, servers or other nodes, by providing communication channels for carrying information between the two or more devices. A communication system may be provided, for example, by a communication network and one or more compatible communication devices. The communication may comprise, for example, communication of data for carrying voice data, electronic mail (email), text messages, multimedia and/or content data, and so on.
One particular model that may be implemented for exchanging messages between devices is a publish-subscribe model.
Disclosure of Invention
According to a first aspect, there is provided a method for distributing a publish-subscribe message to a client over a network using a message broker, the method comprising: a message broker that receives a message from a first client identifying a second client as a successor to the first client; determining that the first client is disconnected from the message broker; and in response to determining that the first client is disconnected from the message broker, the message broker routes one or more messages identified for transmission to the first client to the second client.
In some examples, determining that the first client is disconnected from the message broker includes determining that the first client is improperly disconnected from the message broker.
In some examples, the one or more messages are message queue telemetry messages.
In some examples, a method includes, prior to receiving a message from a first client identifying a second client, receiving a message from the second client indicating availability of the second client for receiving messages identified for transmission to other clients; and sending, to the first client, an indication of availability of the second client for receiving one or more messages intended for transmission to the first client.
In some examples, the message from the second client includes a vendor ID of the second client, and sending the indication of the availability of the second client to the first client is performed in response to determining that the vendor ID of the second client matches the vendor ID of the first client.
In some examples, a method comprises: in response to receiving a polling message from a first client to poll one or more clients to determine availability of the one or more clients to receive one or more messages intended for transmission to the first client, an indication of availability of a second client is sent to the first client.
In some examples, the one or more messages are identified for transmission to the first client by an indication of a subscription of the first client to a category of the one or more messages, wherein the indication is stored by the message broker.
In some examples, the message from the first client identifying the second client includes a media access control address of the second client.
According to a second aspect, there is provided a method for controlling distribution of publish-subscribe messages to clients, the method comprising: the first client sends a message to the message broker identifying the second client as a successor to the first client, the message including instructions to the message broker to route one or more messages identified for transmission to the first client to the second client in response to the message broker determining that the first client is disconnected from the message broker.
According to a third aspect, there is provided a computer program comprising instructions such that, when the computer program is executed on a computing device, the computing device is arranged to perform the steps of the first or second aspect.
According to a fourth aspect, there is provided a message broker configured to distribute publish-subscribe messages to clients, the message broker comprising at least one processor and at least one memory including computer program code, the at least one memory and the computer program code configured, with the at least one processor, to cause the message broker to at least: determining that a first client of a message broker is disconnected from the message broker; and routing one or more messages identified for transmission to the first client to a second client identified as successors to the first client in messages from the first client identifying the second client in response to determining that the first client is disconnected from the message broker.
According to a fifth aspect, there is provided a first client device configured to control distribution of a publish-subscribe message to a client, the first device comprising at least one processor and at least one memory including computer program code, the at least one memory and the computer program code configured, with the at least one processor, to cause the first client to at least: sending a message to the message broker identifying the second client as a successor to the first client, the message including instructions to the message broker to route one or more messages identified for transmission to the first client to the second client in response to the message broker determining that the first client is disconnected from the message broker.
Drawings
To assist in understanding the present disclosure and to show how the examples may be carried into effect, reference is made, by way of example, to the accompanying drawings, in which:
FIG. 1 schematically illustrates an example of a publish-subscribe communications system;
fig. 2 schematically shows an example of a communication device;
FIG. 3 schematically illustrates an example of a publish-subscribe communications system;
FIG. 4 illustrates an example of client-related data stored in a message broker;
fig. 5 illustrates an example method performed at a message broker in accordance with an example of the present disclosure;
fig. 6 illustrates an example method performed at a first client according to an example of the present disclosure;
fig. 7 illustrates an example method performed at a second client according to an example of the present disclosure; and
figure 8 schematically illustrates an example of a publish-subscribe communications system.
Detailed Description
In this specification, for convenience and convention, reference will be made to "client," "publisher," "subscriber," "message broker," and the like, with the understanding that, unless the context requires otherwise, this refers to "client device," "publisher device," "subscriber device," "message broker device," and the like.
As previously mentioned, one particular model that may be implemented for exchanging messages between devices is the so-called publish-subscribe model. Here, a client sending a message does not do so by programming a message to be sent directly to a particular receiver, as is common in many communication systems. Instead, when a client, known as a publisher, sends a message, the client programs the message to be sent with an indication of the particular "category" (or "topic") to which the message belongs. Messages are sent by publishers to a message broker that includes a list of all clients known as subscribers that have registered subscriptions to particular categories of messages sent by publishers. The message broker then sends the message to the subscribers indicated as that category. To register a subscription for a particular category of message, the client may send a subscribe message to the message broker, which will then store an indication that the client subscribes to receive messages of that category and forward any future messages received from publishers to the client.
One protocol that is often used for publish-subscribe messaging is the Message Queue Telemetry Transport (MQTT) protocol, which is a lightweight messaging protocol for use on top of the TCP/IP protocol. MQTT is specifically designed for constrained devices and low bandwidth, high latency or unreliable networks. The design principle is to minimize network bandwidth and device resource requirements while also trying to ensure reliability and a certain degree of delivery assurance. These principles also prove to make the protocol ideal for the emerging "machine-to-machine" (M2M) or "internet of things" world of connected devices, as well as for mobile applications where bandwidth and battery power are at a premium.
Generally, as used herein, an IoT device is a device that has an addressable interface (e.g., an Internet Protocol (IP) address, a bluetooth Identifier (ID), a Near Field Communication (NFC) ID, etc.) and is capable of sending information to one or more other devices over a wired or wireless connection. IoT devices may generally include or be incorporated into, for example, refrigerators, ovens, microwave ovens, freezers, dishwashers, washers, dryers, furnaces, air conditioners, thermostats, televisions and other consumer electronics, light fixtures, dust collectors, sprinklers, electricity meters, gas meters, and the like. IoT devices may be deployed in locations or situations where there is no mains power supply or where IoT devices may not be suitable for mains power supply, including, for example, where IoT devices are sensors for temperature, humidity, pressure, light level, pollution, etc.
In some cases, in a publish-subscribe system, a client may be improperly disconnected from a message broker. However, the message broker may still receive messages of the category to which the improperly disconnected client is subscribed. The message broker may simply discard such information intended for the client. However, this information will then be unprocessed.
Before explaining examples in detail, certain general principles of a publish-subscribe communications system and suitable communications devices are briefly explained with reference to fig. 1 and 2 to aid in understanding the techniques of the examples described below.
Figure 1 illustrates a publish/subscribe communications system. The
The
The category indicated by the received message provides the key to delivering the message (publication) between the publisher and subscriber. The broker is configured to match a string category on a published message with a list of clients subscribed to receive messages that include the string category. A list of clients for each message category may be stored in
In one example, a client device may send a subscription request message specifying that it wishes to receive messages of a string category that includes categories such as "temperature", "pressure", "humidity", "luminous intensity", and the like. The message broker may receive such a message at the interface and process the message at the controller to determine that the list of client devices registered for the string category "temperature" should be updated in the
Assume that the
An example client device will now be described in more detail with reference to fig. 2, which shows a schematic partial cross-sectional view of a wireless communication device 200.
Client device 200 may be, for example, a mobile device (i.e., a device that is not fixed to a particular location), or may be a fixed device. The wireless device may or may not require human interactive communication, for example being an MTC device.
The client device 200 may receive signals over the air or radio interface 207 via suitable means for receiving and may transmit signals via suitable means for transmitting radio signals. In fig. 2, an interface that may include a transceiver device is schematically indicated by
The client device 200 is typically provided with at least one
The client 200 may be configured to communicate with the message broker according to the MQTT protocol. The
Referring again to fig. 1, problems may arise when a client device, such as
One proposal for the case when a client device is disconnected from a message broker is to store any messages to be sent to the client device in the message broker. When the client device reconnects to the message broker, the message broker sends the stored message to the client device. However, in this case, the stored message will not be processed until the client device reconnects. In addition, storing messages in the message broker requires additional storage space.
Another proposal is to notify other clients of an improperly disconnected client by publishing a particular category/topic to the client. This is a precaution against accidents. However, this proposal does not address the problem of how to handle messages intended for transmission to an improperly disconnected client. A message indicating that the client has disconnected may be declared on the specification message category. But other clients will not have access to the topic or notice the topic.
Thus, there is a problem that arises when a client in a publish-subscribe messaging system disconnects from a message broker, particularly in situations where the client is improperly disconnected from the message broker.
In examples described herein, a method of distributing publish-subscribe messages is provided in which, when a first client device is disconnected from a message broker, the message broker is configured to send a message indicated to be transmitted to the first client device to a second client device that has been designated as a successor to the first client device. The first client device may designate the second client device as the successor by issuing a particular message (as explained below) to the message broker. The statement may be made generally at any stage of the MQTT connection. A second client device, which has been designated as a successor to the first client device, may then receive these messages from the message broker and process them. Thus, messages intended for the first client device may be received and processed by the second client device even before the first client device reconnects to the message broker. Thus, there is no need to store messages at the message broker until the client device reconnects, since the examples provide inheritance or legacy for the message to route or redistribute the message of the disconnected client to another client. The client devices can autonomously reorganize the message flow between them in case of an improper disconnection. This defined inheritance or legacy mechanism will help the system not to drop any urgent packets even if disconnection of the client device occurs, for example.
An example of a process of establishing a successor for a first client device will now be explained with reference to fig. 3. Fig. 3 illustrates messages exchanged between the
The
The
The
The
When the message broker determines one or more potential successors for the first client, the message broker is configured to send a
The
Because of the agent-oriented message distribution nature of the MQTT protocol, there is no need to send a successor setup (success) message to all other clients. This may be possible, for example, to collect data only between ancestors and successors. Instead of broadcasting the received successor setup message to all other nodes, the message broker will have a database for the ancestor and successor to determine whether to route the incoming message to the ancestor client (i.e., the first client in this example) or to the successor client (i.e., the second client in this example).
Referring to fig. 4, an example of
The
Referring to fig. 5, an example of a method that may be performed in a message broker is shown. The skilled person will appreciate that not all steps in the method are necessary and in some embodiments one or more steps may be omitted.
At S502, the
At S504, the message broker receives a message from the
At S506, the
At S508, the
At S510, the message broker receives one or more messages from a third client device acting as a publisher. These messages are indicated as being transmitted to the
At S512, the
At S514, if it is determined that the
At S516, if it is determined that the
Referring to fig. 6, an example of a
At S602, the
At S604, the
At S606, the
At S608, the
Referring to fig. 7, a method that may be performed at a successor client (in this example, second client 302) is illustrated. The skilled person will appreciate that not all steps in the method are necessary and in some embodiments one or more steps may be omitted.
At S702, the
At S704, the
Referring to fig. 8, a publish-subscribe communications system is schematically illustrated. The figure also shows a
The message represented by the numeral (1) shown in the figure represents a notification/subscription message (e.g., notification ancestor, subscriber successor, successor data, set successor) sent from
It will be appreciated that the processor or processing system or circuitry referred to herein may in fact be provided by a single chip or integrated circuit or multiple chips or integrated circuits, optionally arranged as a chipset, Application Specific Integrated Circuit (ASIC), Field Programmable Gate Array (FPGA), Digital Signal Processor (DSP), Graphics Processing Unit (GPU) or the like. One or more chips may include circuitry (and possibly firmware) for embodying at least one or more of one or more data processors and one or more digital signal processors, the circuitry being configurable so as to operate in accordance with the illustrative examples. In this regard, the illustrative examples may be implemented, at least in part, by computer software stored in a (non-transitory) memory and executed by a processor or by hardware or by a combination of tangibly stored software and hardware (and tangibly stored firmware).
Reference is made herein to data storage for storing data. This may be provided by a single device or by a plurality of devices. Suitable devices include, for example, hard disks and non-volatile semiconductor memories.
Although reference has been made in the description to a message queue telemetry transmission protocol, the skilled person will appreciate that this is merely an example and that some examples of the disclosure may involve the use of other protocols.
The examples described herein are to be understood as illustrative examples of embodiments of the invention. Further embodiments and examples are contemplated. Any feature described in relation to any one example or embodiment may be used alone or in combination with other features. In addition, any feature described in relation to any one example or embodiment may also be used in combination with any other feature or features of any other example or embodiment, or any combination of any other of examples or embodiments. Furthermore, equivalents and modifications not described herein may also be employed within the scope of the invention as defined in the claims.
- 上一篇:一种医用注射器针头装配设备
- 下一篇:对本地网络上的数据存储系统的访问的基于云的管理