Monitor connections from the client side
This topic has not yet been written. The content below is from the topic description.
On the client side, an org.jboss.remoting.ConnectionValidator periodically sends a PING message to the server and reports a failure if the response does not arrive within a specified timeout period. The PING is sent on one thread, and another thread determines if the response arrives in time. Separating these two activities allows Remoting to detect a failure regardless of the cause of the failure. The creation of the ConnectionValidator is the responsibility of the org.jboss.remoting.Client class. All the application code needs to do is to register an implementation of the org.jboss.remoting.ConnectionListener interface, which has only one method: public void handleConnectionException(Throwable throwable, Client client); What actions the ConnectionListener chooses to take are up to the application, but disconnecting the Client might be a reasonable strategy. The Client class has three methods for registering a ConnectionListener: public void addConnectionListener(ConnectionListener listener); public void addConnectionListener(ConnectionListener listener, int pingPeriod); public void addConnectionListener(ConnectionListener listener, Map metadata); The second method supports configuring the frequency of PING messages, and the third method supports more general configuration of the ConnectionValidator. Note that a given Client maintains a single ConnectionValidator, so the parameters in the metadata map are applied only on the first call to Client.addConnectionListener(). The following parameters are supported by ConnectionValidator, which is where the parameter names are defined: VALIDATOR_PING_PERIOD (actual value "validatorPingPeriod") - specifies the time, in milliseconds, that elapses between the sending of PING messages to the server. The default value is 2000. VALIDATOR_PING_TIMEOUT (actual value "validatorPingTimeout") - specifies the time, in milliseconds, allowed for arrival of a response to a PING message. The default value is 1000. FAILURE_DISCONNECT_TIMEOUT (actual value "failureDisconnectTimeout") - if the parameter "stopLeaseOnFailure" (see Interactions between client side and server side connection monitoring) is set to "true", then "failureDisconnectTimeout" determines the disconnect timeout value to be used by org.jboss.remoting.LeasePinger in shutting down. In particular, if "failureDisconnectTimeout" is set to "0", then LeasePinger will avoid any network i/o. Normally, the values for these parameters are obtained either from the Client's configuration map or the metadata map passed to addConnectionListener(), with values in the metadata map taking precedence. However, another relevant parameter is defined in org.jboss.remoting.Client: USE_ALL_PARAMS (actual value "useAllParams") - this parameter is searched for in the InvokerLocator, in the configuration map passed to the Client, and in the metadata map (in that order). If the last occurrence found is set to "true", then parameter values are first obtained from the InvokerLocator, followed by the Client's configuration map and the metadata map. Note that ConnectionValidator creates a client invoker to sends the PING messages, and it passes the metadata map to configure the client invoker. NOTE. The default values of VALIDATOR_PING_PERIOD and VALIDATOR_PING_TIMEOUT have often been found in practice to be too small, increasing the likelihood of spurious connection failures. NOTE. It is important to set VALIDATOR_PING_PERIOD to a value greater than the value of VALIDATOR_PING_TIMEOUT. Doing so gives the ConnectionValidator a chance to notify all ConnectionListeners, which might result in shutting down the connection, before the next PING is sent. For more configuration parameters, see Interactions between client side and server side connection monitoring.