FlowSession

@DoNotImplement
interface FlowSession

A FlowSession is a handle on a communication sequence between two paired flows, possibly running on separate nodes.

It is used to send and receive messages between the flows as well as to query information about the counter-flow. Sessions have their own local flow context which can be accessed via the contextProperties property. Note that the parent context is snapshotted at the point the contextProperties is first accessed, after which no other changes to the parent context will be reflected in them. See contextProperties for more information.

There are two ways of obtaining such a session:

  1. Calling FlowMessaging.initiateFlow. This will create a FlowSession object on which the first send/receive operation will attempt to kick off a corresponding ResponderFlow flow on the counterpart's node.

  2. As constructor parameter to ResponderFlow flows. This session is the one corresponding to the initiating flow and may be used for replies.

See also

Functions

Link copied to clipboard
@Suspendable
abstract fun close()

Closes this session and performs cleanup of any resources tied to this session.

Link copied to clipboard
@Suspendable
abstract fun <R : Any> receive(receiveType: Class<R>): R

Suspends until a message of type R is received from the counterparty.

Link copied to clipboard
@Suspendable
abstract fun send(payload: Any)

Queues the given payload for sending to the counterparty and continues without suspending.

Link copied to clipboard
@Suspendable
abstract fun <R : Any> sendAndReceive(receiveType: Class<R>, payload: Any): R

Serializes and queues the given payload object for sending to the counterparty. Suspends until a response is received, which must be of the given receiveType.

Properties

Link copied to clipboard
Link copied to clipboard
abstract val counterparty: MemberX500Name

The MemberX500Name of the counterparty this session is connected to.

Extensions

Link copied to clipboard
@Suspendable
inline fun <R : Any> FlowSession.receive(): R

Suspends until a message of type R is received from the counterparty.

Link copied to clipboard
@Suspendable
inline fun <R : Any> FlowSession.sendAndReceive(payload: Any): R

Serializes and queues the given payload object for sending to the counterparty. Suspends until a response is received, which must be of the given R type.