Client.unsubscribe() does not work

Hi I am using Mqtt3AsyncClient and the unsubscribe method does not work.

   public void unsubscribeClient(String topic) {
        hiveSubClient.unsubscribe(Mqtt3Unsubscribe.builder().topicFilter(topic).build());
    }

When I use the unsubscribe method with paho client, the topic immediately disappears from topics bound to the queue(using rabbitMQ so the terminology might not 100% match)

 public void unsubscribeClient(String routingKey) {
        try {
            pahoSubClient.unsubscribe(routingKey);
        } catch (MqttException e) {
            throw new RuntimeException(e);
        }
    }

Is the syntax I use correct?

Hello PeNo,

you are using the async API flavour of the HiveMQ MQTT Client. The unsubscribe() method of the async client does intermediately return a CompleteableFuture after sending the UNSUBSCRIBE to the broker. The returned CompleteableFuture only complete when the UNSUBACK is received from the broker.

In order to have the same behaviour as below you can use the blocking API of the HiveMQ MQTT Client:

hiveSubClient.toBlocking().unsubscribe(Mqtt3Unsubscribe.builder().topicFilter(topic).build());

Hi Yannick,
thank you for your reply. Only after you gave me the correct syntax and when it was not working I got the right idea. I am posting this for a future reference if someone uses RabbitMQ MQTT and hive client.

RabbitMQ MQTT topic segmentation works with dot . and translates it under the hood to mqtt / forward slash.

When I subscribe with hiveMQ client the topic must be segmented by /. Eg: instanz1/account1/store1/
However the UI of rabbit displays the segmentation as . Eg: instanz1.account1.store1.

And the same goes for unsubscribe. Unsubscribing with hive client I need to use the forward slash delimiter instanz1/account1/store1/
And it works now