What is the difference between the subscribe(..)
methods and the publishes(..)
method(s) in the HiveMQ Java Client library?
When I use subscribe(...)
, I know it will send a SUBSCRIBE to the MQTT broker in some way, but does the same (or similar) happen when I do a publishes(...)
, or is it completely client side?
If the latter, does that mean I could connect to a persistent session and use publishes(...)
to process ANY incoming messages that the broker may have queued up for me? As in, does publishes(...)
automatically get all messages that that client got sent by the broker, without having to explicitly subscribe?
For example, say I have an IoT device that has extremely low bandwidth and power constraints. I turn the device on, it connects, sets up a persistent session, and subscribes to a topic. Then, I turn the device off and then on again. It connects, sees that a persistent session exists, so does NOT subscribe. No messages will be processed by this client now (even though the broker seems to queue them and deliver them), because the subscribe code was what hooked up the callback logic. Is using publishes
the way to get around this? Is there a different way to have that callback logic hooked up without explicitly calling subscribe()
?