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 devicedirection
indicates 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
Machine
has a propertyfreeMemory
- A
JavaVirtualMachine
is aMachine
- A
JavaVirtualMachine
has an operation calledgc
which runs the garbage collecor There is an instance of a
JavaVirtualMachine
with- id is 42
- is deployed on a host called
myhost
- is running a web app called
mywebapp
- qualifiedName is
/myhost/mywebapp
The
JavaVirtualMachine
42 would publish its free memory on topic/JavaVirtualMachine/42/out/val/Machine/freeMemory/myhost/mywebapp
- In order to receive operation call, the
JavaVirtualMachine
42 would subscibe to topics/JavaVirtualMachine/42/in/op/#
; ifid
is 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 receivefreeMemory
values from any instance ofMachine
/JavaVirtualMachine/+/out/val/Machine/freeMemory/#
to receivefreeMemory
values from any instance ofJavaVirtualMachine
/+/+/out/val/Machine/freeMemory/myhost/#
to receivefreeMemory
values from any instance deployed onmyhost
- An application would publish to
/JavaVirtualMachine/42/in/op/JavaVirtualMachine/gc
to run the gc on JVM 42
Not tested but it should work …