public class MultiRPCClient<I extends RPCOps>
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 MultiRPCClient.start
returns an interface 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
class 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
exception RPCException
.
It is also possible to add interface RPCConnectionListener
s event before connection is started to be notified about connection lifecycle.
Please see documentation on interface RPCConnectionListener
for more details.
Modifier and Type | Field and Description |
---|---|
static net.corda.client.rpc.ext.MultiRPCClient.Companion |
Companion
Deprecated.
|
Constructor and Description |
---|
MultiRPCClient(NetworkHostAndPort hostAndPort,
java.lang.Class<I> rpcOpsClass,
java.lang.String username,
java.lang.String password,
CordaRPCClientConfiguration configuration) |
MultiRPCClient(NetworkHostAndPort hostAndPort,
java.lang.Class<I> rpcOpsClass,
java.lang.String username,
java.lang.String password,
java.lang.ClassLoader classLoader,
CordaRPCClientConfiguration configuration) |
MultiRPCClient(NetworkHostAndPort hostAndPort,
java.lang.Class<I> rpcOpsClass,
java.lang.String username,
java.lang.String password,
ClientRpcSslOptions sslConfiguration,
java.lang.ClassLoader classLoader) |
MultiRPCClient(NetworkHostAndPort hostAndPort,
java.lang.Class<I> rpcOpsClass,
java.lang.String username,
java.lang.String password,
CordaRPCClientConfiguration configuration,
ClientRpcSslOptions sslConfiguration,
java.lang.ClassLoader classLoader) |
MultiRPCClient(java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
java.lang.Class<I> rpcOpsClass,
java.lang.String username,
java.lang.String password,
CordaRPCClientConfiguration configuration,
ClientRpcSslOptions sslConfiguration,
java.lang.ClassLoader classLoader) |
MultiRPCClient(NetworkHostAndPort hostAndPort,
java.lang.Class<I> rpcOpsClass,
java.lang.String username,
java.lang.String password,
java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
CordaRPCClientConfiguration configuration,
ClientRpcSslOptions sslConfiguration,
java.lang.ClassLoader classLoader,
Trace externalTrace,
Actor impersonatedActor,
CordaX500Name targetLegalIdentity) |
MultiRPCClient(java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
java.lang.Class<I> rpcOpsClass,
java.lang.String username,
java.lang.String password,
java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
CordaRPCClientConfiguration configuration,
ClientRpcSslOptions sslConfiguration,
java.lang.ClassLoader classLoader,
Trace externalTrace,
Actor impersonatedActor,
CordaX500Name targetLegalIdentity) |
Modifier and Type | Method and Description |
---|---|
boolean |
addConnectionListener(RPCConnectionListener<I> listener)
Adds
interface RPCConnectionListener to this class MultiRPCClient to be informed about important connectivity events. |
void |
close() |
boolean |
removeConnectionListener(RPCConnectionListener<I> listener)
Removes
interface RPCConnectionListener from this class MultiRPCClient . |
java.util.concurrent.CompletableFuture<net.corda.client.rpc.RPCConnection> |
start()
Logs in to the target server and returns an active connection.
|
void |
stop()
Stops the client and closes
interface RPCConnection if it has been previously established |
public static net.corda.client.rpc.ext.MultiRPCClient.Companion Companion
public MultiRPCClient(NetworkHostAndPort hostAndPort, java.lang.Class<I> rpcOpsClass, java.lang.String username, java.lang.String password, CordaRPCClientConfiguration configuration)
public MultiRPCClient(NetworkHostAndPort hostAndPort, java.lang.Class<I> rpcOpsClass, java.lang.String username, java.lang.String password, java.lang.ClassLoader classLoader, CordaRPCClientConfiguration configuration)
public MultiRPCClient(NetworkHostAndPort hostAndPort, java.lang.Class<I> rpcOpsClass, java.lang.String username, java.lang.String password, ClientRpcSslOptions sslConfiguration, java.lang.ClassLoader classLoader)
public MultiRPCClient(NetworkHostAndPort hostAndPort, java.lang.Class<I> rpcOpsClass, java.lang.String username, java.lang.String password, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, java.lang.ClassLoader classLoader)
public MultiRPCClient(java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool, java.lang.Class<I> rpcOpsClass, java.lang.String username, java.lang.String password, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, java.lang.ClassLoader classLoader)
public MultiRPCClient(NetworkHostAndPort hostAndPort, java.lang.Class<I> rpcOpsClass, java.lang.String username, java.lang.String password, java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, java.lang.ClassLoader classLoader, Trace externalTrace, Actor impersonatedActor, CordaX500Name targetLegalIdentity)
public MultiRPCClient(java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool, java.lang.Class<I> rpcOpsClass, java.lang.String username, java.lang.String password, java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers, CordaRPCClientConfiguration configuration, ClientRpcSslOptions sslConfiguration, java.lang.ClassLoader classLoader, Trace externalTrace, Actor impersonatedActor, CordaX500Name targetLegalIdentity)
public boolean addConnectionListener(RPCConnectionListener<I> listener)
Adds interface RPCConnectionListener
to this class MultiRPCClient
to be informed about important connectivity events.
true
if the element has been added, false
when listener is already contained in the set of listeners.interface RPCConnectionListener
,
class MultiRPCClient
public boolean removeConnectionListener(RPCConnectionListener<I> listener)
Removes interface RPCConnectionListener
from this class MultiRPCClient
.
true
if the element has been successfully removed; false
if it was not present in the set of listeners.interface RPCConnectionListener
,
class MultiRPCClient
public java.util.concurrent.CompletableFuture<net.corda.client.rpc.RPCConnection> 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
interface RPCConnection
or throwing exception RPCException
if the server version is too low or if the server is not
reachable within a reasonable timeout or if login credentials provided are incorrect.public void stop()
Stops the client and closes interface RPCConnection
if it has been previously established
interface RPCConnection
public void close()