Interface ReconnectConfig
- All Superinterfaces:
Config
This is use to configure reconnection behavior for a specific connector. If reconnect is enabled, whenever a client connection is lost, messages for the client will continue to be queued. This allows the client to reconnect and pick up from where they left off.
Because messages will still be queued whilst the client is disconnected the configuration also allows a different maximum queue depth to be specified to use in the period of disconnection.
The keep alive and maximum queue depth properties can be changed at any time, even after the server has started.
- Since:
- 4.4
-
Method Summary
Modifier and TypeMethodDescriptionlong
Gets the keep alive value.int
Gets the maximum queue depth.int
Returns the maximum number of sent messages that can be recovered on reconnection.void
setKeepAlive
(long keepAlive) Sets the keep alive value.void
setMaximumQueueDepth
(int maxDepth) Sets the maximum queue depth value.void
setRecoveryBufferSize
(int size) Set the maximum number of sent messages that can be recovered on reconnection.
-
Method Details
-
setKeepAlive
Sets the keep alive value.Setting a non-zero value for this property enables the reconnect functionality for all clients connecting via the owning connector.
The value represents a period of time which a client's session is to be retained after a connection is lost. During this period messages will continue to be queued for the client.
By default this value is 300000 ms (5 minutes). Set this value to 0 to disable reconnection.
- Parameters:
keepAlive
- the time in milliseconds to keep context for a disconnected client so that it may reconnect. A value of zero indicates that reconnect is not possible.- Throws:
ConfigException
- if unable to set property
-
getKeepAlive
long getKeepAlive()Gets the keep alive value.- Returns:
- keep alive value in milliseconds. Zero indicates that reconnection is not enabled.
-
setMaximumQueueDepth
Sets the maximum queue depth value.This determines how large the client queue is allowed to become whilst waiting for the client to re-connect.
This can be set to any value as it will only be used if it is greater than the current maximum queue depth for the client queue.
By default this is set to 0 which means the queue size will not be altered when a client is disconnected.
- Parameters:
maxDepth
- maximum queue size or zero if an alternate queue size is not to be used. Any value less than the configured maximum queue depth would not be used anyway.- Throws:
ConfigException
- if unable to set property
-
getMaximumQueueDepth
int getMaximumQueueDepth()Gets the maximum queue depth.- Returns:
- maximum queue depth. 0 means that an alternate queue depth will not be used and the queue will remain a its current size during the disconnected period.
-
setRecoveryBufferSize
Set the maximum number of sent messages that can be recovered on reconnection.If the
keep alive
time is not zero, this connector supports reconnection. For each client connected via this connector, the server will retain a buffer of up tosize
sent messages. If a client disconnects and reconnects, the server uses this buffer to re-send messages that the client has not received.The default value is 128 messages. Higher values increase the chance of successful reconnection, but increase the per-client memory footprint.
- Parameters:
size
- number of messages; may be 0- Throws:
ConfigException
- if a negative value is provided, or the configuration is locked- Since:
- 5.8
-
getRecoveryBufferSize
int getRecoveryBufferSize()Returns the maximum number of sent messages that can be recovered on reconnection.- Returns:
- the size of the buffer used to store sent messages for clients that support reconnection
- Since:
- 5.8
-