net.sf.xenqtt.client
Class MqttClientConfig

java.lang.Object
  extended by net.sf.xenqtt.client.MqttClientConfig
All Implemented Interfaces:
Cloneable

public final class MqttClientConfig
extends Object
implements Cloneable

Use this class to configure the MqttClient implementations and the MqttClientFactory. This is an advanced operation. The defaults should be fine for most cases.


Constructor Summary
MqttClientConfig()
           
 
Method Summary
 MqttClientConfig clone()
           
 int getBlockingTimeoutSeconds()
           
 MqttClientDebugListener getClientDebugListener()
           
 int getConnectTimeoutMillis()
           
 int getConnectTimeoutSeconds()
           
 int getKeepAliveSeconds()
           
 int getMessageResendIntervalSeconds()
           
 ReconnectionStrategy getReconnectionStrategy()
           
 MqttClientConfig setBlockingTimeoutSeconds(int blockingTimeoutSeconds)
           
 MqttClientConfig setClientDebugListener(MqttClientDebugListener clientDebugListener)
           
 MqttClientConfig setConnectTimeoutSeconds(int connectTimeoutSeconds)
           
 MqttClientConfig setKeepAliveSeconds(int keepAliveSeconds)
           
 MqttClientConfig setMessageResendIntervalSeconds(int messageResendIntervalSeconds)
           
 MqttClientConfig setReconnectionStrategy(ReconnectionStrategy reconnectionStrategy)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MqttClientConfig

public MqttClientConfig()
Method Detail

getReconnectionStrategy

public ReconnectionStrategy getReconnectionStrategy()
Returns:
The algorithm used to reconnect to the broker if the connection is lost.

Defaults to a ProgressiveReconnectionStrategy where the initial reconnection attempt happens after 50 millis then increases by a factor of 5 up to 30 seconds where it continues to retry indefinitely.


setReconnectionStrategy

public MqttClientConfig setReconnectionStrategy(ReconnectionStrategy reconnectionStrategy)
Parameters:
reconnectionStrategy - The algorithm used to reconnect to the broker if the connection is lost.

Defaults to a ProgressiveReconnectionStrategy where the initial reconnection attempt happens after 50 millis then increases by a factor of 5 up to 30 seconds where it continues to retry indefinitely.

Returns:
this object

getConnectTimeoutSeconds

public int getConnectTimeoutSeconds()
Returns:
Seconds to wait for an ack to a connect message before timing out and closing the channel. 0 to wait forever.

Defaults to 30 seconds.


getConnectTimeoutMillis

public int getConnectTimeoutMillis()
Returns:
getConnectTimeoutSeconds() converted to milliseconds

setConnectTimeoutSeconds

public MqttClientConfig setConnectTimeoutSeconds(int connectTimeoutSeconds)
Parameters:
connectTimeoutSeconds - Seconds to wait for an ack to a connect message before timing out and closing the channel. 0 to wait forever.

Defaults to 30 seconds.

Returns:
this object

getMessageResendIntervalSeconds

public int getMessageResendIntervalSeconds()
Returns:
Seconds between attempts to resend a message that is MqttMessage.isAckable(). The minimum allowable value for this setting is 2.

Defaults to 30 seconds.


setMessageResendIntervalSeconds

public MqttClientConfig setMessageResendIntervalSeconds(int messageResendIntervalSeconds)
Parameters:
messageResendIntervalSeconds - Seconds between attempts to resend a message that is MqttMessage.isAckable(). The minimum allowable value for this setting is 2.

Defaults to 30 seconds.

Returns:
this object

getBlockingTimeoutSeconds

public int getBlockingTimeoutSeconds()
Returns:
Seconds until a blocked method invocation times out and an MqttTimeoutException is thrown. 0 will wait forever. Applies only to synchronous clients. It is ignored by asynchronous clients.

Defaults to 0 (wait forever).


setBlockingTimeoutSeconds

public MqttClientConfig setBlockingTimeoutSeconds(int blockingTimeoutSeconds)
Parameters:
blockingTimeoutSeconds - Seconds until a blocked method invocation times out and an MqttTimeoutException is thrown. 0 will wait forever. Applies only to synchronous clients. It is ignored by asynchronous clients.

Defaults to 0 (wait forever).

Returns:
this object

getKeepAliveSeconds

public int getKeepAliveSeconds()
Returns:
The Keep Alive timer, measured in seconds, defines the maximum time interval between messages received from a client. It enables the broker to detect that the network connection to a client has dropped, without having to wait for the long TCP/IP timeout. In the absence of a data-related message during the time period, this client sends a PINGREQ message, which the broker acknowledges with a PINGRESP message.

If the broker does not receive a message from the client within one and a half times the Keep Alive time period (the client is allowed "grace" of half a time period), it disconnects the client. This action does not impact any of the client's subscriptions.

If this client does not receive a PINGRESP message within a Keep Alive time period after sending a PINGREQ, it closes the TCP/IP socket connection.

The Keep Alive timer is a 16-bit value that represents the number of seconds for the time period. The actual value is application-specific, but a typical value is a few minutes. The maximum value is approximately 18 hours. A value of zero (0) means the client is not disconnected.

Defaults to 300 seconds (5 minutes).


setKeepAliveSeconds

public MqttClientConfig setKeepAliveSeconds(int keepAliveSeconds)
Parameters:
keepAliveSeconds - The Keep Alive timer, measured in seconds, defines the maximum time interval between messages received from a client. It enables the broker to detect that the network connection to a client has dropped, without having to wait for the long TCP/IP timeout. In the absence of a data-related message during the time period, this client sends a PINGREQ message, which the broker acknowledges with a PINGRESP message.

If the broker does not receive a message from the client within one and a half times the Keep Alive time period (the client is allowed "grace" of half a time period), it disconnects the client. This action does not impact any of the client's subscriptions.

If this client does not receive a PINGRESP message within a Keep Alive time period after sending a PINGREQ, it closes the TCP/IP socket connection.

The Keep Alive timer is a 16-bit value that represents the number of seconds for the time period. The actual value is application-specific, but a typical value is a few minutes. The maximum value is approximately 18 hours. A value of zero (0) means the client is not disconnected.

Defaults to 300 seconds (5 minutes).

Returns:
this object

getClientDebugListener

public MqttClientDebugListener getClientDebugListener()
Returns:
The listener that will receive events for this client. Null if there is no listener.

setClientDebugListener

public MqttClientConfig setClientDebugListener(MqttClientDebugListener clientDebugListener)
Parameters:
clientDebugListener - The listener that will receive events for this client. null to have no listener. This can have a significant performance impact and should only be used when debugging.

clone

public MqttClientConfig clone()
Overrides:
clone in class Object
See Also:
Object.clone()


Copyright © 2013. All Rights Reserved.