Skip to content
Tim Ebben edited this page May 11, 2016 · 7 revisions

TL;DR

SensorThings MQTT spec is hard to implement using Mosquitto so for now we are not implementing it 100% according to the spec.

To publish a message use GOST as prefix path in the topic, for example to publish a new observation you can send it to the topic:

GOST/Datastreams(1)/Observations

SensorThings MQTT problems and temporarily fixes

We decided to not follow the MQTT SensorThings spec for now cause of some problems: To follow the spec we need to have full control on the MQTT broker, since there is not yet a Golang MQTT broker which is production ready we went with Mosquitto for now which leads to the following problems:

  1. The spec describes topics with the ODATA urls, for example: Datastreams(1)/Observations but we don't want to subscribe to al possible topics. Temp fix: subsribe to # and map the topic from an incoming message to the right handler by filtering out the id part: Datastreams()/Observations -> HandleObservationByDatastream(id), subscribing to # is not a wise idea if the broker is used by more applications, sort of fixed by the temp fix of problem 3.

  2. Subscribing on entity properties RESOURCE_PATH_TO_AN_ENTITY/PROPERTY_NAME + RESOURCE_PATH/COLLECTION_NAME?$select=PROPERTY_1,PROPERTY_2,… This is not possible for now since we can't get a list of subscribed topics from Mosquitto (it is possible by reading logs and sending messages but we don't like this idea) So this is not supported for now.

  3. Subscribe and publish to the same topic Datastreams(1)/Observations leads to receiving unprocessed messages on the clients side. For instance, when a client sends { "result": 18 } to the topic Datastreams(1)/Observations a subscribed client receives this unprocessed info, GOST also receives this message processes it and sends a publish message on Datastreams(1)/Observations which is also received by the subscribed client. For the subscribed client it is only necessary to receive the processed message it also leads to more network traffic and GOST receiving his own published message again (ping/pong effect) Temp fix: publishing messages to post and patch entities need a GOST trailing path so when you want to add a new observation for example you can send it to: GOST/Datastreams(1)/Observations or patch a thing: Gost/Thing(1)

In the future we hope to have a golang powered MQTT broker where we have full control over so we can implement the MQTT extension according to the SensorThings specification.

Clone this wiki locally