drogue-iot / drogue-cloud

Cloud Native IoT
https://drogue.io
Apache License 2.0
114 stars 30 forks source link

MQTT Integration should have a richer topic structure #263

Open JulianFeinauer opened 2 years ago

JulianFeinauer commented 2 years ago

Currently, when using the mqtt integration one acn only subscripe all messages in one app or none. But it would be beneficial in many scenarios to get only a substream of the messages, e.g. only from one device. So it would be helpful to allow an alternative subscription topic "tree" which contains e..g the partition key or the subject of the messages. Then one could use the MQTT topic filter semantics to narrow down the messages one wants to receive.

ctron commented 2 years ago

That is true. But, having all messages/events in a single Kafka stream might make this tricky and provide a false impression of what is going on in the system.

With Kafka it is "all or nothing", so if you would filter for a single device, you would need to consume all messages and throw away all the other events.

However, there are a few use cases where we would like to have a similar feature.

The latter one might be the most complicated. And I am not sure if the IoT connectivity layer is the right location for this. Or if it wouldn't be better to implement this in a digital twin layer. Where one could filter in something like a "virtual topic hierarchy", which maps to the digital twin space.

The other two use-cases could be implemented in some kind of pre-configured rule, which would define how messages will be delivered. Something like "if message is for firmware update, deliver to kafka topic X". Which would: 1) create a new kafka topic for the user/application 2) direct all matching messages to this topic 3) but keep them off the main event stream (which would also hide them from the MQTT integration).

JulianFeinauer commented 2 years ago

Hey Jens, i agree with your general analysis although one also has to distinguish between the Kafka messages that drogue has to consume and then the generated MQTT messages that have to be transferred to the client.

So i agree with your analysis but still think it could be worthwhile to have some kind of server side filtering.