Flow Messaging
FlowMessaging allows a flow to initiate and communicate with one or more 3rd party flows.
The platform will provide an instance of FlowMessaging to flows via property injection.
A Flow can initiate one or more flows other counterparties within the network, when a new flow is initiated a FlowSession is created. The FlowSession represents the connection to an initiated flow and can be used to send and receive data between the two flows.
Example usage:
- Kotlin:
class MyFlow : ClientStartableFlow { lateinit var flowMessaging: FlowMessaging override fun call(requestBody: RestRequestBody): String { val counterparty = parse("CN=Alice, O=Alice Corp, L=LDN, C=GB") val session = flowMessaging.initiateFlow(counterparty) val result = session.sendAndReceive<String>("hello") session.close() return result } }Content copied to clipboard - Java:
class MyFlow implements ClientStartableFlow { public FlowMessaging flowMessaging; public String call(RestRequestBody requestBody) { MemberX500Name counterparty = MemberX500Name.parse("CN=Alice, O=Alice Corp, L=LDN, C=GB"); FlowSession session = flowMessaging.initiateFlow(counterparty); String result = session.sendAndReceive(String.class, "hello"); session.close(); return result; } }Content copied to clipboard
Functions
Link copied to clipboard
@Suspendable
@NotNull
Creates a communication session with a counterparty's ResponderFlow.
@Suspendable
@NotNull
@Suspendable
@NotNull
Creates a communication session with another member.
Link copied to clipboard
@Suspendable
@NotNull
Suspends until a message has been received for each session in the specified
sessions.Link copied to clipboard
@Suspendable
@NotNull
Suspends until a message has been received for each session in the specified
sessions.Link copied to clipboard
Queues the given
payload for sending to the provided sessions and continues without waiting for a response.Link copied to clipboard
Queues the given payloads for sending to the provided sessions and continues without waiting for a response.