fun proxy(timeout: Duration? = null, minVersion: Int = 0): CordaRPCOps
Returns a fresh proxy that lets you invoke RPCs on the server. Calls on it block, and if the server throws an exception then it will be rethrown on the client. Proxies are thread safe but only one RPC can be in flight at once. If youd like to perform multiple RPCs in parallel, use this function multiple times to get multiple proxies.
Creation of a proxy is a somewhat expensive operation that involves calls to the server, so if you want to do calls from many threads at once you should cache one proxy per thread and reuse them. This function itself is thread safe though so requires no extra synchronisation.
RPC sends and receives are logged on the net.corda.rpc logger.
By default there are no timeouts on calls. RPCs can survive temporary losses or changes in connectivity, like switching between wifi networks. You can specify a timeout on the level of a proxy. If a call times out it will throw RPCException.Deadline.
The CordaRPCOps defines what client RPCs are available. If an RPC returns an Observable anywhere in the
object graph returned then the server-side observable is transparently linked to a messaging queue, and that
queue linked to another observable on the client side here.
The proxy and linked observables consume some small amount of resources on the server. Its OK to just exit your process and let the server clean up, but in a long running process where you only need something for a short amount of time it is polite to cast the objects to Closeable or AutoCloseable and close it when you are done. Finalizers are in place to warn you if you lose a reference to an unclosed proxy or observable.
RPCException
- if the server version is too low or if the server isnt reachable within the given time.