In the context of MQTT and pub/sub, let's assume my embedded micro-controller IOT device has a significant number of variables (i.e., various sensors, values, settings, outputs, etc) which can be mapped to "topics".
Is it really necessary to publish (to a broker) on topics if there are no subscribers for the topics?
I'd like to think I have a fairly decent grasp of MQTT, but as I thought through the implementation for this device, this question jumped out at me. It would not be trivial for this device to always publish on all topics.
Typically in this case, a subscriber will be interested in a small subset of topics, not all. It seems very unnecessary to publish on ALL topics if only a small subset are being subscribed to. Why not only publish on topics being subscribed to?
MQTT subscriber clients typically connect to a broker, then send their subscribe message to the broker. I don't see a mechanism by which subscribers can indicate to publishers what topics they are interested in, thereby allowing publishers to only publish on the necessary topics.
Am I misunderstanding a nuance of MQTT, or more generally, pub/sub?