RPCStartable Flow
RPCStartableFlow is a Flow that is started via RPC.
RPCStartableFlow.call takes in a RPCRequestData, containing the body of the RPC request that started the flow.
The string return type is treated by the platform as a JSON encoded string to return to the RPC service, and will appear in the RPC flow status when the flow completes. To assist in returning valid JSON, the JsonMarshallingService can be used.
Flows implementing this interface must have a no-arg constructor. The flow invocation will fail if this constructor does not exist.
Example usage:
Kotlin:
class MyFlow : RPCStartableFlow {
@CordaInject
lateinit var jsonMarshallingService: JsonMarshallingService
@Suspendable
override fun call(requestBody: RPCRequestData): String {
val parameters = requestBody.getRequestBodyAs<MyFlowParameters>(jsonMarshallingService)
...
return jsonMarshallingService.format(parameters)
}
}Content copied to clipboard
Java:
public class MyFlow implements RPCStartableFlow {
@CordaInject
public JsonMarshallingService jsonMarshallingService;
@Suspendable
@Override
public String call(RPCRequestData requestBody) {
MyFlowParameters parameters = requestBody.getRequestBodyAs(jsonMarshallingService, MyFlowParameters.class);
...
return jsonMarshallingService.format(parameters);
}
}Content copied to clipboard