Link Search Menu Expand Document Edit GitHub

MQTT Operations

Most MQTT operations provide a fluent builder API or can be called with a prebuilt MQTT message.

  • client.publishWith()
            .topic("test/topic")
            .qos(MqttQos.AT_LEAST_ONCE)
            .payload("payload".getBytes())
            .send();
    
  • Mqtt5Publish publishMessage = Mqtt5Publish.builder()
            .topic("test/topic")
            .qos(MqttQos.AT_LEAST_ONCE)
            .payload("payload".getBytes())
            .build();
    
    client.publish(publishMessage);
    

Some MQTT operations also provide methods without any arguments if no mandatory fields have to be set. Then the default parameters (as defined in the MQTT specification or reasonable defaults if not defined there) will be used.

client.connect();
client.disconnect();

All MQTT operations are safe to be called by different threads.


Table of contents