Reputation: 105
I have 2 Nodes say Party A and Party B. I am hitting an API through Party A's node with some data then I need to process(Inside a flow) this data and create a State say State A(Party A will be the participant) then I need to Initiate another flow with the processed data(from the first flow itself) and party B as Initiator. So how will I do this? . Basically What I need to do is like I need to initiate 2 flows of different initiators inside one API call.
Upvotes: 1
Views: 136
Reputation: 44
I think you can make use of sendAndReceive
. In Responder
class, which will be Initiated by the second party can make use of the data that send from the MainClassInitiator
, which will be initiated by first Party.
class MainClass {
@InitiatingFlow
@StartableByRPC
open class MainClassInitiator(val ParameterFromApi: DataType,
val NodeB: Party) : FlowLogic<SignedTransaction>() {
@Suspendable
override fun call(): SignedTransaction {
val notary = serviceHub.networkMapCache.notaryIdentities[0]
val initiator = NodeB
val session = initiateFlow(initiator)
val initiatorValue = session.sendAndReceive<SignedTransaction>(ParameterFromApi).unwrap { it }
}
}
@InitiatedBy(MainClassInitiator::class)
class Responder(val session: FlowSession) : FlowLogic<SignedTransaction>() {
@Suspendable
override fun call(): SignedTransaction {
val request = session.receive<DataType>().unwrap { it }
}
}
}
Upvotes: 1