Monday, May 11, 2015

MQTT - Topics - Part II


A Topic forms the namespace. 
- Topic is  hierarchical with each “sub topic” separated by / 
- An example topic space 

A house publishes information about itself on
- / / / //energyConsumption 
- / / / / / solarEnergy 
- / / / / / alarmState
- / / / / / solarEnergy 
And it subscribes for control commands 
- / / / / / thermostat / setTemp 

A subscriber can subscribe to an absolute topic or can use wildcards. 
- Single level wildcards “+” can appear anywhere in the topic string 
- Mutli level wildcards “#” must appear at the end of the string 
- Wildcards must be next to a separator 
- Canot be used wildcards when publishing 

For example 
- India/KA/Bangalore/560100/1/energyconsumption
Energy consumption for 1 house in Bangalore
- India/KA/Bangalore/+/+/energyconsumption
Energy consumption of all houses in Bangalore
- India/KA/Bangalore/560100/# 

Details of Energy consumption, solar and alarm for all houses in 560100 

A subscription can be durable or non durable. 
Durable 
Once the subscription is in place, the broker will forward matching messages to the subscriber. 
Immediately if the subscriber is connected
If the subscriber is not connected, the messages are stored on the server/broker until the next time the subscriber connects. 
Non-Durable 
The subscription lifetime is the same as the time the subscriber is connected to the server / broker. 

A publication may be retained
- A publisher can mark a publication as retained. 
- The broker remembers the last known good message of a retained topic. 
- The broker gives the last known good message to new subscribers 

i.e. the new subscriber does not have to wait for a publisher to publish a message in order to receive its first message. 

references: 

No comments:

Post a Comment