MultiRPCClient

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.

Parameters

hostAndPort

The network address to connect to.

haAddressPool

A list of NetworkHostAndPort representing the addresses of servers in HA mode. The client will attempt to connect to a live server by trying each address in the list. If the servers are not in HA mode, the client will round-robin from the beginning of the list and try all servers.

rpcOpsClass

Class instance of the RPCOps remote interface that will be used for communication.

username

The username to authenticate with.

password

The password to authenticate with.

configuration

An optional configuration used to tweak client behaviour.

sslConfiguration

An optional ClientRpcSslOptions used to enable secure communication with the server.

classLoader

a classloader, which will be used (if provided) to discover available SerializationCustomSerializers and SerializationWhitelists. If no classloader is provided, the classloader of the current class will be used by default for the aforementioned discovery process.

customSerializers

a set of SerializationCustomSerializers to be used. If this parameter is specified, then no classpath scanning will be performed for custom serializers, the provided ones will be used instead. This parameter serves as a more user-friendly option to specify your serializers and disable the classpath scanning (e.g. for performance reasons).

externalTrace

external Trace for correlation.

impersonatedActor

the actor on behalf of which all the invocations will be made.

targetLegalIdentity

in case of multi-identity RPC endpoint specific legal identity to which the calls must be addressed.

Constructors

Link copied to clipboard
constructor(hostAndPort: <Error class: unknown class>, rpcOpsClass: Class<I>, username: String, password: String, configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT)
constructor(hostAndPort: <Error class: unknown class>, rpcOpsClass: Class<I>, username: String, password: String, classLoader: ClassLoader, configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT)
constructor(hostAndPort: <Error class: unknown class>, rpcOpsClass: Class<I>, username: String, password: String, sslConfiguration: <Error class: unknown class>? = null, classLoader: ClassLoader? = null)
constructor(hostAndPort: <Error class: unknown class>, rpcOpsClass: Class<I>, username: String, password: String, configuration: CordaRPCClientConfiguration, sslConfiguration: <Error class: unknown class>?, classLoader: ClassLoader? = null)
constructor(haAddressPool: List<<Error class: unknown class>>, rpcOpsClass: Class<I>, username: String, password: String, configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: <Error class: unknown class>? = null, classLoader: ClassLoader? = null)
constructor(hostAndPort: <Error class: unknown class>, rpcOpsClass: Class<I>, username: String, password: String, customSerializers: Set<<Error class: unknown class><out <Error class: unknown class>, out <Error class: unknown class>>>?, configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: <Error class: unknown class>? = null, classLoader: ClassLoader? = null, externalTrace: <Error class: unknown class>? = null, impersonatedActor: <Error class: unknown class>? = null, targetLegalIdentity: <Error class: unknown class>? = null)
constructor(haAddressPool: List<<Error class: unknown class>>, rpcOpsClass: Class<I>, username: String, password: String, customSerializers: Set<<Error class: unknown class><out <Error class: unknown class>, out <Error class: unknown class>>>?, configuration: CordaRPCClientConfiguration = CordaRPCClientConfiguration.DEFAULT, sslConfiguration: <Error class: unknown class>? = null, classLoader: ClassLoader? = null, externalTrace: <Error class: unknown class>? = null, impersonatedActor: <Error class: unknown class>? = null, targetLegalIdentity: <Error class: unknown class>? = null)

Functions

Link copied to clipboard

Adds RPCConnectionListener to this MultiRPCClient to be informed about important connectivity events.

Link copied to clipboard
open override fun close()
Link copied to clipboard

Logs in to the target server and returns an active connection.

Link copied to clipboard
fun stop()

Stops the client and closes RPCConnection if it has been previously established