Is there a built in way to check with hivemq-mqtt-client if a specific topic matches another topic in advance?
For instance, a message published with topic:
publishedTopic= "sensors/sensor1";
A client that subscribes:
subscribedTopic = "sensors/#";
Is there something like
publishedTopic.matches(subscribedTopic)
?
The exact situation:
I run a broker in my house, several devices publish values with different topics. Some like sensor/humi[45], some like sensor/data[JSON Payload]. For my personal use I run an application using Java HiveQM MQTT clients. One client is subscribed to relevant topics using mosquitto on raspberryPi. The other client is publishing selected data to a public accessible broker. Receiving a new message will not only process all data in the way I process it but also trigger a publishing the received message to the public broker.
Yes, I can
if(topic.equals("sensor/xxx")) {
//publish to public broker here
}
But doing some like subscribing to "sensor/#", from my internal broker, and "forwarding" something like "sensor/+", and letting a library doing the job of determining if a certain message that is received with "sensors/#", will be republished to the public broker, limited to "sensors/+" is what I am looking for.
Is the logic inside HiveMQ mqtt-client library, which obviously filters in that exact way, when I subscribe to "sensors/#", accessible for the library user?
sensors/#
on BrokerA and you want to forwardsensors/sensor1
but notsensors/sensors2
e.g.? And what is meant by "forward" - republish this topic from your client to BrokerB? – Odysseus