hivemq/hivemq-mqtt-client

How to subscribe with a custom subscription identifier?

andsel opened this issue · 3 comments

andsel commented

Checklist

❓ Question

How can I [...]?
I don't know if it's possible and how set subscription identifier during the subscribe

Is it possible to [...]?
Set a custom subscription identifier when sending a SUBSCRIBE message to the broker

📎 Additional context

subscriber.subscribeWith()
            .topicFilter("/metric/temperature/#")
// --> how to configure here the subscription identifier?
            .send();

Hi @andsel - there is no API for this - this client has been built to manage subscription identifiers automatically internally when it's supported by the broker.

Not all brokers support subscription identifiers (HiveMQ does) so support has to be checked in the CONNACK connect response.

Managing IDs (and their re-use) can be cumbersome when dealing with a lot of subscriptions.

What's your use case/problem to solve? Maybe we can find an alternative solution...

Hi @pglombardo
I'm writing the MQTT 5 support in Moquette broker and using HiveMQ client to create integration tests, in particular I was writing the test to proof the subscription identifier so I was wondering how to value that mqtt property in the the subscribe.
You answered my question, when I'll enable the subscription identifier capability in CONNACK I'll start seeing the subscriptions using it.

Thanks! 👍

Excellent - let me know if you have any issues.