You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(corda4): implement monitoring of state changes
Add new endpoints to corda kotlin server used to start and stop
monitoring, and get/clean state changes from its internal buffer.
Monitoring session is started separately for each client, each client
can monitor many corda states. Clients that are not active for specified
amount of time are removed. Implementation uses transaction queues that
are polled periodically by the client, instead of socketio-based
solution because we want to minimize probability of losing a transaction
from corda. This can happen when WS connection is disconnected, for
instance. With transaction queue on the connector, and explicit
get/remove calls from the client, we have greater control over what
transactions are delivered to the client code. Also, setting up socketio
on spring boot seems overly complicated and would obscurificate the
implementation.
Add reactive watchBlocksV1 that polls kotlin server and
reports new transactions asynchronously. Add CordaApiClient support to
VerifierClient.
Add functional test for both monitoring interfaces.
Update corda setup in corda-all-in-one to newer version.
Closes: #1610
Signed-off-by: Michal Bajer <[email protected]>
Copy file name to clipboardExpand all lines: packages/cactus-plugin-ledger-connector-corda/README.md
+31
Original file line number
Diff line number
Diff line change
@@ -293,6 +293,37 @@ const res = await apiClient.invokeContractV1({
293
293
});
294
294
```
295
295
296
+
### Transaction Monitoring
297
+
- There are two interfaces to monitor changes of vault states - reactive `watchBlocksV1` method, and low-level HTTP API calls.
298
+
- Note: The monitoring APIs are implemented only on kotlin-server connector (`main-server`), not typescript connector!
299
+
- For usage examples review the functional test file: `packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/monitor-transactions-v4.8.test.ts`
300
+
- Because transactions read from corda are stored on the connector, they will be lost if connector is closed/killed before transaction were read by the clients.
301
+
- Each client has own set of state monitors that are managed independently. After starting the monitoring, each new transaction is queued on the connector until read and explicitly cleared by `watchBlocksV1` or direct HTTP API call.
302
+
- Client monitors can be periodically removed by the connector, if there was no action from the client for specified amount of time.
303
+
- Client expiration delay can be configured with `cactus.sessionExpireMinutes` option. It default to 30 minutes.
304
+
- Each transaction has own index assigned by the corda connector. Index is unique for each client monitoring session. For instance:
305
+
- Stopping monitoring for given state will reset the transaction index counter for given client. After restart, it will report first transaction with index 0.
306
+
- Each client can see tha same transaction with different index.
307
+
- Index can be used to determine the transaction order for given client session.
- Reactive (RxJS) interface to observe state changes.
312
+
- Internally, it uses polling of low-level HTTP APIs.
313
+
- Watching block should return each block at least once, no blocks should be missed after startMonitor has started. The only case when transaction is lost is when connector we were connected to died.
314
+
- Transactions can be duplicated in case internal `ClearMonitorTransactionsV1` call was not successful (for instance, because of connection problems).
315
+
- Options:
316
+
-`stateFullClassName: string`: state to monitor.
317
+
-`pollRate?: number`: how often poll the kotlin server for changes (default 5 seconds).
318
+
319
+
#### Low-level HTTP API
320
+
- These should not be used when watchBlocks API is sufficient.
321
+
- Consists of the following methods:
322
+
-`startMonitorV1`: Start monitoring for specified state changes. All changes after calling this function will be stored in internal kotlin-server buffer, ready to be read by calls to `GetMonitorTransactionsV1`. Transactions occuring before the call to startMonitorV1 will not be reported.
323
+
-`GetMonitorTransactionsV1`: Read all transactions for given state name still remaining in internal buffer.
324
+
-`ClearMonitorTransactionsV1`: Remove transaction for given state name with specified index number from internal buffer. Should be used to acknowledge receiving specified transactions in user code, so that transactions are not reported multiple times.
325
+
-`stopMonitorV1`: Don't watch for transactions changes anymore, remove any transactions that were not read until now.
Copy file name to clipboardExpand all lines: packages/cactus-plugin-ledger-connector-corda/src/main-server/kotlin/gen/kotlin-spring/.openapi-generator/FILES
Copy file name to clipboardExpand all lines: packages/cactus-plugin-ledger-connector-corda/src/main-server/kotlin/gen/kotlin-spring/src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/Application.kt
Copy file name to clipboardExpand all lines: packages/cactus-plugin-ledger-connector-corda/src/main-server/kotlin/gen/kotlin-spring/src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/api/ApiPluginLedgerConnectorCorda.kt
0 commit comments