nitesh solanki
nitesh solanki

Reputation: 177

Modifying the behaviour of Corda service object at runtime

Is it possible to update/modify methods(behaviour) of Corda service object(singleton) at run time? For example:

There is a function in the Corda Service object as shown below, which tracks for vault updates, does some processing with the state data and then makes an API call to the external system. At some point the logic of processing the state data may change and would like to modify the behaviour at run time without restarting my corda node.

Is Corda Service right way to do it? Can Java instrumentation API or Java Assist or any other bytecode re-writing tools may help?

private fun trackVaultAndUpdateExternalSystem() {
val ourIdentity = ourIdentity()
serviceHub.vaultService.trackBy<State>().updates.subscribe { update: Vault.Update<State> ->
    update.produced.forEach { message: StateAndRef<State> ->
        val state = message.state.data
        if (state.recipient == ourIdentity) {
            // do some processing and then make an API call to the external system
        }
    }
}

Upvotes: 0

Views: 111

Answers (1)

Mike Hearn
Mike Hearn

Reputation: 1473

It can be done using the JDWP but I do not recommend this at all. Corda is designed to tolerate downtime. You will not lose messages or cause errors to be observed by counterparties if your node goes offline for a while. If your app cannot tolerate even a few seconds of downtime then you'd need app hotswap but we don't formally support this today.

Upvotes: 1

Related Questions