0

i can't seem to find a way to subscribe to more than just one topic using the .topicfilter("topic/test) . anybody got an idea how to make it subscribe to list of topics ?

joghm
  • 569
  • 3
  • 20

1 Answers1

2

@joghm!

Most certainly - the typical way this is implemented is by using multiple .addSubscription calls within a .subscribeWith().

Here is an example using the HiveMQ MQTT Java client (which I believe is the client in use here) and an MQTT3 client implementation :

mqtt3AsyncClient.subscribeWith()
.addSubscription().topicFilter(“tenant1/topic”).qos(MqttQos.AT_LEAST_ONCE).applySubscription()
.addSubscription().topicFilter(“tenant2/topic”).qos(MqttQos.AT_LEAST_ONCE).applySubscription()
.callback(e -> {})
.send();

More specific details can be found on the HiveMQ Community forum at this link : https://community.hivemq.com/t/subscribe-to-two-different-topics/137.

Please feel free to reach out on the community forum, as well, if there are any further questions regarding HiveMQ's libraries!

Best, Aaron from the HiveMQ Team