MultiRPCClient
Keywords: net.corda.client.rpc.ext.MultiRPCClient class
Date: 2023-09-18

net.corda.client.rpc.ext

## Class MultiRPCClient<I extends RPCOps>

- net.corda.client.rpc.ext.MultiRPCClient<I>

-     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 `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.

  See Also:
    Corda Documentation, `start`, `interface RPCConnection`, `class CordaRPCClientConfiguration`, `exception RPCException`, `interface RPCConnectionListener`, `interface RPCConnectionListener`

- - ### Field Detail

    - #### Companion

          public static net.corda.client.rpc.ext.MultiRPCClient.Companion Companion

      Deprecated.

  - ### Constructor Detail

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password)

    - #### MultiRPCClient

          public MultiRPCClient(@NotNull
                                NetworkHostAndPort hostAndPort,
                                @NotNull
                                java.lang.Class<I> rpcOpsClass,
                                @NotNull
                                java.lang.String username,
                                @NotNull
                                java.lang.String password,
                                @NotNull
                                java.lang.ClassLoader classLoader,
                                @NotNull
                                CordaRPCClientConfiguration configuration)

    - #### MultiRPCClient

          public MultiRPCClient(@NotNull
                                NetworkHostAndPort hostAndPort,
                                @NotNull
                                java.lang.Class<I> rpcOpsClass,
                                @NotNull
                                java.lang.String username,
                                @NotNull
                                java.lang.String password,
                                @Nullable
                                ClientRpcSslOptions sslConfiguration,
                                @Nullable
                                java.lang.ClassLoader classLoader)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader,
                                              @Nullable
                                              Trace externalTrace,
                                              @Nullable
                                              Actor impersonatedActor,
                                              @Nullable
                                              CordaX500Name targetLegalIdentity)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader,
                                              @Nullable
                                              Trace externalTrace,
                                              @Nullable
                                              Actor impersonatedActor)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader,
                                              @Nullable
                                              Trace externalTrace)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              NetworkHostAndPort hostAndPort,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader,
                                              @Nullable
                                              Trace externalTrace,
                                              @Nullable
                                              Actor impersonatedActor,
                                              @Nullable
                                              CordaX500Name targetLegalIdentity)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader,
                                              @Nullable
                                              Trace externalTrace,
                                              @Nullable
                                              Actor impersonatedActor)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader,
                                              @Nullable
                                              Trace externalTrace)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration,
                                              @Nullable
                                              java.lang.ClassLoader classLoader)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration,
                                              @Nullable
                                              ClientRpcSslOptions sslConfiguration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers,
                                              @NotNull
                                              CordaRPCClientConfiguration configuration)

    - #### MultiRPCClient

          @JvmOverloads
          public MultiRPCClient(@NotNull
                                              java.util.List<net.corda.core.utilities.NetworkHostAndPort> haAddressPool,
                                              @NotNull
                                              java.lang.Class<I> rpcOpsClass,
                                              @NotNull
                                              java.lang.String username,
                                              @NotNull
                                              java.lang.String password,
                                              @Nullable
                                              java.util.Set<? extends net.corda.core.serialization.SerializationCustomSerializer<?,?>> customSerializers)

  - ### Method Detail

    - #### addConnectionListener

          public boolean addConnectionListener(@NotNull
                                               RPCConnectionListener<I> listener)

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

      Returns:
        `true` if the element has been added, `false` when listener is already contained in the set of listeners.
      See Also:
        `interface RPCConnectionListener`, `class MultiRPCClient`

    - #### removeConnectionListener

          public boolean removeConnectionListener(@NotNull
                                                  RPCConnectionListener<I> listener)

      Removes `interface RPCConnectionListener` from this `class MultiRPCClient`.

      Returns:
        `true` if the element has been successfully removed; `false` if it was not present in the set of listeners.
      See Also:
        `interface RPCConnectionListener`, `class MultiRPCClient`

    - #### start

          @NotNull
          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

      Returns:
        CompletableFuture containing `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.
      See Also:
        CompletableFuture

    - #### stop

          public void stop()

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

      See Also:
        `interface RPCConnection`

    - #### close

          public void close()