Class AbstractReconnectStrategy
java.lang.Object
org.openhab.core.io.transport.mqtt.reconnect.AbstractReconnectStrategy
- Direct Known Subclasses:
PeriodicReconnectStrategy
Implement this class to provide a strategy for (re)establishing a lost
broker connection.
- Author:
- David Graeff - Initial contribution
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
TheMqttConnectionObserver
will call this method if a broker connection has been successfully established.@Nullable MqttBrokerConnection
Return the brokerConnection object that this reconnect policy is assigned to.abstract boolean
Return true if your implementation is trying to establish a connection, false otherwise.abstract void
TheMqttConnectionObserver
will call this method if a broker connection has been lost or couldn't be established.void
setBrokerConnection
(MqttBrokerConnection mqttBrokerConnectionImpl) Will be called by .abstract void
start()
Start the reconnect strategy handling.abstract void
stop()
Stop the reconnect strategy handling.
-
Field Details
-
brokerConnection
-
-
Constructor Details
-
AbstractReconnectStrategy
public AbstractReconnectStrategy()
-
-
Method Details
-
setBrokerConnection
Will be called by .- Parameters:
mqttBrokerConnectionImpl
- The broker connection
-
getBrokerConnection
Return the brokerConnection object that this reconnect policy is assigned to. -
isReconnecting
public abstract boolean isReconnecting()Return true if your implementation is trying to establish a connection, false otherwise. -
lostConnection
public abstract void lostConnection()TheMqttConnectionObserver
will call this method if a broker connection has been lost or couldn't be established. Your implementation should start trying to reestablish a connection. -
connectionEstablished
public abstract void connectionEstablished()TheMqttConnectionObserver
will call this method if a broker connection has been successfully established. Your implementation should stop reconnection attempts and release resources. -
start
public abstract void start()Start the reconnect strategy handling. -
stop
public abstract void stop()Stop the reconnect strategy handling.It must be possible to restart a reconnect strategy again after it has been stopped.
-