sendAndReceive

@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.

Note that this function is not just a simple send and receive pair. It is more efficient and more correct to use sendAndReceive when you expect to do a message swap rather than use FlowSession.send and then FlowSession.receive.

Return

The received data R

Parameters

R

The data type received from the counterparty.

receiveType

The data type received from the counterparty.

payload

The data sent to the counterparty.

Throws

net.corda.v5.base.exceptions.CordaRuntimeException

if the session is closed or in a failed state.