FlowMessaging

@DoNotImplement
interface FlowMessaging

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
       }
     }
    
  • 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;
       }
    }
    

Functions

Link copied to clipboard
@Suspendable
@NotNull
abstract fun initiateFlow(@NotNull x500Name: MemberX500Name): FlowSession
@Suspendable
@NotNull
abstract fun initiateFlow(@NotNull x500Name: MemberX500Name, requireClose: Boolean): FlowSession
Creates a communication session with a counterparty's ResponderFlow.
@Suspendable
@NotNull
abstract fun initiateFlow(@NotNull x500Name: MemberX500Name, @NotNull flowContextPropertiesBuilder: FlowContextPropertiesBuilder): FlowSession
@Suspendable
@NotNull
abstract fun initiateFlow(@NotNull x500Name: MemberX500Name, requireClose: Boolean, @NotNull flowContextPropertiesBuilder: FlowContextPropertiesBuilder): FlowSession
Creates a communication session with another member.
Link copied to clipboard
@Suspendable
@NotNull
abstract fun <R> receiveAll(@NotNull receiveType: Class<out R>, @NotNull sessions: Set<FlowSession>): List<R>
Suspends until a message has been received for each session in the specified sessions.
Link copied to clipboard
@Suspendable
@NotNull
abstract fun receiveAllMap(@NotNull sessions: Map<FlowSession, Class<out Any>>): Map<FlowSession, out Any>
Suspends until a message has been received for each session in the specified sessions.
Link copied to clipboard
@Suspendable
abstract fun sendAll(@NotNull payload: Any, @NotNull sessions: Set<FlowSession>)
Queues the given payload for sending to the provided sessions and continues without waiting for a response.
Link copied to clipboard
@Suspendable
abstract fun sendAllMap(@NotNull payloadsPerSession: Map<FlowSession, Any>)
Queues the given payloads for sending to the provided sessions and continues without waiting for a response.