Class MqttConnector


  • public class MqttConnector
    extends java.lang.Object
    This helper class wraps a connection to an MQTT broker.

    One main feature of this class is to retry the initial connection to an MQTT broker. A feature that is unfortunately not present in Eclipse Paho. After the first successful connection, Paho reconnects on its own in case of a lost connection.

    • Constructor Summary

      Constructors 
      Constructor Description
      MqttConnector()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.concurrent.CompletableFuture<org.eclipse.paho.mqttv5.client.IMqttClient> connect​(java.lang.String serverUri, java.lang.String clientId, java.lang.String username, java.lang.String password)  
      protected java.util.concurrent.CompletableFuture<org.eclipse.paho.mqttv5.client.IMqttClient> connect​(java.lang.String serverUri, java.lang.String clientId, java.lang.String username, java.lang.String password, org.eclipse.paho.mqttv5.client.MqttCallback callback)  
      protected void deactivate()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MqttConnector

        public MqttConnector()
    • Method Detail

      • deactivate

        protected void deactivate()
      • connect

        protected java.util.concurrent.CompletableFuture<org.eclipse.paho.mqttv5.client.IMqttClient> connect​(java.lang.String serverUri,
                                                                                                             java.lang.String clientId,
                                                                                                             java.lang.String username,
                                                                                                             java.lang.String password)
                                                                                                      throws java.lang.IllegalArgumentException,
                                                                                                             org.eclipse.paho.mqttv5.common.MqttException
        Throws:
        java.lang.IllegalArgumentException
        org.eclipse.paho.mqttv5.common.MqttException
      • connect

        protected java.util.concurrent.CompletableFuture<org.eclipse.paho.mqttv5.client.IMqttClient> connect​(java.lang.String serverUri,
                                                                                                             java.lang.String clientId,
                                                                                                             java.lang.String username,
                                                                                                             java.lang.String password,
                                                                                                             org.eclipse.paho.mqttv5.client.MqttCallback callback)
                                                                                                      throws java.lang.IllegalArgumentException,
                                                                                                             org.eclipse.paho.mqttv5.common.MqttException
        Throws:
        java.lang.IllegalArgumentException
        org.eclipse.paho.mqttv5.common.MqttException