Class MqttClient

java.lang.Object
io.vertx.mutiny.mqtt.MqttClient
All Implemented Interfaces:
MutinyDelegate

public class MqttClient extends Object implements MutinyDelegate
An MQTT client

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

See Also:
  • MqttClient
  • Field Details

  • Constructor Details

    • MqttClient

      public MqttClient(io.vertx.mqtt.MqttClient delegate)
      Create a new instance of MqttClient delegating to the given (non-null) instance of MqttClient.
    • MqttClient

      public MqttClient(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.mqtt.MqttClient getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate instance
    • connect

      @CheckReturnValue public io.smallrye.mutiny.Uni<MqttConnAckMessage> connect(int port, String host)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.connect(int, String)
    • connectAndAwait

      public MqttConnAckMessage connectAndAwait(int port, String host)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method returns a MqttConnAckMessage. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      Returns:
      The operation result
      See Also:
      • MqttClient.connect(int, String)
    • connectAndForget

      public MqttClient connectAndForget(int port, String host)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method ignores the MqttConnAckMessage result or any failure.

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.connect(int, String)
    • connect

      @CheckReturnValue public io.smallrye.mutiny.Uni<MqttConnAckMessage> connect(int port, String host, String serverName)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      serverName - the SNI server name
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.connect(int, String, String)
    • connectAndAwait

      public MqttConnAckMessage connectAndAwait(int port, String host, String serverName)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method returns a MqttConnAckMessage. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      serverName - the SNI server name
      Returns:
      The operation result
      See Also:
      • MqttClient.connect(int, String, String)
    • connectAndForget

      public MqttClient connectAndForget(int port, String host, String serverName)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method ignores the MqttConnAckMessage result or any failure.

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      serverName - the SNI server name
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.connect(int, String, String)
    • connect

      @CheckReturnValue public io.smallrye.mutiny.Uni<MqttConnAckMessage> connect(int port, String host, String serverName, Map<String,String> userProperties)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      serverName - the SNI server name
      userProperties - Connect User Properties
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.connect(int, String, String, Map)
    • connectAndAwait

      public MqttConnAckMessage connectAndAwait(int port, String host, String serverName, Map<String,String> userProperties)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method returns a MqttConnAckMessage. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      serverName - the SNI server name
      userProperties - Connect User Properties
      Returns:
      The operation result
      See Also:
      • MqttClient.connect(int, String, String, Map)
    • connectAndForget

      public MqttClient connectAndForget(int port, String host, String serverName, Map<String,String> userProperties)
      Connects to an MQTT server calling connectHandler after connection

      Unlike the bare Vert.x variant, this method ignores the MqttConnAckMessage result or any failure.

      Parameters:
      port - port of the MQTT server
      host - hostname/ip address of the MQTT server
      serverName - the SNI server name
      userProperties - Connect User Properties
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.connect(int, String, String, Map)
    • disconnect

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> disconnect()
      Disconnects from the MQTT server

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.disconnect()
    • disconnectAndAwait

      public void disconnectAndAwait()
      Disconnects from the MQTT server

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • MqttClient.disconnect()
    • disconnectAndForget

      public MqttClient disconnectAndForget()
      Disconnects from the MQTT server

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.disconnect()
    • publish

      @CheckReturnValue public io.smallrye.mutiny.Uni<Integer> publish(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain)
      Sends the PUBLISH message to the remote MQTT server

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topic - topic on which the message is published
      payload - message payload
      qosLevel - QoS level
      isDup - if the message is a duplicate
      isRetain - if the message needs to be retained
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.publish(String, Buffer, MqttQoS, boolean, boolean)
    • publishAndAwait

      public Integer publishAndAwait(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain)
      Sends the PUBLISH message to the remote MQTT server

      Unlike the bare Vert.x variant, this method returns a Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topic - topic on which the message is published
      payload - message payload
      qosLevel - QoS level
      isDup - if the message is a duplicate
      isRetain - if the message needs to be retained
      Returns:
      The operation result
      See Also:
      • MqttClient.publish(String, Buffer, MqttQoS, boolean, boolean)
    • publishAndForget

      public MqttClient publishAndForget(String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain)
      Sends the PUBLISH message to the remote MQTT server

      Unlike the bare Vert.x variant, this method ignores the Integer result or any failure.

      Parameters:
      topic - topic on which the message is published
      payload - message payload
      qosLevel - QoS level
      isDup - if the message is a duplicate
      isRetain - if the message needs to be retained
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.publish(String, Buffer, MqttQoS, boolean, boolean)
    • publish

      @CheckReturnValue public io.smallrye.mutiny.Uni<Integer> publish(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain)
      Sends the PUBLISH message to the remote MQTT server with a specific message ID

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      id - the message ID
      topic - topic on which the message is published
      payload - message payload
      qosLevel - QoS level
      isDup - if the message is a duplicate
      isRetain - if the message needs to be retained
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.publish(int, String, Buffer, MqttQoS, boolean, boolean)
    • publishAndAwait

      public Integer publishAndAwait(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain)
      Sends the PUBLISH message to the remote MQTT server with a specific message ID

      Unlike the bare Vert.x variant, this method returns a Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      id - the message ID
      topic - topic on which the message is published
      payload - message payload
      qosLevel - QoS level
      isDup - if the message is a duplicate
      isRetain - if the message needs to be retained
      Returns:
      The operation result
      See Also:
      • MqttClient.publish(int, String, Buffer, MqttQoS, boolean, boolean)
    • publishAndForget

      public MqttClient publishAndForget(int id, String topic, io.vertx.core.buffer.Buffer payload, io.netty.handler.codec.mqtt.MqttQoS qosLevel, boolean isDup, boolean isRetain)
      Sends the PUBLISH message to the remote MQTT server with a specific message ID

      Unlike the bare Vert.x variant, this method ignores the Integer result or any failure.

      Parameters:
      id - the message ID
      topic - topic on which the message is published
      payload - message payload
      qosLevel - QoS level
      isDup - if the message is a duplicate
      isRetain - if the message needs to be retained
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.publish(int, String, Buffer, MqttQoS, boolean, boolean)
    • publishRelease

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> publishRelease(int publishMessageId)
      Sends the PUBREL message to the remote MQTT server. This can be used when a PUBREL message expires

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      publishMessageId - identifier of the PUBLISH message to acknowledge
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.publishRelease(int)
    • publishReleaseAndAwait

      public void publishReleaseAndAwait(int publishMessageId)
      Sends the PUBREL message to the remote MQTT server. This can be used when a PUBREL message expires

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      publishMessageId - identifier of the PUBLISH message to acknowledge
      See Also:
      • MqttClient.publishRelease(int)
    • publishReleaseAndForget

      public MqttClient publishReleaseAndForget(int publishMessageId)
      Sends the PUBREL message to the remote MQTT server. This can be used when a PUBREL message expires

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      publishMessageId - identifier of the PUBLISH message to acknowledge
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.publishRelease(int)
    • subscribe

      @CheckReturnValue public io.smallrye.mutiny.Uni<Integer> subscribe(String topic, int qos)
      Subscribes to the topic with a specified QoS level

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topic - topic you subscribe on
      qos - QoS level
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.subscribe(String, int)
    • subscribeAndAwait

      public Integer subscribeAndAwait(String topic, int qos)
      Subscribes to the topic with a specified QoS level

      Unlike the bare Vert.x variant, this method returns a Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topic - topic you subscribe on
      qos - QoS level
      Returns:
      The operation result
      See Also:
      • MqttClient.subscribe(String, int)
    • subscribeAndForget

      public MqttClient subscribeAndForget(String topic, int qos)
      Subscribes to the topic with a specified QoS level

      Unlike the bare Vert.x variant, this method ignores the Integer result or any failure.

      Parameters:
      topic - topic you subscribe on
      qos - QoS level
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.subscribe(String, int)
    • subscribe

      @CheckReturnValue public io.smallrye.mutiny.Uni<Integer> subscribe(Map<String,Integer> topics)
      Subscribes to the topics with related QoS levels

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topics - topics and related QoS levels to subscribe to
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.subscribe(Map)
    • subscribeAndAwait

      public Integer subscribeAndAwait(Map<String,Integer> topics)
      Subscribes to the topics with related QoS levels

      Unlike the bare Vert.x variant, this method returns a Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topics - topics and related QoS levels to subscribe to
      Returns:
      The operation result
      See Also:
      • MqttClient.subscribe(Map)
    • subscribeAndForget

      public MqttClient subscribeAndForget(Map<String,Integer> topics)
      Subscribes to the topics with related QoS levels

      Unlike the bare Vert.x variant, this method ignores the Integer result or any failure.

      Parameters:
      topics - topics and related QoS levels to subscribe to
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.subscribe(Map)
    • unsubscribe

      @CheckReturnValue public io.smallrye.mutiny.Uni<Integer> unsubscribe(String topic)
      Unsubscribe from receiving messages on given topic

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topic - Topic you want to unsubscribe from
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.unsubscribe(String)
    • unsubscribeAndAwait

      public Integer unsubscribeAndAwait(String topic)
      Unsubscribe from receiving messages on given topic

      Unlike the bare Vert.x variant, this method returns a Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topic - Topic you want to unsubscribe from
      Returns:
      The operation result
      See Also:
      • MqttClient.unsubscribe(String)
    • unsubscribeAndForget

      public MqttClient unsubscribeAndForget(String topic)
      Unsubscribe from receiving messages on given topic

      Unlike the bare Vert.x variant, this method ignores the Integer result or any failure.

      Parameters:
      topic - Topic you want to unsubscribe from
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.unsubscribe(String)
    • unsubscribe

      @CheckReturnValue public io.smallrye.mutiny.Uni<Integer> unsubscribe(List<String> topics)
      Unsubscribe from receiving messages on given list of topic

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      topics - list of topics you want to unsubscribe from
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.unsubscribe(List)
    • unsubscribeAndAwait

      public Integer unsubscribeAndAwait(List<String> topics)
      Unsubscribe from receiving messages on given list of topic

      Unlike the bare Vert.x variant, this method returns a Integer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      topics - list of topics you want to unsubscribe from
      Returns:
      The operation result
      See Also:
      • MqttClient.unsubscribe(List)
    • unsubscribeAndForget

      public MqttClient unsubscribeAndForget(List<String> topics)
      Unsubscribe from receiving messages on given list of topic

      Unlike the bare Vert.x variant, this method ignores the Integer result or any failure.

      Parameters:
      topics - list of topics you want to unsubscribe from
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.unsubscribe(List)
    • authenticationExchange

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> authenticationExchange(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties)
      Send an AUTH packet to the server.

      Used to continue an Enhanced Authentication exchange started in CONNECT, or to request re-authentication on an already-established session. Available only when the client is configured for MQTT 5.0.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      reasonCode - authenticate reason code
      properties - MQTT properties (typically AUTHENTICATION_METHOD and AUTHENTICATION_DATA)
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • MqttClient.authenticationExchange(MqttAuthenticateReasonCode, MqttProperties)
    • authenticationExchangeAndAwait

      public void authenticationExchangeAndAwait(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties)
      Send an AUTH packet to the server.

      Used to continue an Enhanced Authentication exchange started in CONNECT, or to request re-authentication on an already-established session. Available only when the client is configured for MQTT 5.0.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      reasonCode - authenticate reason code
      properties - MQTT properties (typically AUTHENTICATION_METHOD and AUTHENTICATION_DATA)
      See Also:
      • MqttClient.authenticationExchange(MqttAuthenticateReasonCode, MqttProperties)
    • authenticationExchangeAndForget

      public MqttClient authenticationExchangeAndForget(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode reasonCode, io.netty.handler.codec.mqtt.MqttProperties properties)
      Send an AUTH packet to the server.

      Used to continue an Enhanced Authentication exchange started in CONNECT, or to request re-authentication on an already-established session. Available only when the client is configured for MQTT 5.0.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      reasonCode - authenticate reason code
      properties - MQTT properties (typically AUTHENTICATION_METHOD and AUTHENTICATION_DATA)
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • MqttClient.authenticationExchange(MqttAuthenticateReasonCode, MqttProperties)
    • create

      public static MqttClient create(Vertx vertx, io.vertx.mqtt.MqttClientOptions options)
      Return an MQTT client instance
      Parameters:
      vertx - Vert.x instance
      options - MQTT client options
      Returns:
      MQTT client instance
    • create

      public static MqttClient create(Vertx vertx)
      Return an MQTT client instance using the default options
      Parameters:
      vertx - Vert.x instance
      Returns:
      MQTT client instance
    • publishCompletionHandler

      public MqttClient publishCompletionHandler(Consumer<Integer> publishCompletionHandler)
      Sets a handler which will be called each time the publishing of a message has been completed.

      For a message that has been published using

      • QoS 0 this means that the client has successfully sent the corresponding PUBLISH packet,
      • QoS 1 this means that a corresponding PUBACK has been received from the server,
      • QoS 2 this means that a corresponding PUBCOMP has been received from the server.
      Parameters:
      publishCompletionHandler - handler called with the packetId
      Returns:
      current MQTT client instance
    • publishAckMessageHandler

      public MqttClient publishAckMessageHandler(Consumer<MqttPubAckMessage> handler)
      Sets a handler which will be called each time a PUBACK is received from the server.

      MQTT 5.0: the handler receives the full typed message including reason code and properties. This handler fires alongside the existing #publishCompletionHandler(Handler).

      Parameters:
      handler - handler called with the PUBACK message
      Returns:
      current MQTT client instance
    • publishRecMessageHandler

      public MqttClient publishRecMessageHandler(Consumer<MqttPubRecMessage> handler)
      Sets a handler which will be called each time a PUBREC is received from the server.

      MQTT 5.0: the handler receives the full typed message including reason code and properties, before the client sends PUBREL.

      Parameters:
      handler - handler called with the PUBREC message
      Returns:
      current MQTT client instance
    • publishCompMessageHandler

      public MqttClient publishCompMessageHandler(Consumer<MqttPubCompMessage> handler)
      Sets a handler which will be called each time a PUBCOMP is received from the server.

      MQTT 5.0: the handler receives the full typed message including reason code and properties. This handler fires alongside the existing #publishCompletionHandler(Handler).

      Parameters:
      handler - handler called with the PUBCOMP message
      Returns:
      current MQTT client instance
    • publishCompletionExpirationHandler

      public MqttClient publishCompletionExpirationHandler(Consumer<Integer> publishCompletionExpirationHandler)
      Sets a handler which will be called when the client does not receive a PUBACK or PUBREC/PUBCOMP for a message published using QoS 1 or 2 respectively.

      The time to wait for an acknowledgement message can be configured using MqttClientOptions.setAckTimeout(int). If the client receives a PUBACK/PUBREC/PUBCOMP for a message after its completion has expired, the handler registered using #publishCompletionUnknownPacketIdHandler(Handler) will be invoked.

      Note that this behavior is outside the scope of the MQTT 3.1.1 specification. The client's default behavior is therefore to wait forever for the server's corresponding acknowledgement.

      Parameters:
      publishCompletionExpirationHandler - the handler to call with the ID of the expired packet
      Returns:
      current MQTT client instance
    • publishCompletionUnknownPacketIdHandler

      public MqttClient publishCompletionUnknownPacketIdHandler(Consumer<Integer> publishCompletionPhantomHandler)
      Sets a handler which will be called when the client receives a PUBACK/PUBREC/PUBCOMP with an unknown packet ID.
      Parameters:
      publishCompletionPhantomHandler - the handler to call with the unknown packet ID
      Returns:
      current MQTT client instance
    • publishHandler

      public MqttClient publishHandler(Consumer<MqttPublishMessage> publishHandler)
      Sets handler which will be called each time server publish something to client
      Parameters:
      publishHandler - handler to call
      Returns:
      current MQTT client instance
    • subscribeCompletionHandler

      public MqttClient subscribeCompletionHandler(Consumer<MqttSubAckMessage> subscribeCompletionHandler)
      Sets handler which will be called after SUBACK packet receiving
      Parameters:
      subscribeCompletionHandler - handler to call. List inside is a granted QoS array
      Returns:
      current MQTT client instance
    • unsubscribeCompletionHandler

      public MqttClient unsubscribeCompletionHandler(Consumer<Integer> unsubscribeCompletionHandler)
      Sets handler which will be called after UNSUBACK packet receiving
      Parameters:
      unsubscribeCompletionHandler - handler to call with the packetid
      Returns:
      current MQTT client instance
    • unsubscribeCompletionMessageHandler

      public MqttClient unsubscribeCompletionMessageHandler(Consumer<MqttUnsubAckMessage> unsubscribeCompletionMessageHandler)
      Sets handler which will be called after UNSUBACK packet receiving
      Parameters:
      unsubscribeCompletionMessageHandler - handler to call with the unsubscribe message
      Returns:
      current MQTT client instance
    • pingResponseHandler

      public MqttClient pingResponseHandler(Runnable pingResponseHandler)
      Sets handler which will be called after PINGRESP packet receiving
      Parameters:
      pingResponseHandler - handler to call
      Returns:
      current MQTT client instance
    • exceptionHandler

      public MqttClient exceptionHandler(Consumer<Throwable> handler)
      Set an exception handler for the client, that will be called when an error happens in internal netty structures. io.netty.handler.codec.DecoderException can be one of the cause
      Parameters:
      handler - the exception handler
      Returns:
      current MQTT client instance
    • disconnectMessageHandler

      public MqttClient disconnectMessageHandler(Consumer<MqttDisconnectMessage> handler)
      Sets a handler that will be called when the server sends a DISCONNECT packet.

      This fires before #closeHandler(Handler) and only for server-initiated disconnects (not when the client calls disconnect()). The handler receives the reason code and properties from the server's DISCONNECT packet.

      Parameters:
      handler - handler to call with the disconnect message
      Returns:
      current MQTT client instance
    • authenticationExchangeHandler

      public MqttClient authenticationExchangeHandler(Consumer<MqttAuthenticationExchangeMessage> handler)
      Sets a handler that will be called when the server sends an AUTH packet (MQTT 5.0 Enhanced Authentication, see §3.15).

      The handler receives the reason code, the authentication method, the authentication data and the full set of MQTT properties from the server's AUTH packet. The user can then reply with authenticationExchange(io.vertx.mqtt.messages.codes.MqttAuthenticateReasonCode, io.netty.handler.codec.mqtt.MqttProperties).

      Parameters:
      handler - handler to call with the AUTH message
      Returns:
      current MQTT client instance
    • closeHandler

      public MqttClient closeHandler(Runnable closeHandler)
      Set a handler that will be called when the connection with server is closed
      Parameters:
      closeHandler - handler to call
      Returns:
      current MQTT client instance
    • ping

      public MqttClient ping()
      This method is needed by the client in order to avoid server closes the connection due to the keep alive timeout if client has no messages to send
      Returns:
      current MQTT client instance
    • pause

      public void pause()
      Pause the reading channel, so no new byte are read from the server. Available after connection is established.

      This simply delegates to NetSocket.pause().

    • resume

      public void resume()
      Resume the reading channel. see pause() Available after connection is established.

      This simply delegates to NetSocket.resume().

    • clientId

      public String clientId()
      Returns:
      the client identifier
    • isConnected

      public boolean isConnected()
      Returns:
      if the connection between client and remote server is established/open
    • newInstance

      public static MqttClient newInstance(io.vertx.mqtt.MqttClient delegate)
      Creates a new instance of the MqttClient.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object