Class MQTTForward

java.lang.Object
javaforce.MQTTForward

public class MQTTForward extends Object
MQTT Forward. Provides a queue of messages to be sent to an MQTT service. MQTTForward will work in the background to send messages.
Author:
peter.quiring
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns # of times a connection was created.
    boolean
    Returns connection status.
    void
    publish(String topic, String msg)
     
    void
    Force a reconnection to MQTT Server.
    void
    setKeepAlive(int value)
    Set keep alive interval in seconds (default = 5) (0 = disabled) Send a ping() to maintain connection.
    void
    setMaxQueueSize(int size)
    Set maximum queue size (default = 1000) Messages are lost when queue reaches this size.
    void
    setQOS(byte qos)
    Set QOS (Quality of service) QOS effects publish acknowledgements.
    void
    start(String host, int port)
    Start sending messages to MQTT Server on host:port without encryption.
    void
    start(String host, int port, String user, String pass)
    Start sending messages to MQTT Server on host:port without encryption with supplied login details.
    void
    start(String host, int port, KeyMgmt keys)
    Start sending messages to MQTT Server on host:port with encryption.
    void
    start(String host, int port, KeyMgmt keys, String user, String pass)
    Start sending messages to MQTT Server on host:port with encryption.
    void
    start(String host, String user, String pass)
    Start sending messages to MQTT Server on host without encryption with supplied login details.
    void
    start(String host, KeyMgmt keys, String user, String pass)
    Start sending messages to MQTT Server on host with encryption with supplied login details.
    void
    Stop forwarding messages and shutdown any connection.

    Methods inherited from class Object

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

    • MQTTForward

      public MQTTForward()
  • Method Details

    • start

      public void start(String host, int port)
      Start sending messages to MQTT Server on host:port without encryption.
    • start

      public void start(String host, int port, KeyMgmt keys)
      Start sending messages to MQTT Server on host:port with encryption.
    • start

      public void start(String host, String user, String pass)
      Start sending messages to MQTT Server on host without encryption with supplied login details.
    • start

      public void start(String host, KeyMgmt keys, String user, String pass)
      Start sending messages to MQTT Server on host with encryption with supplied login details.
    • start

      public void start(String host, int port, String user, String pass)
      Start sending messages to MQTT Server on host:port without encryption with supplied login details.
    • start

      public void start(String host, int port, KeyMgmt keys, String user, String pass)
      Start sending messages to MQTT Server on host:port with encryption.
    • stop

      public void stop()
      Stop forwarding messages and shutdown any connection.
    • isConnected

      public boolean isConnected()
      Returns connection status.
    • getConnects

      public int getConnects()
      Returns # of times a connection was created.
    • setMaxQueueSize

      public void setMaxQueueSize(int size)
      Set maximum queue size (default = 1000) Messages are lost when queue reaches this size.
    • setQOS

      public void setQOS(byte qos)
      Set QOS (Quality of service) QOS effects publish acknowledgements. QOS values are defined in javaforce.service.MQTTServer QOS_0 = NO ACK QOS_1 = ACK QOS_2 = REC, REL, CMP QOS_3 = reserved
      Parameters:
      qos - = quality of service (default = QOS_1)
    • publish

      public void publish(String topic, String msg)
    • setKeepAlive

      public void setKeepAlive(int value)
      Set keep alive interval in seconds (default = 5) (0 = disabled) Send a ping() to maintain connection.
    • reconnect

      public void reconnect()
      Force a reconnection to MQTT Server.