I have a question about subscriptions in Paho and how applications can manage disparate topics (allowing for wildcards). We're interested because we're providing a layer to manage all this stuff to both simplify life for the developers and so we can later use non-MQTT pub/sub under the covers if desired.
An example is probably the best way to explain. Let's say we have two separate modules in our program:
get_all_info()
subscribes for a short time to the topicfleet/vehicle-N/#
to get all information for a specific vehicleN
.speed_mon()
, interested only in the speed of all vehicles, subscribes tofleet/+/speed
for the duration of the program.
Consider the sequence(a):
speed_mon()
subscribes tofleet/+/speed
.get_all_info()
subscribes tofleet/vehicle-17/#
and gets information.get_all_info()
unsubscribes tofleet/vehicle-17/#
.
Will the third operation affect the first? In other words, will we still get messages of topic fleet/vehicle-17/speed
?
If the unsubscribe is a simple reversal of a specific subscription, it will disable only the subscription created in the second bullet point.
If it uses the filter to disable all matching subscriptions (in the sense of wildcards), it will affect the first subscription as well.
(a) Ignore the fact for now that we would be better off with get_all_info()
subscribing to fleet/#
for the duration of the program and never unsubscribing, instead just caching messages into local storage. This is a contrived example. We have no control over how clients will use our layer.