|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.xenqtt.client.ProgressiveReconnectionStrategy
public final class ProgressiveReconnectionStrategy
A ReconnectionStrategy
implementation that allows for progressive reconnection attempts to the broker. Reconnect attempts begin at an aggressive
(configurable) interval. Subsequent attempts back off in aggressiveness with the assumption that if the broker is not nearly immediate available that an
issue might prevent a reconnect in the near-term but perhaps not in the longer-term.
This class is thread-safe.
Constructor Summary | |
---|---|
ProgressiveReconnectionStrategy(long baseReconnectMillis,
int progressiveFactor,
int maxNumberOfReconnects,
long maxReconnectMillis)
Create a new instance of this class. |
Method Summary | |
---|---|
ReconnectionStrategy |
clone()
|
void |
connectionEstablished()
Called by an MqttClient instance when a connection to the broker is established. |
long |
connectionLost(MqttClient client,
Throwable cause)
Called by an MqttClient each time the connection to the broker is lost other than by an intentional disconnect. |
long |
getBaseReconnectMillis()
|
int |
getCurrentRetry()
|
int |
getMaxNumberOfReconnects()
|
long |
getMaxReconnectMillis()
|
int |
getProgressiveFactor()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProgressiveReconnectionStrategy(long baseReconnectMillis, int progressiveFactor, int maxNumberOfReconnects, long maxReconnectMillis)
baseReconnectMillis
- The base reconnect millis to start at. The first retry is attempted at this intervalprogressiveFactor
- The progressive factor. This defines how to increase the amount of time between reconnects. For example, if the base is 100 and this is 2 the
reconnects will occur as such: 100, 200, 400, 800, 1600, ...
maxNumberOfReconnects
- The maximum number of reconnect attempts to makemaxReconnectMillis
- maximum number of millis to wait. Once the progression has reached this value all future retries will be at this interval.Method Detail |
---|
public long connectionLost(MqttClient client, Throwable cause)
ReconnectionStrategy
MqttClient
each time the connection to the broker is lost other than by an intentional disconnect.
connectionLost
in interface ReconnectionStrategy
cause
- The exception that cause the connection to close or resulted from the connection closing. May be null
.
ReconnectionStrategy.connectionLost(net.sf.xenqtt.client.MqttClient, java.lang.Throwable)
public void connectionEstablished()
ReconnectionStrategy
MqttClient
instance when a connection to the broker is established.
connectionEstablished
in interface ReconnectionStrategy
ReconnectionStrategy.connectionEstablished()
public ReconnectionStrategy clone()
clone
in interface ReconnectionStrategy
clone
in class Object
MqttClientFactory
.Object.clone()
,
ReconnectionStrategy.clone()
public long getBaseReconnectMillis()
public int getProgressiveFactor()
100, 200, 400, 800, 1600, ...
public int getMaxNumberOfReconnects()
public long getMaxReconnectMillis()
public int getCurrentRetry()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |