net.sf.xenqtt.client
Class FixedReconnectionStrategy

java.lang.Object
  extended by net.sf.xenqtt.client.FixedReconnectionStrategy
All Implemented Interfaces:
Cloneable, ReconnectionStrategy

public final class FixedReconnectionStrategy
extends Object
implements ReconnectionStrategy

A ReconnectStrategy implementation that attempts to reconnect a fixed intervals up to a maximum number of reconnection attempts.

This class is thread-safe.


Constructor Summary
FixedReconnectionStrategy(long reconnectDelayMillis, int maxReconnectAttempts)
          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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedReconnectionStrategy

public FixedReconnectionStrategy(long reconnectDelayMillis,
                                 int maxReconnectAttempts)
Create a new instance of this class.

Parameters:
reconnectDelayMillis - The amount of time, in milliseconds, to wait before each reconnect attempt
maxReconnectAttempts - The maximum number of times to attempt a reconnect before no further attempts will be made
Method Detail

connectionLost

public long connectionLost(MqttClient client,
                           Throwable cause)
Description copied from interface: ReconnectionStrategy
Called by an MqttClient each time the connection to the broker is lost other than by an intentional disconnect.

Specified by:
connectionLost in interface ReconnectionStrategy
cause - The exception that cause the connection to close or resulted from the connection closing. May be null.
Returns:
Milliseconds the client should wait before trying to connect to the broker again. If <= 0 the client will stop trying to connect to the broker.
See Also:
ReconnectionStrategy.connectionLost(net.sf.xenqtt.client.MqttClient, java.lang.Throwable)

connectionEstablished

public void connectionEstablished()
Description copied from interface: ReconnectionStrategy
Called by an MqttClient instance when a connection to the broker is established.

Specified by:
connectionEstablished in interface ReconnectionStrategy
See Also:
ReconnectionStrategy.connectionEstablished()

clone

public ReconnectionStrategy clone()
Specified by:
clone in interface ReconnectionStrategy
Overrides:
clone in class Object
Returns:
A new instance of the same type as this object. This is used to create a new strategy for each client created by the MqttClientFactory.
See Also:
Object.clone(), ReconnectionStrategy.clone()


Copyright © 2013. All Rights Reserved.