Unshared state connections are created differently from shared state connections in three important ways. First, there is a JAR file that must be present in the environment
CLASSPATH of the client. Second, the connection must be created using an unshared state connection factory. And finally, the server URLs must be specified using unshared state syntax.
When an unshared state connection fails, the connection’s ExceptionListener callback is invoked. To recover the connection—repair it so that it is connected to an active server—the client application calls the connection factory’s
recoverConnection method. This must be performed in the
ExceptionListener callback. The
recoverConnection method blocks until the connection (and its related objects, including sessions, producers, and consumers) are fully recreated, or until it has failed in all its attempts to recreate these objects.
As long as the unshared state client has a valid connection, the API behaves the same as the standard EMS client. However, when the unshared state client’s connection is broken, the API performs as follows:
Note that the connection is considered broken from the point where the underlying TCP/SSL connection fails, and until
recoverConnection successfully returns.
When a server connection is lost during an unshared state failover, clients attempt to reconnect to the second server. To enable a client to reconnect, you must specify the URLs of both servers when creating a connection.
The client attempts to connect to each URL in the order listed. If a connection to one URL fails, the client tries the next URL in the list. The client tries the URLs in sequence until all URLs have been tried. If the first failed connection was not the first URL in the list, the attempts wrap to the start of the list (so each URL is tried). If none of the attempts succeed, the connection fails.