ReconnectingCordaRPCOps

Wrapper over CordaRPCOps that handles exceptions when the node or the connection to the node fail.

All operations are retried on failure, except flow start operations that die before receiving a valid FlowHandle, in which case a CouldNotStartFlowException is thrown.

When calling methods that return a DataFeed like CordaRPCOps.vaultTrackBy, the returned DataFeed.updates object will no longer be a usable rx.Observable but an instance of ReconnectingObservable. The caller has to explicitly cast to ReconnectingObservable and call ReconnectingObservable.subscribe. If used as an rx.Observable it will just fail. The returned DataFeed.snapshot is the snapshot as it was when the feed was first retrieved.

Note: There is no guarantee that observations will not be lost.

This class is not a stable API. Any project that wants to use it, must copy and paste it.

Constructors

Link copied to clipboard
constructor(nodeHostAndPorts: List<<Error class: unknown class>>, username: String, password: String, rpcConfiguration: CordaRPCClientConfiguration, gracefulReconnect: GracefulReconnect = GracefulReconnect(), sslConfiguration: <Error class: unknown class>? = null, classLoader: ClassLoader? = null, observersPool: ExecutorService)

Types

Link copied to clipboard
data class ReconnectingRPCConnection(val nodeHostAndPorts: List<<Error class: unknown class>>, val username: String, val password: String, val rpcConfiguration: CordaRPCClientConfiguration, val sslConfiguration: <Error class: unknown class>? = null, val classLoader: ClassLoader?, val gracefulReconnect: GracefulReconnect = GracefulReconnect(), val observersPool: ExecutorService) : RPCConnection<<Error class: unknown class>>

Helper class useful for reconnecting to a Node.

Functions

Link copied to clipboard
fun close()
Link copied to clipboard
fun runFlowWithLogicalRetry(runFlow: (<Error class: unknown class>) -> <Error class: unknown class>, hasFlowStarted: (<Error class: unknown class>) -> Boolean, onFlowConfirmed: () -> Unit = {}, timeout: Duration = 4.seconds)

This function runs a flow and retries until it completes successfully.