This post is an attempt to define a naming convention for MQTT topic that combines physical and location information.
1 2 3 4 | |
Where
class: the class of the deviceid: the unique id of the devicedirectionindicates the direction of the message'in': the message goes to the device'out': the message goes from the device
command: the command to execute'get': get the value of the feature'set': set the value of the feature'unset': unset the value of the feature'val': send the value of the feature'op': execute an operation on the device
declaringClass: the class in which the feature is declaredfeature: the feature (property or operation)qualifiedName: the fully qualified name of the device
Examples
Machine case
- A
Machinehas a propertyfreeMemory - A
JavaVirtualMachineis aMachine - A
JavaVirtualMachinehas an operation calledgcwhich runs the garbage collecor There is an instance of a
JavaVirtualMachinewith- id is 42
- is deployed on a host called
myhost - is running a web app called
mywebapp - qualifiedName is
/myhost/mywebapp
The
JavaVirtualMachine42 would publish its free memory on topic/JavaVirtualMachine/42/out/val/Machine/freeMemory/myhost/mywebapp- In order to receive operation call, the
JavaVirtualMachine42 would subscibe to topics/JavaVirtualMachine/42/in/op/#; ifidis kind of UUID, it could only subscribe to/+/42/in/#- and to
/+/+/in/op/+/+/myhost/mywebapp
- An application would subscribe to
/+/+/out/val/Machine/freeMemory/#to receivefreeMemoryvalues from any instance ofMachine/JavaVirtualMachine/+/out/val/Machine/freeMemory/#to receivefreeMemoryvalues from any instance ofJavaVirtualMachine/+/+/out/val/Machine/freeMemory/myhost/#to receivefreeMemoryvalues from any instance deployed onmyhost
- An application would publish to
/JavaVirtualMachine/42/in/op/JavaVirtualMachine/gcto run the gc on JVM 42
Not tested but it should work …