Clyde D'Cruz
Clyde D'Cruz

Reputation: 2065

How to reliably observe state updates in the Corda node?

The ReconnectingCordaRPCOps.kt class available in Corda has the following note:

* Note: There is no guarantee that observations will not be lost.
  1. What are the conditions in which a observation could get lost.
  2. What would be a reliable way to continuously pull all state updates from a Corda node ?

Upvotes: 1

Views: 84

Answers (1)

Dimos
Dimos

Reputation: 8898

What are the conditions in which a observation could get lost.

During a reconnection, the previous observer is automatically unsubscribed from the observable and re-subscribed after the connection is established again. As a result, if there are any events that had happened during this window between disconnection and reconnection, they will not be emitted to the observable.

What would be a reliable way to continuously pull all state updates from a Corda node ?

Currently, the API for graceful reconnection provides two additional hooks onDisconnect and onReconnect (see docs here), which can be used to perform some reconciliation to discover these updates that were not emitted. This could be achieved by querying the node's vault using a time window [disconnection_event_time - safety_offset, reconnection_event_time + safety_offset] and then discarding/deduplicating the events that have already been seen via the observable. The larger the safety_offset is, the more reliable this approach would be in not missing events.

Upvotes: 1

Related Questions