interface FlowExternalAsyncOperation represents an external future that blocks a flow from continuing until the future returned by
FlowExternalAsyncOperation.execute has completed. Examples of external processes where
interface FlowExternalAsyncOperation would be useful
include, triggering a long running process on an external system or retrieving information from a service that might be down.
The flow will suspend while it is blocked to free up a flow worker thread, which allows other flows to continue processing while waiting for the result of this process.
interface FlowExternalAsyncOperation should ideally hold references to any external values required by
references should be passed into the implementation's constructor. For example, an amount or a reference to a Corda Service could be
It is discouraged to insert into the node's database from a
interface FlowExternalAsyncOperation, except for keeping track of deduplicationIds
that have been processed. It is possible to interact with the database from inside a
interface FlowExternalAsyncOperation but, for most
operations, is not currently supported.
java.util.concurrent.CompletableFuture<R> execute(java.lang.String deduplicationId)
Executes a future.
The future created and returned from
FlowExternalAsyncOperation.execute must handle its own threads. If a new thread is not spawned or taken from a thread
pool, then the flow worker thread will be used. This removes any benefit from using an
deduplicationId- If the flow restarts from a checkpoint (due to node restart, or via a visit to the flow hospital following an error) the execute method might be called more than once by the Corda flow state machine. For each duplicate call, the deduplicationId is guaranteed to be the same allowing duplicate requests to be de-duplicated if necessary inside the execute method.