Class MultiRPCClient
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable
public final class MultiRPCClient<I extends RPCOps> implements AutoCloseable
An RPC client connects to the specified server and allows to make calls using specified remote interface to the server that perform various useful tasks. Please see the Client RPC section of Corda Documentation to learn more about how this API works. Only a brief description is provided here.
Calling start returns an RPCConnection containing a proxy that allows making RPCs calls to the server. This is a blocking communication, and if the server throws an exception then it will be rethrown on the client. Proxies are thread safe and may be used to invoke multiple RPCs in parallel.
RPC sends and receives are logged on the
net.corda.rpc
logger.In case of loss of connection to the server, the client will try to reconnect using the settings provided via CordaRPCClientConfiguration. If the client was created using a list of hosts via haAddressPool, automatic failover will occur (the servers have to be started in HA mode). While attempting failover, current and future RPC calls will throw RPCException.
It is also possible to add RPCConnectionListeners event before connection is started to be notified about connection lifecycle. Please see documentation on RPCConnectionListener for more details.
-
-
Constructor Summary
Constructors Constructor Description MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, CordaRPCClientConfiguration configuration)
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, ClassLoader classLoader, CordaRPCClientConfiguration configuration)
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader)
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader)
MultiRPCClient(List<NetworkHostAndPort> haAddressPool, Class<I> rpcOpsClass, String username, String password, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader)
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, Set<SerializationCustomSerializer<?, ?>> customSerializers, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader, Trace externalTrace, Actor impersonatedActor, CordaX500Name targetLegalIdentity)
MultiRPCClient(List<NetworkHostAndPort> haAddressPool, Class<I> rpcOpsClass, String username, String password, Set<SerializationCustomSerializer<?, ?>> customSerializers, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader, Trace externalTrace, Actor impersonatedActor, CordaX500Name targetLegalIdentity)
-
Method Summary
Modifier and Type Method Description final Boolean
addConnectionListener(RPCConnectionListener<I> listener)
Adds RPCConnectionListener to this MultiRPCClient to be informed about important connectivity events. final Boolean
removeConnectionListener(RPCConnectionListener<I> listener)
Removes RPCConnectionListener from this MultiRPCClient. final CompletableFuture<RPCConnection<I>>
start()
Logs in to the target server and returns an active connection. final Unit
stop()
Stops the client and closes RPCConnection if it has been previously established Unit
close()
-
-
Constructor Detail
-
MultiRPCClient
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, CordaRPCClientConfiguration configuration)
-
MultiRPCClient
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, ClassLoader classLoader, CordaRPCClientConfiguration configuration)
-
MultiRPCClient
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader)
-
MultiRPCClient
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader)
-
MultiRPCClient
MultiRPCClient(List<NetworkHostAndPort> haAddressPool, Class<I> rpcOpsClass, String username, String password, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader)
-
MultiRPCClient
MultiRPCClient(NetworkHostAndPort hostAndPort, Class<I> rpcOpsClass, String username, String password, Set<SerializationCustomSerializer<?, ?>> customSerializers, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader, Trace externalTrace, Actor impersonatedActor, CordaX500Name targetLegalIdentity)
-
MultiRPCClient
MultiRPCClient(List<NetworkHostAndPort> haAddressPool, Class<I> rpcOpsClass, String username, String password, Set<SerializationCustomSerializer<?, ?>> customSerializers, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, ClassLoader classLoader, Trace externalTrace, Actor impersonatedActor, CordaX500Name targetLegalIdentity)
-
-
Method Detail
-
addConnectionListener
final Boolean addConnectionListener(RPCConnectionListener<I> listener)
Adds RPCConnectionListener to this MultiRPCClient to be informed about important connectivity events.
-
removeConnectionListener
final Boolean removeConnectionListener(RPCConnectionListener<I> listener)
Removes RPCConnectionListener from this MultiRPCClient.
-
start
final CompletableFuture<RPCConnection<I>> start()
Logs in to the target server and returns an active connection.
It only makes sense to this method once. If it is called repeatedly it will return the same by reference CompletableFuture
-
stop
final Unit stop()
Stops the client and closes RPCConnection if it has been previously established
-
-
-
-