2

I have a HiveMQ MQTT server that I am running. When I connect using MQTT explorer I can see all of the topics and sub-topics. However, I can't seem to find a way to recreate this with the HiveMqtt Java SDK. I can subscribe to /# but that only works if the device sends a message after subscribed. I want to on boot cache all of the currently available topics.

Is this possible so I don't have to manually maintain a list?

Jackie
  • 131
  • 4

1 Answers1

1

There is no topic list, brokers don't work that way.

Topics only exist on published messages, brokers don't have a "list of topics".

What brokers do have is a list of topic patterns, one for every subscription, but these can include wildcards that can match many infinitely many different topics.

The same applies to the ACL that controls which topics a client can publish to, this is also a list of topic patterns that can include the same wildcards.

Also just as a side note, just because a message has once been published to a topic doesn't mean that another ever will be.

Any client that appears to show a topic tree at start up must be caching a list of previously seen messages and updating it as new messages are published. This might look like a "full topic tree" if the applications making use of the broker publish retained message as all those messages would be delivered on connection.

hardillb
  • 12,813
  • 1
  • 21
  • 34