as1 (application server 1) -is the user name chosen in chapter 1
service1 - this can be freely defined
SUBSCRIPTIONS: External server (here application server as1) subscribes to the broker for chosen topics, few examples below:
PUBLISHING: Server requests location for particular HS:
NOTIFICATIONS: Our system can send additionally notification after the response - in case other devices/modules interested. Topic examples:
External clients could follow our internal rule regarding publishing ready message with status true/false every time when they connect/disconnect.
According to the MQTT 3.1.1 specification, the broker must distribute the last will message of a client in the following situations:
a) The broker detects an I/O error or network failure.
b) The client fails to communicate within the defined Keep Alive period.
c) The client does not send a DISCONNECT packet before it closes the network connection.
d) The broker closes the network connection because of a protocol error.
Example:
When service1 ready then application server (as1) sends: as1/service1/system/ready/noti/rpc {"clientId":"as1/service1","status":true} and when disconnected unexpectedly (message sent by broker): as1/service1/system/ready/noti/rpc {"clientId":"as1/service1","status":false} |
Additional notes:
A retained message is a normal MQTT message with the retained flag set to true. The broker stores the last retained message and the corresponding QoS for that topic. Each client that subscribes to a topic pattern that matches the topic of the retained message receives the retained message immediately after they subscribe. The broker stores only one retained message per topic.
A Quality of Service Level (QoS) for the messages. The level (0,1 or 2) determines the guarantee of a message reaching the other end (client or broker). Currently we use QoS = 0, but we need to consider level 1 or 2 in case of messages which come from application server.
There are 3 QoS levels in MQTT:
QoS Level | Description | Usage |
0 | It guarantees a best effort delivery. A message won’t be acknowledged by the receiver or stored and redelivered by the sender. This is often called “fire and forget” and provides the same guarantee as the underlying TCP protocol. |
|
1 | It is guaranteed that a message will be delivered at least once to the receiver. But the message can also be delivered more than once. The sender will store the message until it gets an acknowledgement from the receiver. |
|
2 | It guarantees that each message is received only once by the counterpart. It is the safest and also the slowest quality of service level. The guarantee is provided by two flows there and back between sender and receiver. |
|
Important !
Messages may be sent at any QoS level, and clients may attempt to subscribe to topics at any QoS level. This means that the client chooses the maximum QoS it will receive. For example, if a message is published at QoS 2 and a client is subscribed with QoS 0, the message will be delivered to that client with QoS 0. If a second client is also subscribed to the same topic, but with QoS 2, then it will receive the same message but with QoS 2. For a second example, if a client is subscribed with QoS 2 and a message is published on QoS 0, the client will receive it on QoS 0.
Higher levels of QoS are more reliable, but involve higher latency and have higher bandwidth requirements.
Additional notes: